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_read_some_then_all_the_rest(self): http = HTTP(b"httq.io:8080") http.get(b"/hello").response() assert http.readable() assert http.status_code == 200 assert http.reason == "OK" assert http.content_type == "text/plain" assert http.readable() assert http.read(5) == b"hello" assert http.readable() assert http.readall() == b", world" assert not http.readable() assert http.read(5) == b"" assert http.content == "hello, world" http.close()