(self)
| 1013 | |
| 1014 | @requires_subprocess() |
| 1015 | def test_http_body_pipe(self): |
| 1016 | # A file reading from a pipe. |
| 1017 | # A pipe cannot be seek'ed. There is no way to determine the |
| 1018 | # content length up front. Thus, do_request_() should fall |
| 1019 | # back to Transfer-encoding chunked. |
| 1020 | |
| 1021 | h = urllib.request.AbstractHTTPHandler() |
| 1022 | o = h.parent = MockOpener() |
| 1023 | |
| 1024 | cmd = [sys.executable, "-c", r"pass"] |
| 1025 | for headers in {}, {"Content-Length": 30}: |
| 1026 | with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc: |
| 1027 | req = Request("http://example.com/", proc.stdout, headers) |
| 1028 | newreq = h.do_request_(req) |
| 1029 | if not headers: |
| 1030 | self.assertEqual(newreq.get_header('Content-length'), None) |
| 1031 | self.assertEqual(newreq.get_header('Transfer-encoding'), |
| 1032 | 'chunked') |
| 1033 | else: |
| 1034 | self.assertEqual(int(newreq.get_header('Content-length')), |
| 1035 | 30) |
| 1036 | |
| 1037 | def test_http_body_iterable(self): |
| 1038 | # Generic iterable. There is no way to determine the content |
nothing calls this directly
no test coverage detected