Skip to content
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

fix: Gzip header should only be set on polling #262

Merged
merged 2 commits into from
Jan 30, 2024
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ install-contract-tests-deps:
poetry install --with contract-tests

.PHONY: start-contract-test-service
start-contract-test-service:
start-contract-test-service: install-contract-tests-deps
@cd contract-tests && poetry run python service.py $(PORT)

.PHONY: start-contract-test-service-bg
Expand All @@ -71,7 +71,7 @@ run-contract-tests:

.PHONY: contract-tests
contract-tests: #! Run the contract test harness
contract-tests: install-contract-tests-deps start-contract-test-service-bg run-contract-tests
contract-tests: start-contract-test-service-bg run-contract-tests

#
# SSE contract test service commands
Expand Down
6 changes: 6 additions & 0 deletions contract-tests/client_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def __init__(self, tag, config):
if streaming.get("baseUri") is not None:
opts["stream_uri"] = streaming["baseUri"]
_set_optional_time_prop(streaming, "initialRetryDelayMs", opts, "initial_reconnect_delay")
else:
opts['stream'] = False
polling = config["polling"]
if polling.get("baseUri") is not None:
opts["base_uri"] = polling["baseUri"]
_set_optional_time_prop(polling, "pollIntervalMs", opts, "poll_interval")

if config.get("events") is not None:
events = config["events"]
Expand Down
1 change: 1 addition & 0 deletions contract-tests/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def status():
body = {
'capabilities': [
'server-side',
'server-side-polling',
'all-flags-with-reasons',
'all-flags-client-side-only',
'all-flags-details-only-for-tracked-flags',
Expand Down
1 change: 1 addition & 0 deletions ldclient/impl/datasource/feature_requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def get_all_data(self):
uri = self._poll_uri
hdrs = _headers(self._config)
cache_entry = self._cache.get(uri)
hdrs['Accept-Encoding'] = 'gzip'
if cache_entry is not None:
hdrs['If-None-Match'] = cache_entry.etag
r = self._http.request('GET', uri,
Expand Down
3 changes: 1 addition & 2 deletions ldclient/impl/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def _application_header_value(application: dict) -> str:

def _base_headers(config):
headers = {'Authorization': config.sdk_key or '',
'User-Agent': 'PythonClient/' + VERSION,
'Accept-Encoding': 'gzip'
'User-Agent': 'PythonClient/' + VERSION
}

app_value = _application_header_value(config.application)
Expand Down
1 change: 0 additions & 1 deletion testing/impl/datasource/test_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def test_request_properties():
assert req.method == 'GET'
assert req.headers.get('Authorization') == 'sdk-key'
assert req.headers.get('User-Agent') == 'PythonClient/' + VERSION
assert req.headers['Accept-Encoding'] == 'gzip'
assert req.headers.get('X-LaunchDarkly-Wrapper') is None
assert req.headers.get('X-LaunchDarkly-Tags') is None

Expand Down
8 changes: 0 additions & 8 deletions testing/impl/events/test_event_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,6 @@ def test_sdk_key_is_sent():

assert mock_http.request_headers.get('Authorization') == 'SDK_KEY'

def test_default_headers_are_send():
with DefaultTestProcessor() as ep:
ep.send_event(EventInputIdentify(timestamp, context))
ep.flush()
ep._wait_until_inactive()

assert mock_http.request_headers.get('Accept-Encoding') == 'gzip'

def test_wrapper_header_not_sent_when_not_set():
with DefaultTestProcessor() as ep:
ep.send_event(EventInputIdentify(timestamp, context))
Expand Down
Loading