Make an outgoing request to the Django WSGI application.
(self, request, *args, **kwargs)
| 74 | return self.factory.generic(method, url, **kwargs).environ |
| 75 | |
| 76 | def send(self, request, *args, **kwargs): |
| 77 | """ |
| 78 | Make an outgoing request to the Django WSGI application. |
| 79 | """ |
| 80 | raw_kwargs = {} |
| 81 | |
| 82 | def start_response(wsgi_status, wsgi_headers, exc_info=None): |
| 83 | status, _, reason = wsgi_status.partition(' ') |
| 84 | raw_kwargs['status'] = int(status) |
| 85 | raw_kwargs['reason'] = reason |
| 86 | raw_kwargs['headers'] = wsgi_headers |
| 87 | raw_kwargs['version'] = 11 |
| 88 | raw_kwargs['preload_content'] = False |
| 89 | raw_kwargs['original_response'] = MockOriginalResponse(wsgi_headers) |
| 90 | |
| 91 | # Make the outgoing request via WSGI. |
| 92 | environ = self.get_environ(request) |
| 93 | wsgi_response = self.app(environ, start_response) |
| 94 | |
| 95 | # Build the underlying urllib3.HTTPResponse |
| 96 | raw_kwargs['body'] = io.BytesIO(b''.join(wsgi_response)) |
| 97 | raw = requests.packages.urllib3.HTTPResponse(**raw_kwargs) |
| 98 | |
| 99 | # Build the requests.Response |
| 100 | return self.build_response(request, raw) |
| 101 | |
| 102 | def close(self): |
| 103 | pass |
no test coverage detected