adriangb / xpresso

A composable Python ASGI web framework
https://xpresso-api.dev/
MIT License
178 stars 4 forks source link

bug: repeated vs comma separated array headers #19

Closed adriangb closed 2 years ago

adriangb commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

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