Example #1
0
def test_http_unsupported_method(tcp_client):
    tcp_client.sendall("PUT\r\n\r\n".encode())
    assert tcp_client.recv(1024) == b''
Example #2
0
def test_http_get_incomplete_request_path(tcp_client):
    tcp_client.sendall("GET /asdf\r\n\r\n".encode())
    assert tcp_client.recv(1024) == b''
Example #3
0
def test_http_incomplete_request(tcp_client):
    tcp_client.sendall("G\r\n\r\n".encode())
    assert tcp_client.recv(1024) == b''
Example #4
0
def test_http_get_illegal_path_404(tcp_client):
    tcp_client.sendall(
        "GET /../.. HTTP/1.1\r\nHost: localhost\r\n\r\n".encode())
    assert tcp_client.recv(1024).decode().startswith("HTTP/1.1 403")
Example #5
0
def test_echo(tcp_client):
    data = " Hello how are you?\n"
    tcp_client.sendall(data.encode())
    assert tcp_client.recv(1024).decode() == data
Example #6
0
def test_multi_echo(tcp_client):
    for i in range(1000):
        data = " Hello how are you?\n"
        tcp_client.sendall(data.encode())
        assert tcp_client.recv(1024).decode() == data