MCPcopy Index your code
hub / github.com/pathwaycom/pathway / _request_scheme

Function _request_scheme

python/pathway/io/http/_server.py:307–329  ·  view source on GitHub ↗

Get request scheme taking into account the forwarded headers.

(request: web.Request)

Source from the content-addressed store, hash-verified

305
306
307def _request_scheme(request: web.Request):
308 """
309 Get request scheme taking into account the forwarded headers.
310 """
311 scheme_headers = [
312 "X-Forwarded-Proto",
313 "X-Scheme",
314 "X-Forwarded-Scheme",
315 ]
316 request_schemes = [
317 "http",
318 "https",
319 ]
320 for header in scheme_headers:
321 header_value = request.headers.get(header)
322 if header_value is None:
323 continue
324 header_value = header_value.lower()
325 if header_value in request_schemes:
326 return header_value
327
328 # fallback, doesn't work for forwarded scenarios
329 return request.scheme
330
331
332class PathwayServer(ABC):

Callers 2

__init__Method · 0.85
_schema_handlerMethod · 0.85

Calls 2

lowerMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected