diff --git a/ldclient/impl/http.py b/ldclient/impl/http.py index 858fd371..9ebb0102 100644 --- a/ldclient/impl/http.py +++ b/ldclient/impl/http.py @@ -19,7 +19,9 @@ def _application_header_value(application: dict) -> str: def _base_headers(config): headers = {'Authorization': config.sdk_key or '', - 'User-Agent': 'PythonClient/' + VERSION} + 'User-Agent': 'PythonClient/' + VERSION, + 'Accept-Encoding': 'gzip' + } app_value = _application_header_value(config.application) if app_value: diff --git a/testing/impl/datasource/test_feature_requester.py b/testing/impl/datasource/test_feature_requester.py index 2deb47b2..a38a31f6 100644 --- a/testing/impl/datasource/test_feature_requester.py +++ b/testing/impl/datasource/test_feature_requester.py @@ -9,7 +9,7 @@ def test_get_all_data_returns_data(): with start_server() as server: config = Config(sdk_key = 'sdk-key', base_uri = server.uri) fr = FeatureRequesterImpl(config) - + flags = { 'flag1': { 'key': 'flag1' } } segments = { 'segment1': { 'key': 'segment1' } } resp_data = { 'flags': flags, 'segments': segments } @@ -31,6 +31,7 @@ def test_get_all_data_sends_headers(): req = server.require_request() assert req.headers['Authorization'] == 'sdk-key' assert req.headers['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 diff --git a/testing/impl/datasource/test_streaming.py b/testing/impl/datasource/test_streaming.py index a3cfe60f..eb90173a 100644 --- a/testing/impl/datasource/test_streaming.py +++ b/testing/impl/datasource/test_streaming.py @@ -43,6 +43,7 @@ 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 diff --git a/testing/impl/events/test_event_processor.py b/testing/impl/events/test_event_processor.py index b2bf91de..51d8b0e4 100644 --- a/testing/impl/events/test_event_processor.py +++ b/testing/impl/events/test_event_processor.py @@ -479,6 +479,14 @@ 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))