You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Http headers are meant to be case insensitive, but lambda events use case sensitive dicts for the header keys.
For example getting the Authorization header you will need to do a case insensitive look up to support if the header is authorization. So you end up doing something like this.
defget_header_value(
self, name: str, default_value: Optional[str] =None, case_sensitive: Optional[bool] =False
) ->Optional[str]:
"""Get header value by name Parameters ---------- name: str Header name default_value: str, optional Default value if no value was found by name case_sensitive: bool Whether to use a case sensitive look up Returns ------- str, optional Header value """ifcase_sensitive:
returnself.headers.get(name, default_value)
returnnext((valueforkey, valueinself.headers.items() ifname.lower() ==key.lower()), default_value)
Questions
Should we default to case insensitive look ups? This is what most people would want?
Just return the first match? Or support returning all matches?
michaelbrewer
changed the title
Case insensitive lookup of header values in http proxy events
Case insensitive lookup of header values in http proxy events [RFC]
Sep 30, 2020
michaelbrewer
changed the title
Case insensitive lookup of header values in http proxy events [RFC]
Case insensitive lookup of header values in http proxy events
Oct 1, 2020
Is your feature request related to a problem? Please describe.
Http headers are meant to be case insensitive, but lambda events use case sensitive dicts for the header keys.
For example getting the
Authorization
header you will need to do a case insensitive look up to support if the header isauthorization
. So you end up doing something like this.Describe the solution you'd like
Update
BaseProxyEvent.get_header_value
method to support case insensitive lookups by defaultQuestions
Describe alternatives you've considered
Use the requests CaseInsensitiveDict or port it :
Additional context
From the Http 1.1 spec, https headers are not supposed to be case sensitive: https://www.w3.org/Protocols/rfc2616/rfc2616.html
The text was updated successfully, but these errors were encountered: