Skip to content

Commit 1796e52

Browse files
committed
Fixes usage of upper case headears
1 parent 683e7e3 commit 1796e52

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

algoliasearch/http/request_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, headers, query_parameters, timeouts, data):
1616
def __setitem__(self, option, value):
1717
# type: (str, Any) -> None
1818

19-
if option in Params.HEADERS:
19+
if option.upper() in [header.upper() for header in Params.HEADERS]:
2020
self.headers[option] = str(value)
2121
elif option in Params.QUERY_PARAMETERS:
2222
self.query_parameters[option] = value

tests/unit/http/test_request_options.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def setUp(self):
1414

1515
# Headers
1616
'User-Agent': 'foo',
17-
'X-Forwarded-For': '1.1.1.1',
17+
18+
# Upper case header, should equal to `X-Forwarded-For`
19+
'X-FORWARDED-FOR': '1.1.1.1',
1820

1921
# Query Params
2022
'createIfNotExists': True,
@@ -39,7 +41,7 @@ def test_default_user_agent(self):
3941
def test_headers(self):
4042
self.assertEqual(self.request_options.headers['User-Agent'], 'foo')
4143
self.assertEqual(
42-
self.request_options.headers['X-Forwarded-For'],
44+
self.request_options.headers['X-FORWARDED-FOR'],
4345
'1.1.1.1'
4446
)
4547

0 commit comments

Comments
 (0)