← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/turnip:py3-http-protocol-version into turnip:master

 

Thiago F. Pappacena has proposed merging ~pappacena/turnip:py3-http-protocol-version into turnip:master with ~pappacena/turnip:py3-http-detect-git-request as a prerequisite.

Commit message:
Py3 compat for HTTP protocol version header

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/turnip/+git/turnip/+merge/394371
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/turnip:py3-http-protocol-version into turnip:master.
diff --git a/turnip/pack/git.py b/turnip/pack/git.py
index 83b672d..b795616 100644
--- a/turnip/pack/git.py
+++ b/turnip/pack/git.py
@@ -506,8 +506,8 @@ class PackBackendProtocol(PackServerProtocol):
 
         cmd_env = {}
         write_operation = False
-        version = params.get(b'version', 0)
-        cmd_env["GIT_PROTOCOL"] = 'version=%s' % version
+        version = params.get(b'version', b'0')
+        cmd_env["GIT_PROTOCOL"] = 'version=%s' % six.ensure_text(version)
         if version == b'2':
             params.pop(b'turnip-advertise-refs', None)
         if command == b'git-upload-pack':
diff --git a/turnip/pack/http.py b/turnip/pack/http.py
index 582c39c..8f4ce1c 100644
--- a/turnip/pack/http.py
+++ b/turnip/pack/http.py
@@ -84,7 +84,7 @@ def fail_request(request, message, code=http.INTERNAL_SERVER_ERROR):
 
 def get_protocol_version_from_request(request):
     version_header = request.requestHeaders.getRawHeaders(
-        'git-protocol', [b'version=0'])[0]
+        b'git-protocol', [b'version=0'])[0]
     try:
         return six.ensure_binary(version_header).split(b'version=', 1)[1]
     except IndexError: