Skip to content

Commit

Permalink
Add test for spurious header warnings; urllib3#1438
Browse files Browse the repository at this point in the history
  • Loading branch information
timb07 committed Sep 12, 2018
1 parent 1821e73 commit 0796637
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/with_dummyserver/test_socketlevel.py
Expand Up @@ -1328,6 +1328,35 @@ def test_header_without_colon_or_value(self):
])


@pytest.mark.skipif(
issubclass(httplib.HTTPMessage, MimeToolMessage),
reason='Header parsing errors not available'
)
class TestOkayHeaders(SocketDummyServerTestCase):

def _test_okay_header_parsing(self, header):
self.start_response_handler((
b'HTTP/1.1 200 OK\r\n'
b'Content-Length: 0\r\n'
) + header + b'\r\n\r\n'
)

pool = HTTPConnectionPool(self.host, self.port, retries=False)
self.addCleanup(pool.close)

with LogRecorder() as logs:
pool.request('GET', '/')

for record in logs:
assert 'Failed to parse headers' not in record.msg

def test_header_text_plain(self):
self._test_okay_header_parsing(b'Content-type: text/plain')

def test_header_message_rfc822(self):
self._test_okay_header_parsing(b'Content-type: message/rfc822')


class TestHEAD(SocketDummyServerTestCase):
def test_chunked_head_response_does_not_hang(self):
self.start_response_handler(
Expand Down

0 comments on commit 0796637

Please sign in to comment.