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

Method __call__

starlette/middleware/cors.py:78–96  ·  view source on GitHub ↗
(self, scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

76 self.preflight_headers = preflight_headers
77
78 async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
79 if scope["type"] != "http": # pragma: no cover
80 await self.app(scope, receive, send)
81 return
82
83 method = scope["method"]
84 headers = Headers(scope=scope)
85 origin = headers.get("origin")
86
87 if origin is None:
88 await self.app(scope, receive, send)
89 return
90
91 if method == "OPTIONS" and "access-control-request-method" in headers:
92 response = self.preflight_response(request_headers=headers)
93 await response(scope, receive, send)
94 return
95
96 await self.simple_response(scope, receive, send, request_headers=headers)
97
98 def is_allowed_origin(self, origin: str) -> bool:
99 if self.allow_all_origins:

Callers

nothing calls this directly

Calls 5

preflight_responseMethod · 0.95
simple_responseMethod · 0.95
HeadersClass · 0.90
appMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected