From ac32991162da391dc2f16b020e678fb3bf36c126 Mon Sep 17 00:00:00 2001 From: Oleg Gashev Date: Sat, 6 Nov 2021 13:07:32 -0400 Subject: [PATCH] python3: add condition to check is NPN extension is enable --- python/nghttp2.pyx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/nghttp2.pyx b/python/nghttp2.pyx index c374d786..b192283d 100644 --- a/python/nghttp2.pyx +++ b/python/nghttp2.pyx @@ -310,9 +310,12 @@ def negotiated_protocol(ssl_obj): def set_application_protocol(ssl_ctx): app_protos = [cnghttp2.NGHTTP2_PROTO_VERSION_ID.decode('utf-8')] - ssl_ctx.set_npn_protocols(app_protos) - if tls.HAS_ALPN: + if tls.HAS_NPN: + ssl_ctx.set_npn_protocols(app_protos) + elif tls.HAS_ALPN: ssl_ctx.set_alpn_protocols(app_protos) + else: + raise Exception('nghttp2_set_application_protocol: NPM or ALPN extension required') cdef _get_stream_user_data(cnghttp2.nghttp2_session *session, int32_t stream_id):