(self)
| 989 | self.assertFalse(newreq.has_header("Transfer-encoding")) |
| 990 | |
| 991 | def test_http_body_fileobj(self): |
| 992 | # A file object - chunked encoding is used |
| 993 | # unless Content Length is already set. |
| 994 | # (Note that there are some subtle differences to a regular |
| 995 | # file, that is why we are testing both cases.) |
| 996 | |
| 997 | h = urllib.request.AbstractHTTPHandler() |
| 998 | o = h.parent = MockOpener() |
| 999 | file_obj = io.BytesIO() |
| 1000 | |
| 1001 | req = Request("http://example.com/", file_obj, {}) |
| 1002 | newreq = h.do_request_(req) |
| 1003 | self.assertEqual(newreq.get_header('Transfer-encoding'), 'chunked') |
| 1004 | self.assertFalse(newreq.has_header('Content-length')) |
| 1005 | |
| 1006 | headers = {"Content-Length": 30} |
| 1007 | req = Request("http://example.com/", file_obj, headers) |
| 1008 | newreq = h.do_request_(req) |
| 1009 | self.assertEqual(int(newreq.get_header('Content-length')), 30) |
| 1010 | self.assertFalse(newreq.has_header("Transfer-encoding")) |
| 1011 | |
| 1012 | file_obj.close() |
| 1013 | |
| 1014 | @requires_subprocess() |
| 1015 | def test_http_body_pipe(self): |
nothing calls this directly
no test coverage detected