@@ -29,6 +29,7 @@ def __init__(self, pubnub):
2929 self .pubnub = pubnub
3030 self ._cancellation_event = None
3131 self ._sort_params = False
32+ self ._use_compression = self .pubnub .config .should_compress
3233
3334 def cancellation_event (self , event ):
3435 self ._cancellation_event = event
@@ -88,9 +89,12 @@ def allow_redirects(self):
8889 def use_base_path (self ):
8990 return True
9091
92+ def is_compressable (self ):
93+ return False
94+
9195 def request_headers (self ):
9296 headers = {}
93- if self .pubnub . config . should_compress :
97+ if self .__compress_request () :
9498 headers ["Content-Encoding" ] = "gzip"
9599 if self .http_method () == HttpMethod .POST :
96100 headers ["Content-type" ] = "application/json"
@@ -108,7 +112,7 @@ def encoded_params(self):
108112
109113 def options (self ):
110114 data = self .build_data ()
111- if data and self .pubnub . config . should_compress :
115+ if data and self .__compress_request () :
112116 data = zlib .compress (data .encode ('utf-8' ), level = 2 )
113117 return RequestOptions (
114118 path = self .build_path (),
@@ -284,3 +288,6 @@ def create_exception(self, category, response, response_info, exception):
284288 exception .status = status
285289
286290 return exception
291+
292+ def __compress_request (self ):
293+ return (self .is_compressable () and self ._use_compression )
0 commit comments