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)
| 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, |
no test coverage detected