MCPcopy
hub / github.com/encode/starlette / __call__

Method __call__

starlette/middleware/base.py:220–244  ·  view source on GitHub ↗
(self, scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 2

backgroundMethod · 0.80
sendFunction · 0.50

Tested by

no test coverage detected