Mercurial > kallithea
changeset 6760:d28545413343 stable
git: include an LF at the end of the service advertisement (Fixes #230)
This fixes hg-git/Dulwich and possibly other conservative Git clients,
which do not ignore the absence of the LF.
The original comment was a guess based on reverse engineering the protocol
not specified in the documentation yet at that moment. Now that the
documentation exists and states this explicitly, just do as it says.
author | Andrew Shadura <andrew@shadura.me> |
---|---|
date | Thu, 14 Jul 2016 14:56:20 +0200 |
parents | 86b39c257c8d |
children | 25dae19e0719 |
files | kallithea/lib/middleware/pygrack.py |
diffstat | 1 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/middleware/pygrack.py Tue Jun 14 22:14:39 2016 +0200 +++ b/kallithea/lib/middleware/pygrack.py Thu Jul 14 14:56:20 2016 +0200 @@ -72,14 +72,17 @@ log.debug('command %s not allowed', git_command) return exc.HTTPMethodNotAllowed() - # note to self: - # please, resist the urge to add '\n' to git capture and increment - # line count by 1. - # The code in Git client not only does NOT need '\n', but actually - # blows up if you sprinkle "flush" (0000) as "0001\n". - # It reads binary, per number of bytes specified. - # if you do add '\n' as part of data, count it. - server_advert = '# service=%s' % git_command + # From Documentation/technical/http-protocol.txt shipped with Git: + # + # Clients MUST verify the first pkt-line is `# service=$servicename`. + # Servers MUST set $servicename to be the request parameter value. + # Servers SHOULD include an LF at the end of this line. + # Clients MUST ignore an LF at the end of the line. + # + # smart_reply = PKT-LINE("# service=$servicename" LF) + # ref_list + # "0000" + server_advert = '# service=%s\n' % git_command packet_len = str(hex(len(server_advert) + 4)[2:].rjust(4, '0')).lower() _git_path = kallithea.CONFIG.get('git_path', 'git') cmd = [_git_path, git_command[4:],