MCPcopy Index your code
hub / github.com/python-websockets/websockets / process_subprotocol

Method process_subprotocol

src/websockets/server.py:393–415  ·  view source on GitHub ↗

Handle the Sec-WebSocket-Protocol HTTP request header. Args: headers: WebSocket handshake request headers. Returns: Subprotocol, if one was selected; this is also the value of the ``Sec-WebSocket-Protocol`` response header. Raises

(self, headers: Headers)

Source from the content-addressed store, hash-verified

391 return response_header_value, accepted_extensions
392
393 def process_subprotocol(self, headers: Headers) -> Subprotocol | None:
394 """
395 Handle the Sec-WebSocket-Protocol HTTP request header.
396
397 Args:
398 headers: WebSocket handshake request headers.
399
400 Returns:
401 Subprotocol, if one was selected; this is also the value of the
402 ``Sec-WebSocket-Protocol`` response header.
403
404 Raises:
405 InvalidHandshake: If the Sec-WebSocket-Subprotocol header is invalid.
406
407 """
408 subprotocols: Sequence[Subprotocol] = sum(
409 [
410 parse_subprotocol(header_value)
411 for header_value in headers.get_all("Sec-WebSocket-Protocol")
412 ],
413 [],
414 )
415 return self.select_subprotocol(subprotocols)
416
417 def select_subprotocol(
418 self,

Callers 1

process_requestMethod · 0.95

Calls 3

select_subprotocolMethod · 0.95
parse_subprotocolFunction · 0.85
get_allMethod · 0.80

Tested by

no test coverage detected