Skip to content

Commit

Permalink
Add tests for HEAD methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa committed Apr 28, 2015
1 parent 1bc3d20 commit 6973620
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/with_dummyserver/test_socketlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,33 @@ def test_httplib_headers_case_insensitive(self):
HEADERS = {'Content-Length': '0', 'Content-type': 'text/plain'}
r = pool.request('GET', '/')
self.assertEqual(HEADERS, dict(r.headers.items())) # to preserve case sensitivity


class TestHEAD(SocketDummyServerTestCase):
def test_chunked_head_response_does_not_hang(self):
handler = create_response_handler(
b'HTTP/1.1 200 OK\r\n'
b'Transfer-Encoding: chunked\r\n'
b'Content-type: text/plain\r\n'
b'\r\n'
)
self._start_server(handler)
pool = HTTPConnectionPool(self.host, self.port, retries=False)
r = pool.request('HEAD', '/', timeout=1, preload_content=False)

# stream will use the read_chunked method here.
self.assertEqual([], list(r.stream()))

def test_empty_head_response_does_not_hang(self):
handler = create_response_handler(
b'HTTP/1.1 200 OK\r\n'
b'Content-Length: 256\r\n'
b'Content-type: text/plain\r\n'
b'\r\n'
)
self._start_server(handler)
pool = HTTPConnectionPool(self.host, self.port, retries=False)
r = pool.request('HEAD', '/', timeout=1, preload_content=False)

# stream will use the read method here.
self.assertEqual([], list(r.stream()))

0 comments on commit 6973620

Please sign in to comment.