(self)
| 1030 | |
| 1031 | @requires_subprocess() |
| 1032 | def test_http_body_pipe(self): |
| 1033 | # A file reading from a pipe. |
| 1034 | # A pipe cannot be seek'ed. There is no way to determine the |
| 1035 | # content length up front. Thus, do_request_() should fall |
| 1036 | # back to Transfer-encoding chunked. |
| 1037 | |
| 1038 | h = urllib.request.AbstractHTTPHandler() |
| 1039 | o = h.parent = MockOpener() |
| 1040 | |
| 1041 | cmd = [sys.executable, "-c", r"pass"] |
| 1042 | for headers in {}, {"Content-Length": 30}: |
| 1043 | with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc: |
| 1044 | req = Request("http://example.com/", proc.stdout, headers) |
| 1045 | newreq = h.do_request_(req) |
| 1046 | if not headers: |
| 1047 | self.assertEqual(newreq.get_header('Content-length'), None) |
| 1048 | self.assertEqual(newreq.get_header('Transfer-encoding'), |
| 1049 | 'chunked') |
| 1050 | else: |
| 1051 | self.assertEqual(int(newreq.get_header('Content-length')), |
| 1052 | 30) |
| 1053 | |
| 1054 | def test_http_body_iterable(self): |
| 1055 | # Generic iterable. There is no way to determine the content |
nothing calls this directly
no test coverage detected