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

Method __call__

starlette/middleware/httpsredirect.py:10–19  ·  view source on GitHub ↗
(self, scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 4

replaceMethod · 0.95
URLClass · 0.90
RedirectResponseClass · 0.90
appMethod · 0.45

Tested by

no test coverage detected