(self)
| 1052 | 30) |
| 1053 | |
| 1054 | def test_http_body_iterable(self): |
| 1055 | # Generic iterable. There is no way to determine the content |
| 1056 | # length up front. Fall back to Transfer-encoding chunked. |
| 1057 | |
| 1058 | h = urllib.request.AbstractHTTPHandler() |
| 1059 | o = h.parent = MockOpener() |
| 1060 | |
| 1061 | def iterable_body(): |
| 1062 | yield b"one" |
| 1063 | |
| 1064 | for headers in {}, {"Content-Length": 11}: |
| 1065 | req = Request("http://example.com/", iterable_body(), headers) |
| 1066 | newreq = h.do_request_(req) |
| 1067 | if not headers: |
| 1068 | self.assertEqual(newreq.get_header('Content-length'), None) |
| 1069 | self.assertEqual(newreq.get_header('Transfer-encoding'), |
| 1070 | 'chunked') |
| 1071 | else: |
| 1072 | self.assertEqual(int(newreq.get_header('Content-length')), 11) |
| 1073 | |
| 1074 | def test_http_body_empty_seq(self): |
| 1075 | # Zero-length iterable body should be treated like any other iterable |
nothing calls this directly
no test coverage detected