Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit ae56862

Browse files
committed
Minor refactor for force_proto
1 parent b093cc7 commit ae56862

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

hyper/tls.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,18 @@ def wrap_socket(sock, server_hostname, ssl_context=None, force_proto=None):
4949
except AttributeError:
5050
ssl.verify_hostname(ssl_sock, server_hostname) # pyopenssl
5151

52-
if force_proto != None:
53-
proto = force_proto
54-
else:
55-
proto = None
56-
57-
# ALPN is newer, so we prefer it over NPN. The odds of us getting
58-
# different answers is pretty low, but let's be sure.
59-
with ignore_missing():
52+
# Allow for the protocol to be forced externally.
53+
proto = force_proto
54+
55+
# ALPN is newer, so we prefer it over NPN. The odds of us getting
56+
# different answers is pretty low, but let's be sure.
57+
with ignore_missing():
58+
if proto is None:
6059
proto = ssl_sock.selected_alpn_protocol()
6160

62-
with ignore_missing():
63-
if proto is None:
64-
proto = ssl_sock.selected_npn_protocol()
61+
with ignore_missing():
62+
if proto is None:
63+
proto = ssl_sock.selected_npn_protocol()
6564

6665
return (ssl_sock, proto)
6766

0 commit comments

Comments
 (0)