MCPcopy Index your code
hub / github.com/encode/django-rest-framework / send

Method send

rest_framework/test.py:76–100  ·  view source on GitHub ↗

Make an outgoing request to the Django WSGI application.

(self, request, *args, **kwargs)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

get_environMethod · 0.95

Tested by

no test coverage detected