Skip to content

Case insensitive headers fix #236

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

Merged
merged 1 commit into from
Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openapi_core/contrib/django/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create(cls, request):
parameters = RequestParameters(
path=path,
query=request.GET,
header=request.headers,
header=request.headers.items(),
cookie=request.COOKIES,
)
full_url_pattern = urljoin(
Expand Down
6 changes: 3 additions & 3 deletions openapi_core/validation/request/datatypes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""OpenAPI core validation request datatypes module"""
import attr
from werkzeug.datastructures import ImmutableMultiDict
from werkzeug.datastructures import ImmutableMultiDict, Headers

from openapi_core.validation.datatypes import BaseValidationResult

Expand All @@ -13,14 +13,14 @@ class RequestParameters(object):
query
Query string parameters as MultiDict. Must support getlist method.
header
Request headers as dict.
Request headers as Headers.
cookie
Request cookies as dict.
path
Path parameters as dict. Gets resolved against spec if empty.
"""
query = attr.ib(factory=ImmutableMultiDict)
header = attr.ib(factory=dict)
header = attr.ib(factory=Headers, converter=Headers)
cookie = attr.ib(factory=dict)
path = attr.ib(factory=dict)

Expand Down
8 changes: 6 additions & 2 deletions tests/unit/security/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ def scheme(self):
def provider(self, scheme):
return HttpProvider(scheme)

def test_issue29427(self, provider):
@pytest.mark.parametrize(
'header',
['authorization', 'Authorization', 'AUTHORIZATION'],
)
def test_header(self, provider, header):
"""Tests HttpProvider against Issue29427
https://bugs.python.org/issue29427
"""
jwt = 'MQ'
headers = {
'Authorization': 'Bearer {0}'.format(jwt),
header: 'Bearer {0}'.format(jwt),
}
request = MockRequest(
'http://localhost', 'GET', '/pets',
Expand Down