コード例 #1
0
ファイル: test.py プロジェクト: pombredanne/httq
 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()
コード例 #2
0
 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()
コード例 #3
0
ファイル: test.py プロジェクト: pombredanne/httq
 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"}
コード例 #4
0
ファイル: test.py プロジェクト: pombredanne/httq
 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()
コード例 #5
0
 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()
コード例 #6
0
 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"
     }
コード例 #7
0
ファイル: test.py プロジェクト: pombredanne/httq
 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()
コード例 #8
0
ファイル: test.py プロジェクト: pombredanne/httq
 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()
コード例 #9
0
ファイル: test.py プロジェクト: pombredanne/httq
 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()
コード例 #10
0
 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()
コード例 #11
0
 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()
コード例 #12
0
 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()