diff --git a/contract-tests/service.py b/contract-tests/service.py index 1fa9a97..fdade79 100644 --- a/contract-tests/service.py +++ b/contract-tests/service.py @@ -70,6 +70,7 @@ def status(): 'secure-mode-hash', 'tags', 'migrations', + 'event-gzip', 'event-sampling', 'polling-gzip', 'inline-context', diff --git a/ldclient/impl/events/event_processor.py b/ldclient/impl/events/event_processor.py index b86b74b..ad5fde3 100644 --- a/ldclient/impl/events/event_processor.py +++ b/ldclient/impl/events/event_processor.py @@ -12,6 +12,7 @@ import uuid import queue import urllib3 +import gzip from ldclient.config import Config from datetime import timedelta from random import Random @@ -559,11 +560,13 @@ def _post_events_with_retry( ): hdrs = _headers(config) hdrs['Content-Type'] = 'application/json' + hdrs['Content-Encoding'] = 'gzip' if payload_id: hdrs['X-LaunchDarkly-Event-Schema'] = str(__CURRENT_EVENT_SCHEMA__) hdrs['X-LaunchDarkly-Payload-ID'] = payload_id can_retry = True context = "posting %s" % events_description + data = gzip.compress(bytes(body, 'utf-8')) while True: next_action_message = "will retry" if can_retry else "some events were dropped" try: @@ -571,7 +574,7 @@ def _post_events_with_retry( 'POST', uri, headers=hdrs, - body=body, + body=data, timeout=urllib3.Timeout(connect=config.http.connect_timeout, read=config.http.read_timeout), retries=0 )