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(other_key)
def test_response_invalid_accept(self): with self.assert_invalid_response_headers() as headers: other_key = "1Eq4UDEFQYg3YspNgqxv5g==" headers['Sec-WebSocket-Accept'] = accept(other_key)
def test_accept(self): # Test vector from RFC 6455 key = "dGhlIHNhbXBsZSBub25jZQ==" acc = "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=" self.assertEqual(accept(key), acc)
def handshake(self, req, res): key = handshake.check_request(req.headers.__getitem__) res.headers['Transfer-Encoding'] = 'chunked' res.headers['Sec-Websocket-Accept'] = handshake.accept(key) return key