Closed cdeler closed 3 years ago
Hello,
I have a question about curio.io.Socket
curio.io.Socket
Once it's created, let's say using curio.open_connection, I want to check selected alpn protocol.
curio.open_connection
I'm doing that using the following code snippet:
def get_selected_alpn_proto(socket: curio.io.Socket) -> str: ident = "http/1.1" if hasattr(socket, "_socket"): raw_socket = socket._socket if isinstance(raw_socket, ssl.SSLSocket): ident = raw_socket.selected_alpn_protocol() return "HTTP/2" if ident == "h2" else "HTTP/1.1"
But it's a bit uncomfortable for me to rely on the protected API (if hasattr(socket, "_socket"))
if hasattr(socket, "_socket")
Do you know if there another way to check the selected alpn protocol once socket has been created?
Curio sockets delegate methods via __getattr__(). It might be possible to call sock.selected_alpn_protocol() directly on the Curio socket.
__getattr__()
sock.selected_alpn_protocol()
Hello,
I have a question about
curio.io.Socket
Once it's created, let's say using
curio.open_connection
, I want to check selected alpn protocol.I'm doing that using the following code snippet:
But it's a bit uncomfortable for me to rely on the protected API (
if hasattr(socket, "_socket")
)Do you know if there another way to check the selected alpn protocol once socket has been created?