(self, scope: Scope, receive: Receive, send: Send)
| 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: |
nothing calls this directly
no test coverage detected