(self, scope)
| 218 | super().__init__(*args, **kwargs) |
| 219 | |
| 220 | async def __call__(self, scope): |
| 221 | # Set up middleware if needed. We couldn't do this earlier, because |
| 222 | # settings weren't available. |
| 223 | if self._middleware_chain is None: |
| 224 | self.load_middleware(is_async=True) |
| 225 | # Extract body file from the scope, if provided. |
| 226 | if "_body_file" in scope: |
| 227 | body_file = scope.pop("_body_file") |
| 228 | else: |
| 229 | body_file = FakePayload("") |
| 230 | |
| 231 | request_started.disconnect(close_old_connections) |
| 232 | await request_started.asend(sender=self.__class__, scope=scope) |
| 233 | request_started.connect(close_old_connections) |
| 234 | # Wrap FakePayload body_file to allow large read() in test environment. |
| 235 | request = ASGIRequest(scope, LimitedStream(body_file, len(body_file))) |
| 236 | # Sneaky little hack so that we can easily get round |
| 237 | # CsrfViewMiddleware. This makes life easier, and is probably required |
| 238 | # for backwards compatibility with external tests against admin views. |
| 239 | request._dont_enforce_csrf_checks = not self.enforce_csrf_checks |
| 240 | # Request goes through middleware. |
| 241 | response = await self.get_response_async(request) |
| 242 | # Simulate behaviors of most web servers. |
| 243 | conditional_content_removal(request, response) |
| 244 | # Attach the originating ASGI request to the response so that it could |
| 245 | # be later retrieved. |
| 246 | response.asgi_request = request |
| 247 | # Emulate a server by calling the close method on completion. |
| 248 | if response.streaming: |
| 249 | if response.is_async: |
| 250 | response.streaming_content = aclosing_iterator_wrapper( |
| 251 | response.streaming_content, response.close |
| 252 | ) |
| 253 | else: |
| 254 | response.streaming_content = closing_iterator_wrapper( |
| 255 | response.streaming_content, response.close |
| 256 | ) |
| 257 | else: |
| 258 | request_finished.disconnect(close_old_connections) |
| 259 | # Will fire request_finished. |
| 260 | await sync_to_async(response.close, thread_sensitive=False)() |
| 261 | request_finished.connect(close_old_connections) |
| 262 | return response |
| 263 | |
| 264 | |
| 265 | def store_rendered_templates(store, signal, sender, template, context, **kwargs): |
nothing calls this directly
no test coverage detected