# HG changeset patch # User Andrew Shadura # Date 1468500980 -7200 # Node ID 1e373254388cf67a084d39234f9b7a4548174649 # Parent b5859022ac6967c16bb42b7f13d69e342e490791 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. diff -r b5859022ac69 -r 1e373254388c kallithea/lib/middleware/pygrack.py --- a/kallithea/lib/middleware/pygrack.py Tue Jul 12 21:47:14 2016 +0200 +++ b/kallithea/lib/middleware/pygrack.py Thu Jul 14 14:56:20 2016 +0200 @@ -102,14 +102,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:],