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