Update client.py

should add force_proto else get proto = None and crash

hyper/http20/connection.py", line 354
assert proto in H2_NPN_PROTOCOLS or proto == H2C_PROTOCOL
This commit is contained in:
firkeuf
2016-05-13 14:08:55 +03:00
parent 50c5920592
commit 1c16d81e46
+2 -2
View File
@@ -14,12 +14,12 @@ class NotificationPriority(Enum):
class APNsClient(object):
def __init__(self, cert_file, use_sandbox=False, use_alternative_port=False):
def __init__(self, cert_file, use_sandbox=False, use_alternative_port=False, proto=None):
server = 'api.development.push.apple.com' if use_sandbox else 'api.push.apple.com'
port = 2197 if use_alternative_port else 443
ssl_context = init_context()
ssl_context.load_cert_chain(cert_file)
self.__connection = HTTP20Connection(server, port, ssl_context=ssl_context)
self.__connection = HTTP20Connection(server, port, ssl_context=ssl_context, force_proto=proto or 'h2')
def send_notification(self, token_hex, notification, priority=NotificationPriority.Immediate, topic=None):
json_payload = dumps(notification.dict(), ensure_ascii=False, separators=(',', ':')).encode('utf-8')