Skip to content
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 ldclient/impl/datasource/feature_requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_all_data(self):
from_cache = True
else:
data = json.loads(r.data.decode('UTF-8'))
etag = r.getheader('ETag')
etag = r.headers.get('ETag')
from_cache = False
if etag is not None:
self._cache[uri] = CacheEntry(data=data, etag=etag)
Expand Down
2 changes: 1 addition & 1 deletion ldclient/impl/events/event_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def _trigger_flush(self):
pass

def _handle_response(self, r):
server_date_str = r.getheader('Date')
server_date_str = r.headers.get('Date')
if server_date_str is not None:
server_date = parsedate(server_date_str)
if server_date is not None:
Expand Down
17 changes: 14 additions & 3 deletions testing/stub_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,28 @@ def get_all_data(self):
raise self.exception
return self.all_data


class _MockHTTPHeaderDict(dict):
def __init__(self, d):
super().__init__({k.lower(): v for k, v in d.items()})

def get(self, key, default=None):
return super().get(key.lower(), default)


class MockResponse:
def __init__(self, status, headers):
self._status = status
self._headers = headers
self._headers = _MockHTTPHeaderDict(headers)

@property
def status(self):
return self._status

def getheader(self, name):
return self._headers.get(name.lower())
@property
def headers(self):
return self._headers


class MockHttp:
def __init__(self):
Expand Down