def test_can_use_head_method_long_hand(self): http = HTTP(b"httq.io:8080") http.head(b"/hello") http.response() assert http.status_code == 200 assert http.reason == "OK" assert http.content_type == "text/plain" assert not http.readable() assert http.content is None http.close()
def test_can_post_json_in_chunks(self): http = HTTP(b"httq.io:8080") http.post(b"/json?foo=bar") http.write(b"bum") http.write(b"ble") http.write(b"bee") http.write(b"") response = http.response() content = response.content assert content == {"method": "POST", "query": "foo=bar", "content": "bumblebee"}
def test_can_pipeline_multiple_get_requests(self): count = 3 turns = range(1, count + 1) http = HTTP(b"httq.io:8080") for i in turns: http.get("/echo?%d" % i) assert len(http._requests) == i for i in reversed(turns): assert len(http._requests) == i assert http.response().status_code == 200 http.readall() assert len(http._requests) == 0 http.close()
def test_can_post_json_in_chunks(self): http = HTTP(b"httq.io:8080") http.post(b"/json?foo=bar") http.write(b"bum") http.write(b"ble") http.write(b"bee") http.write(b"") response = http.response() content = response.content assert content == { "method": "POST", "query": "foo=bar", "content": "bumblebee" }
def test_request_headers(self): http = HTTP(b"httq.io:8080") http.get(b"/hello") http.response() assert http.request_headers == {b"Host": b"httq.io:8080"} http.close()
def test_request_url(self): http = HTTP(b"httq.io:8080") http.get(b"/hello") http.response() assert http.request_url == b"/hello" http.close()
def test_request_method(self): http = HTTP(b"httq.io:8080") http.get(b"/hello") http.response() assert http.request_method == b"GET" http.close()