MCPcopy Create free account
hub / github.com/pallets/quart / _create_request_from_scope

Method _create_request_from_scope

src/quart/asgi.py:74–104  ·  view source on GitHub ↗
(self, send: ASGISendCallable)

Source from the content-addressed store, hash-verified

72 return
73
74 def _create_request_from_scope(self, send: ASGISendCallable) -> Request:
75 headers = Headers()
76 headers["Remote-Addr"] = (self.scope.get("client") or ["<local>"])[0]
77 for name, value in self.scope["headers"]:
78 headers.add(name.decode("latin1").title(), value.decode("latin1"))
79 if self.scope["http_version"] < "1.1":
80 headers.setdefault("Host", self.app.config["SERVER_NAME"] or "")
81
82 path = self.scope["path"]
83 path = path if path[0] == "/" else urlparse(path).path
84 root_path = self.scope.get("root_path", "")
85 if root_path != "":
86 try:
87 path = path.split(root_path, 1)[1]
88 path = " " if path == "" else path
89 except IndexError:
90 path = " " # Invalid in paths, hence will result in 404
91
92 return self.app.request_class(
93 self.scope["method"],
94 self.scope["scheme"],
95 path,
96 self.scope["query_string"],
97 headers,
98 self.scope.get("root_path", ""),
99 self.scope["http_version"],
100 max_content_length=self.app.config["MAX_CONTENT_LENGTH"],
101 body_timeout=self.app.config["BODY_TIMEOUT"],
102 send_push_promise=partial(self._send_push_promise, send),
103 scope=self.scope,
104 )
105
106 async def handle_request(self, request: Request, send: ASGISendCallable) -> None:
107 try:

Calls 1

getMethod · 0.45