aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
Diffstat (limited to 'netlib')
-rw-r--r--netlib/http2/protocol.py6
-rw-r--r--netlib/tcp.py19
2 files changed, 15 insertions, 10 deletions
diff --git a/netlib/http2/protocol.py b/netlib/http2/protocol.py
index 459c2293..feac220c 100644
--- a/netlib/http2/protocol.py
+++ b/netlib/http2/protocol.py
@@ -61,7 +61,6 @@ class HTTP2Protocol(object):
assert settings_ack_frame.flags & frame.Frame.FLAG_ACK
assert len(settings_ack_frame.settings) == 0
-
def next_stream_id(self):
if self.current_stream_id is None:
self.current_stream_id = 1
@@ -89,7 +88,10 @@ class HTTP2Protocol(object):
self.http2_settings[setting] = value
- self.send_frame(frame.SettingsFrame(state=self, flags=frame.Frame.FLAG_ACK))
+ self.send_frame(
+ frame.SettingsFrame(
+ state=self,
+ flags=frame.Frame.FLAG_ACK))
def _create_headers(self, headers, stream_id, end_stream=True):
# TODO: implement max frame size checks and sending in chunks
diff --git a/netlib/tcp.py b/netlib/tcp.py
index f6179faa..fc2ce115 100644
--- a/netlib/tcp.py
+++ b/netlib/tcp.py
@@ -6,6 +6,8 @@ import sys
import threading
import time
import traceback
+
+import OpenSSL
from OpenSSL import SSL
from . import certutils
@@ -401,16 +403,17 @@ class _Connection(object):
if log_ssl_key:
context.set_info_callback(log_ssl_key)
- # advertise application layer protocols
- if alpn_protos is not None:
- context.set_alpn_protos(alpn_protos)
+ if OpenSSL._util.lib.Cryptography_HAS_ALPN:
+ # advertise application layer protocols
+ if alpn_protos is not None:
+ context.set_alpn_protos(alpn_protos)
- # select application layer protocol
- if alpn_select is not None:
- def alpn_select_f(conn, options):
- return bytes(alpn_select)
+ # select application layer protocol
+ if alpn_select is not None:
+ def alpn_select_f(conn, options):
+ return bytes(alpn_select)
- context.set_alpn_select_callback(alpn_select_f)
+ context.set_alpn_select_callback(alpn_select_f)
return context