def make_accept_response(self, client): request = client.connect() return Response( status_code=101, reason_phrase="Switching Protocols", headers=Headers({ "Upgrade": "websocket", "Connection": "Upgrade", "Sec-WebSocket-Accept": accept_key(request.headers["Sec-WebSocket-Key"]), }), )
def test_response_invalid_accept(self): with self.assertInvalidResponseHeaders(InvalidHeaderValue) as headers: del headers["Sec-WebSocket-Accept"] other_key = "1Eq4UDEFQYg3YspNgqxv5g==" headers["Sec-WebSocket-Accept"] = accept_key(other_key)
def test_accept_key(self): self.assertEqual(accept_key(KEY), ACCEPT)