<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Hi</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Thanks for reporting ... and for the
proposed fix.</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">That bug is something I missed when
porting to py3. Apparently, other Git implementations are less
strict, and it didn't come up while testing.</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">But I think the fix can be made simpler
and more complete: <br>
</div>
<div class="moz-cite-prefix"><a class="moz-txt-link-freetext" href="https://kallithea-scm.org/repos/kallithea-incoming/changeset/b9be708625087a6618240d614d27782632a80b2b">https://kallithea-scm.org/repos/kallithea-incoming/changeset/b9be708625087a6618240d614d27782632a80b2b</a></div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Can you confirm this works as well for
you?</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">/Mads<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">On 10/28/20 2:13 PM, Valentin wrote:<br>
</div>
<blockquote type="cite"
cite="mid:e16c76fa-c3a1-731e-ea57-92ebcb0bf508@vrvis.at">Hi,
<br>
<br>
I've noticed cases in which kallithea returns headers that seem
incorrect on git requests over http.
<br>
This first occurred as some users had problems fetching repos from
our kallithea instance with software that uses the JGit library on
Windows (user agent string: JGit/5.4.2.201908231537-r).
<br>
The error message noted:
<br>
'git fetch' command failed (repository dir: <TeamCity data
dir>/system/caches/git/git-233054F9.git).
<br>
stderr: https:<redacted>: expected Content-Type
application/x-git-upload-pack-result; received Content-Type
application/x-b'git-upload-pack'-result
<br>
<br>
I was able to reproduce this header by using git for windows,
although it didn't produce an error:
<br>
valentin@CASHEW MINGW64 ~
<br>
$ GIT_CURL_VERBOSE=1 git clone https:<redacted>
<br>
Cloning into 'master'...
<br>
<br>
...
<br>
...
<br>
12:14:51.522612 http.c:721 <= Recv header,
0000000059 bytes (0x0000003b)
<br>
12:14:51.522612 http.c:733 <= Recv header:
Content-Type: application/x-git-upload-pack-advertisement
<br>
...
<br>
...
<br>
12:15:32.147657 http.c:721 <= Recv header,
0000000055 bytes (0x00000037)
<br>
12:15:32.147657 http.c:733 <= Recv header:
Content-Type: application/x-b'git-upload-pack'-result
<br>
<br>
<br>
The problem arises in pygrack.py [0] where encode('utf-8') is used
on line 178:
<br>
resp.content_type = 'application/x-%s-result' %
git_command.encode('utf-8')
<br>
<br>
in contrary, on line 128 str() is used:
<br>
resp.content_type = 'application/x-%s-advertisement' %
str(git_command)
<br>
<br>
I patched my kallithea instance to use str() (see the attached
diff) which resolves the problem.
<br>
I think this is safe to do, as git_command is checked against
valid commands before and therefor must be convertible to a
string.
<br>
<br>
Hope i got that right and you can integrate this into an upcoming
release.
<br>
<br>
Cheers,
<br>
Valentin
<br>
<br>
<br>
[0]
<a class="moz-txt-link-freetext" href="https://kallithea-scm.org/repos/kallithea/files/855b37d3bacdc6175566ca7d23c19e2352da1087/kallithea/lib/middleware/pygrack.py">https://kallithea-scm.org/repos/kallithea/files/855b37d3bacdc6175566ca7d23c19e2352da1087/kallithea/lib/middleware/pygrack.py</a><br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
kallithea-general mailing list
<a class="moz-txt-link-abbreviated" href="mailto:kallithea-general@sfconservancy.org">kallithea-general@sfconservancy.org</a>
<a class="moz-txt-link-freetext" href="https://lists.sfconservancy.org/mailman/listinfo/kallithea-general">https://lists.sfconservancy.org/mailman/listinfo/kallithea-general</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>