(self)
| 1035 | 30) |
| 1036 | |
| 1037 | def test_http_body_iterable(self): |
| 1038 | # Generic iterable. There is no way to determine the content |
| 1039 | # length up front. Fall back to Transfer-encoding chunked. |
| 1040 | |
| 1041 | h = urllib.request.AbstractHTTPHandler() |
| 1042 | o = h.parent = MockOpener() |
| 1043 | |
| 1044 | def iterable_body(): |
| 1045 | yield b"one" |
| 1046 | |
| 1047 | for headers in {}, {"Content-Length": 11}: |
| 1048 | req = Request("http://example.com/", iterable_body(), headers) |
| 1049 | newreq = h.do_request_(req) |
| 1050 | if not headers: |
| 1051 | self.assertEqual(newreq.get_header('Content-length'), None) |
| 1052 | self.assertEqual(newreq.get_header('Transfer-encoding'), |
| 1053 | 'chunked') |
| 1054 | else: |
| 1055 | self.assertEqual(int(newreq.get_header('Content-length')), 11) |
| 1056 | |
| 1057 | def test_http_body_empty_seq(self): |
| 1058 | # Zero-length iterable body should be treated like any other iterable |
nothing calls this directly
no test coverage detected