def test_reset_pushed_streams_when_push_disabled(self): self.add_push_frame(1, 2, [(':method', 'GET'), (':path', '/'), (':authority', 'www.google.com'), (':scheme', 'https'), ('accept-encoding', 'gzip')]) self.add_headers_frame(1, [(':status', '200'), ('content-type', 'text/html')]) self.request() self.conn._enable_push = False self.conn.get_response() f = RstStreamFrame(2) f.error_code = 7 assert self.conn._sock.queue[-1] == f.serialize()
def test_cancel_push(self): self.add_push_frame(1, 2, [(':method', 'GET'), (':path', '/'), (':authority', 'www.google.com'), (':scheme', 'https'), ('accept-encoding', 'gzip')]) self.add_headers_frame(1, [(':status', '200'), ('content-type', 'text/html')]) self.request() self.conn.get_response() list(self.conn.get_pushes())[0].cancel() f = RstStreamFrame(2) f.error_code = 8 assert self.conn._sock.queue[-1] == f.serialize()
def socket_handler(listener): sock = listener.accept()[0] # We get two messages for the connection open and then a HEADERS # frame. receive_preamble(sock) sock.recv(65535) # Now, send two RST_STREAM frames. for _ in range(0, 2): f = RstStreamFrame(1) sock.send(f.serialize()) # Wait for the message from the main thread. recv_event.wait() sock.close()
def test_receive_unexpected_frame(self): # RST_STREAM frames are never defined on connections, so send one of # those. c = HTTP20Connection('www.google.com') f = RstStreamFrame(1) with pytest.raises(ValueError): c.receive_frame(f)