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

When acting as a client, processing HTTP/1.0 responses fails #192

Open
vulpyne opened this issue Aug 17, 2021 · 4 comments
Open

When acting as a client, processing HTTP/1.0 responses fails #192

vulpyne opened this issue Aug 17, 2021 · 4 comments

Comments

@vulpyne
Copy link

vulpyne commented Aug 17, 2021

It seems like this line is the issue:

ensure_eq!(version, 1, "Unsupported HTTP version");

It is my understanding there shouldn't be a meaningful difference parsing a HTTP/1.0 with a 1.1 parser since the only differences are some extra headers and possible result codes which wouldn't exist in the 1.0 response.

httparse_res.version will be 0 in the case of a HTTP/1.0 response. Perhaps that code is attempting to match on the major version number, however httparse uses that field for the minor one which is a bit unintuitive.

@jbr
Copy link
Member

jbr commented Aug 18, 2021

async-h1 is currently an http/1.1 library and does not yet support http/1.0. you're right that the differences are minor, but as of the current release of http-types and async-h1, it is exclusively http/1.1

@vulpyne
Copy link
Author

vulpyne commented Aug 18, 2021

Is there anything in a HTTP/1.0 response that would cause issues with a HTTP/1.1 parser? If not, what is the benefit of explicitly refusing to handle a HTTP/1.0 response?

@jbr
Copy link
Member

jbr commented Aug 18, 2021

It's not that we couldn't add support for 1.0 at some point (and I've started in on that in the v3 branch) but that the current version of async-h1 is intended to be an async http/1.1 client and server. I believe you're right that http/1.0 would be trivial to support on the client side

@vulpyne
Copy link
Author

vulpyne commented Aug 18, 2021

Trivial or not, I would expect someone else to do it for me. Would you accept a pull request that just changed the conditional to not explicitly error out on a HTTP/1.0 response? i.e. change it to ensure!(version < 2, "Unsupported HTTP version");

If you wanted to be super-safe I guess there could even be a feature flag that allowed rejecting those responses as before, although I personally don't really see the advantage.

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

2 participants