(self, scope: Scope, receive: Receive, send: Send)
| 8 | self.app = app |
| 9 | |
| 10 | async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: |
| 11 | if scope["type"] in ("http", "websocket") and scope["scheme"] in ("http", "ws"): |
| 12 | url = URL(scope=scope) |
| 13 | redirect_scheme = {"http": "https", "ws": "wss"}[url.scheme] |
| 14 | netloc = url.hostname if url.port in (80, 443) else url.netloc |
| 15 | url = url.replace(scheme=redirect_scheme, netloc=netloc) |
| 16 | response = RedirectResponse(url, status_code=307) |
| 17 | await response(scope, receive, send) |
| 18 | else: |
| 19 | await self.app(scope, receive, send) |
nothing calls this directly
no test coverage detected