Skip to content

Commit c4fadb2

Browse files
authored
Merge pull request #21 from zejn/master
Facilitate easier use of another networking library
2 parents e743dc9 + 097d5bc commit c4fadb2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pywebpush/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ def send(self, data, headers={}, ttl=0, gcm_key=None, reg_id=None):
209209
headers['ttl'] = ttl
210210
# Additionally useful headers:
211211
# Authorization / Crypto-Key (VAPID headers)
212-
return requests.post(endpoint,
213-
data=encoded_data,
212+
return self._post(endpoint, encoded_data, headers)
213+
214+
def _post(self, url, data, headers):
215+
"""Make POST request on specified Web Push endpoint with given data
216+
and headers.
217+
218+
Subclass this class and override this method if you want to use any
219+
other networking library or interface and keep the business logic.
220+
"""
221+
return requests.post(url,
222+
data=data,
214223
headers=headers)

0 commit comments

Comments
 (0)