Exemplo n.º 1
0
 def test_attributes(self):
     request = http.HTTPRequest()
     assert request.version == "HTTP/1.1"
     assert request.headers == {}
     assert request.body == b""
     assert request.text is None
     assert request.files is None
     assert request.boundary == "--------BOUNDARY--------"
     assert request.form is None
     assert request.rawform is None
     assert request.json is None
     assert request.xml is None
Exemplo n.º 2
0
    async def test_continue(self):
        async def handler(client, request):
            response = http.HTTPResponse(200)
            response.body = request.body
            return response

        async with http.serve(handler, "localhost", 12345):
            request = http.HTTPRequest()
            request.continue_threshold = 64
            request.body = b"a" * 80

            response = await http.request("localhost:12345", request)
            assert response.body == b"a" * 80
Exemplo n.º 3
0
    async def test_request(self):
        async def handler(client, request):
            assert request.path == "/path"
            response = http.HTTPResponse(200)
            response.body = request.body
            return response

        async with http.serve(handler, "localhost", 12345):
            request = http.HTTPRequest()
            request.body = b"test"
            request.path = "/path"

            response = await http.request("localhost:12345", request)
            assert response.body == b"test"
Exemplo n.º 4
0
 def test_encode_body(self):
     request = http.HTTPRequest()
     assert request.encode_body() == b""
Exemplo n.º 5
0
 def test_encode_headers(self):
     request = http.HTTPRequest()
     assert request.encode_headers() == b"GET / HTTP/1.1\r\n\r\n"
Exemplo n.º 6
0
 def test_attributes(self):
     request = http.HTTPRequest()
     assert request.method == "GET"
     assert request.path == "/"
     assert request.params is None
     assert request.continue_threshold == 1024