Test the connection is cleaned up when the response is closed
(self)
| 1837 | self.assertTrue(http_handler.has_auth_header) |
| 1838 | |
| 1839 | def test_http_closed(self): |
| 1840 | """Test the connection is cleaned up when the response is closed""" |
| 1841 | for (transfer, data) in ( |
| 1842 | ("Connection: close", b"data"), |
| 1843 | ("Transfer-Encoding: chunked", b"4\r\ndata\r\n0\r\n\r\n"), |
| 1844 | ("Content-Length: 4", b"data"), |
| 1845 | ): |
| 1846 | header = "HTTP/1.1 200 OK\r\n{}\r\n\r\n".format(transfer) |
| 1847 | conn = test_urllib.fakehttp(header.encode() + data) |
| 1848 | handler = urllib.request.AbstractHTTPHandler() |
| 1849 | req = Request("http://dummy/") |
| 1850 | req.timeout = None |
| 1851 | with handler.do_open(conn, req) as resp: |
| 1852 | resp.read() |
| 1853 | self.assertTrue(conn.fakesock.closed, |
| 1854 | "Connection not closed with {!r}".format(transfer)) |
| 1855 | |
| 1856 | def test_invalid_closed(self): |
| 1857 | """Test the connection is cleaned up after an invalid response""" |