Computes the value for the Sec-WebSocket-Accept header, given the value for Sec-WebSocket-Key.
(key: Union[str, bytes])
| 885 | |
| 886 | @staticmethod |
| 887 | def compute_accept_value(key: Union[str, bytes]) -> str: |
| 888 | """Computes the value for the Sec-WebSocket-Accept header, |
| 889 | given the value for Sec-WebSocket-Key. |
| 890 | """ |
| 891 | sha1 = hashlib.sha1() |
| 892 | sha1.update(utf8(key)) |
| 893 | sha1.update(b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11") # Magic value |
| 894 | return native_str(base64.b64encode(sha1.digest())) |
| 895 | |
| 896 | def _challenge_response(self, handler: WebSocketHandler) -> str: |
| 897 | return WebSocketProtocol13.compute_accept_value( |
no test coverage detected