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

Method base_url

starlette/requests.py:116–130  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

114
115 @property
116 def base_url(self) -> URL:
117 if not hasattr(self, "_base_url"):
118 base_url_scope = dict(self.scope)
119 # This is used by request.url_for, it might be used inside a Mount which
120 # would have its own child scope with its own root_path, but the base URL
121 # for url_for should still be the top level app root path.
122 app_root_path = base_url_scope.get("app_root_path", base_url_scope.get("root_path", ""))
123 path = app_root_path
124 if not path.endswith("/"):
125 path += "/"
126 base_url_scope["path"] = path
127 base_url_scope["query_string"] = b""
128 base_url_scope["root_path"] = app_root_path
129 self._base_url = URL(scope=base_url_scope)
130 return self._base_url
131
132 @property
133 def headers(self) -> Headers:

Callers

nothing calls this directly

Calls 2

URLClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected