On Thu, Nov 15, 2018 at 01:51:52PM -0800, Josh Steadmon wrote:
> > This patch tightens both of those (I also made a few stylistic tweaks,
> > and added the ERR condition to show where it would go). I dunno. Part of
> > me sees this as a nice cleanup, but maybe it is better to just leave it
> > alone. A lot of these behaviors are just how it happens to work now, and
> > not part of the spec, but we don't know what might be relying on them.
>
> At least according to the protocol-v2 and http-protocol docs, the
> stricter behavior seems correct:
>
> For the first point above, dumb servers should never use an
> "application/x-git-*" content type (http-protocol.txt line 163-167).
>
> For the second point, the docs require v2 servers to use
> "application/x-git-*" content types. protocol-v2.txt lines 63-65 state
> that v2 clients should make a smart http request, while
> http-protocol.txt lines 247-252 state that a smart server's response
> type must be "application/x-git-*".
Thanks for digging into the spec. I agree that it's pretty clear that
the appropriate content-type is expected.
> Of course we don't know if other implementations follow the spec, but
> ISTM that this patch at least doesn't contradict how we've promised the
> protocols should work.
These seem like pretty unlikely ways for a buggy server to behave, so I
think it's a reasonable risk. I also checked GitHub's implementation
(which recently learned to speak v2) and made sure that it works. :)
I didn't check JGit, but given the provenance, I assume it's fine.
Amusingly, this does break the test you just added, because it tries to
issue an ERR after claiming "text/html" (and after my patch, we
correctly fall back to dumb-http).
> If no one has any objections, I'll include the diff below in v2. Thanks
> for the help Jeff!
I think it makes sense to do the refactoring first as a separate step.
And of course it needs a commit message. So how about this series (your
original is rebased on top)?
[1/3]: remote-curl: refactor smart-http discovery
[2/3]: remote-curl: tighten "version 2" check for smart-http
[3/3]: remote-curl: die on server-side errors
remote-curl.c | 96 +
t/lib-httpd.sh | 1 +
t/lib-httpd/apache.conf | 4 ++
t/lib-httpd/error-smart-http.sh | 3 ++
t/t5551-http-fetch-smart.sh | 5 ++
5 files changed, 75 insertions(+), 34 deletions(-)
create mode 100644 t/lib-httpd/error-smart-http.sh
-Peff