(self, scope: Scope, receive: Receive, send: Send)
| 222 | self.background = None |
| 223 | |
| 224 | async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: |
| 225 | if self.info is not None: |
| 226 | await send({"type": "http.response.debug", "info": self.info}) |
| 227 | await send( |
| 228 | { |
| 229 | "type": "http.response.start", |
| 230 | "status": self.status_code, |
| 231 | "headers": self.raw_headers, |
| 232 | } |
| 233 | ) |
| 234 | |
| 235 | should_close_body = True |
| 236 | async for chunk in self.body_iterator: |
| 237 | if isinstance(chunk, dict): |
| 238 | # We got an ASGI message which is not response body (eg: pathsend) |
| 239 | should_close_body = False |
| 240 | await send(chunk) |
| 241 | continue |
| 242 | await send({"type": "http.response.body", "body": chunk, "more_body": True}) |
| 243 | |
| 244 | if should_close_body: |
| 245 | await send({"type": "http.response.body", "body": b"", "more_body": False}) |
| 246 | |
| 247 | if self.background: |
| 248 | await self.background() |
nothing calls this directly
no test coverage detected