werkzeug.Headers allows to add multiple headers with the same name:
from werkzeug import Headers
h = Headers()
h.add("example", "value1")
h.add("example", "value2")
h.get_all("example")
> ['value1', 'value2']
Trying to write a test case to gracefully prevent users from doing so with a custom header, I noticed that when using werkzeug's TestClient and issuing a get, the request.headers context only receive the latest value, not both.
It seems that this is due to
|
for key, value in headers.to_wsgi_list(): |
|
result["HTTP_%s" % key.upper().replace("-", "_")] = value |
Should these be modified to preserve all values instead of replacing them?
I'd gladly change it if it makes sense.
werkzeug.Headersallows to add multiple headers with the same name:Trying to write a test case to gracefully prevent users from doing so with a custom header, I noticed that when using werkzeug's
TestClientand issuing aget, therequest.headerscontext only receive the latest value, not both.It seems that this is due to
werkzeug/src/werkzeug/test.py
Lines 743 to 744 in e7ba08f
Should these be modified to preserve all values instead of replacing them?
I'd gladly change it if it makes sense.