MCPcopy Index your code
hub / github.com/python/cpython / test_ipv6host_header

Method test_ipv6host_header

Lib/test/test_httplib.py:267–300  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

265 self.assertIn(b'\xa0NonbreakSpace: value', conn._buffer)
266
267 def test_ipv6host_header(self):
268 # Default host header on IPv6 transaction should be wrapped by [] if
269 # it is an IPv6 address
270 expected = b'GET /foo HTTP/1.1\r\nHost: [2001::]:81\r\n' \
271 b'Accept-Encoding: identity\r\n\r\n'
272 conn = client.HTTPConnection('[2001::]:81')
273 sock = FakeSocket('')
274 conn.sock = sock
275 conn.request('GET', '/foo')
276 self.assertStartsWith(sock.data, expected)
277
278 expected = b'GET /foo HTTP/1.1\r\nHost: [2001:102A::]\r\n' \
279 b'Accept-Encoding: identity\r\n\r\n'
280 conn = client.HTTPConnection('[2001:102A::]')
281 sock = FakeSocket('')
282 conn.sock = sock
283 conn.request('GET', '/foo')
284 self.assertStartsWith(sock.data, expected)
285
286 expected = b'GET /foo HTTP/1.1\r\nHost: [fe80::]\r\n' \
287 b'Accept-Encoding: identity\r\n\r\n'
288 conn = client.HTTPConnection('[fe80::%2]')
289 sock = FakeSocket('')
290 conn.sock = sock
291 conn.request('GET', '/foo')
292 self.assertStartsWith(sock.data, expected)
293
294 expected = b'GET /foo HTTP/1.1\r\nHost: [fe80::]:81\r\n' \
295 b'Accept-Encoding: identity\r\n\r\n'
296 conn = client.HTTPConnection('[fe80::%2]:81')
297 sock = FakeSocket('')
298 conn.sock = sock
299 conn.request('GET', '/foo')
300 self.assertStartsWith(sock.data, expected)
301
302 def test_malformed_headers_coped_with(self):
303 # Issue 19996

Callers

nothing calls this directly

Calls 3

requestMethod · 0.95
assertStartsWithMethod · 0.80
FakeSocketClass · 0.70

Tested by

no test coverage detected