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

bug: repeated vs comma separated array headers #19

Closed
adriangb opened this issue Jan 21, 2022 · 2 comments
Closed

bug: repeated vs comma separated array headers #19

adriangb opened this issue Jan 21, 2022 · 2 comments

Comments

@adriangb
Copy link
Owner

As per specs, these should be treated as equivalent. But I believe we are only dealing with the latter right now. It might make sense to double check what the ASGI spec, the HTTP specs, the OpenAPI spec, requests/TesClient and finally Starlette have to say about the matter and then fix the issue (if there is one)

@adriangb adriangb changed the title but: repeated vs comma separated headers bug: repeated vs comma separated headers Jan 21, 2022
@adriangb adriangb changed the title bug: repeated vs comma separated headers bug: repeated vs comma separated array headers Jan 21, 2022
@adriangb
Copy link
Owner Author

It looks like requests can send repeated headers: https://stackoverflow.com/a/19901034

So at least the tests won't be a total pain to write.

It also looks like Starlette supports repeated headers but does nothing about comma separated ones. This makes sense.

Given our need to support array headers, think the most flexible/logical thing to do is to merge any repeated headers (in order, as per the spec) with the first value. So [("x-header", "1,2"), ("x-header", "3")] becomes {"x-header": "1,2,3"}. The we'd parse just like we currently do.

@adriangb
Copy link
Owner Author

It looks like requests no longer accepts repeated headers.
httpx does, but there's a bug: encode/httpx#2038

So this will most likely just wait until that is fixed in HTTPX

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

1 participant