Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cohttp-eio(client): 400 BadRequest due to Connection: TE #973

Open
art-w opened this issue Feb 20, 2023 · 3 comments
Open

cohttp-eio(client): 400 BadRequest due to Connection: TE #973

art-w opened this issue Feb 20, 2023 · 3 comments

Comments

@art-w
Copy link
Contributor

art-w commented Feb 20, 2023

I'm getting a 400 Bad Request rather than the expected 404 NotFound:

let () =
  Eio_main.run @@ fun env ->
  let response, _ = Cohttp_eio.Client.get env ~host:"bttracker.debian.org" ~port:6969 "/" in
  Format.printf "%s@." (Http.Status.to_string @@ Http.Response.status response)

I think this is caused by the Connection: TE header:

$ curl -v 'http://bttracker.debian.org:6969/' # 404 NotFound <- expected
$ curl -v -H 'TE: trailers' 'http://bttracker.debian.org:6969/' # 404 NotFound <- still ok
$ curl -v -H 'Connection: TE' 'http://bttracker.debian.org:6969/' # 400 BadRequest
$ curl -v -H 'Connection: TE' -H 'TE: trailers' 'http://bttracker.debian.org:6969/' # 400 BadRequest

I've no idea what this header is doing, or why cohttp-eio is the only client that enables it. In any case, the bug seems specific to this cheap server, but it would be nice if there was a way of not sending this header :)

@mseri
Copy link
Collaborator

mseri commented Feb 20, 2023

Ping @bikallem

@bikallem
Copy link
Contributor

This functionality is the implementation of HTTP/1.1 spec (https://www.rfc-editor.org/rfc/rfc9110#section-10.1.4)

A sender of TE MUST also send a "TE" connection option within the Connection header field (Section 7.6.1) to inform intermediaries not to forward this field.

In any case, the bug seems specific to this cheap server, but it would be nice if there was a way of not sending this header :)

A HTTP/1.1 non conforming (various degrees) client request is definitely on the cards.

@art-w
Copy link
Contributor Author

art-w commented Feb 22, 2023

Ha I see, thanks for the pointer! Unless there are more reports of servers rejecting this header, I don't think it's a pressing issue :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants