Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
13 changes: 9 additions & 4 deletions 13 .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: python
version: 6.1.0
version: 6.2.0
schema: 1
scm: github.com/pubnub/python
sdks:
Expand All @@ -18,7 +18,7 @@ sdks:
distributions:
- distribution-type: library
distribution-repository: package
package-name: pubnub-6.1.0
package-name: pubnub-6.2.0
location: https://pypi.org/project/pubnub/
supported-platforms:
supported-operating-systems:
Expand Down Expand Up @@ -97,8 +97,8 @@ sdks:
-
distribution-type: library
distribution-repository: git release
package-name: pubnub-6.1.0
location: https://github.com/pubnub/python/releases/download/v6.1.0/pubnub-6.1.0.tar.gz
package-name: pubnub-6.2.0
location: https://github.com/pubnub/python/releases/download/v6.2.0/pubnub-6.2.0.tar.gz
supported-platforms:
supported-operating-systems:
Linux:
Expand Down Expand Up @@ -169,6 +169,11 @@ sdks:
license-url: https://github.com/aio-libs/aiohttp/blob/master/LICENSE.txt
is-required: Required
changelog:
- date: 2022-03-21
version: v6.2.0
changes:
- type: feature
text: "Add methods to change use compression option on chosen endpoints."
- date: 2022-03-01
version: v6.1.0
changes:
Expand Down
6 changes: 6 additions & 0 deletions 6 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v6.2.0
March 21 2022

#### Added
- Add methods to change use compression option on chosen endpoints.

## v6.1.0
March 01 2022

Expand Down
11 changes: 9 additions & 2 deletions 11 pubnub/endpoints/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self, pubnub):
self.pubnub = pubnub
self._cancellation_event = None
self._sort_params = False
self._use_compression = self.pubnub.config.should_compress

def cancellation_event(self, event):
self._cancellation_event = event
Expand Down Expand Up @@ -88,9 +89,12 @@ def allow_redirects(self):
def use_base_path(self):
return True

def is_compressable(self):
return False

def request_headers(self):
headers = {}
if self.pubnub.config.should_compress:
if self.__compress_request():
headers["Content-Encoding"] = "gzip"
if self.http_method() == HttpMethod.POST:
headers["Content-type"] = "application/json"
Expand All @@ -108,7 +112,7 @@ def encoded_params(self):

def options(self):
data = self.build_data()
if data and self.pubnub.config.should_compress:
if data and self.__compress_request():
data = zlib.compress(data.encode('utf-8'), level=2)
return RequestOptions(
path=self.build_path(),
Expand Down Expand Up @@ -284,3 +288,6 @@ def create_exception(self, category, response, response_info, exception):
exception.status = status

return exception

def __compress_request(self):
return (self.is_compressable() and self._use_compression)
7 changes: 7 additions & 0 deletions 7 pubnub/endpoints/file_operations/send_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def build_file_upload_request(self):
def http_method(self):
return HttpMethod.POST

def use_compression(self, compress=True):
self._use_compression = bool(compress)
return self

def is_compressable(self):
return True

def custom_params(self):
return {}

Expand Down
7 changes: 7 additions & 0 deletions 7 pubnub/endpoints/pubsub/fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def use_post(self, use_post):
self._use_post = bool(use_post)
return self

def is_compressable(self):
return True

def use_compression(self, compress=True):
self._use_compression = bool(compress)
return self

def meta(self, meta):
self._meta = meta
return self
Expand Down
7 changes: 7 additions & 0 deletions 7 pubnub/endpoints/pubsub/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def use_post(self, use_post):
self._use_post = bool(use_post)
return self

def use_compression(self, compress=True):
self._use_compression = bool(compress)
return self

def is_compressable(self):
return True

def should_store(self, should_store):
self._should_store = bool(should_store)
return self
Expand Down
2 changes: 1 addition & 1 deletion 2 pubnub/pubnub_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

class PubNubCore:
"""A base class for PubNub Python API implementations"""
SDK_VERSION = "6.1.0"
SDK_VERSION = "6.2.0"
SDK_NAME = "PubNub-Python"

TIMESTAMP_DIVIDER = 1000
Expand Down
2 changes: 1 addition & 1 deletion 2 requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ aiohttp
requests
cbor2
behave
-e git://github.com/pubnub/vcrpy.git@aiotthp_redirect_enabled#egg=vcrpy
-e git+https://github.com/pubnub/vcrpy.git@aiotthp_redirect_enabled#egg=vcrpy
2 changes: 1 addition & 1 deletion 2 setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='pubnub',
version='6.1.0',
version='6.2.0',
description='PubNub Real-time push service in the cloud',
author='PubNub',
author_email='support@pubnub.com',
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.