MCPcopy
hub / github.com/pallets/werkzeug / _add_cookies_to_wsgi

Method _add_cookies_to_wsgi

src/werkzeug/test.py:935–957  ·  view source on GitHub ↗

If cookies are enabled, set the ``Cookie`` header in the environ to the cookies that are applicable to the request host and path. :meta private: .. versionadded:: 2.3

(self, environ: WSGIEnvironment)

Source from the content-addressed store, hash-verified

933 self._cookies.pop((domain, path, key), None)
934
935 def _add_cookies_to_wsgi(self, environ: WSGIEnvironment) -> None:
936 """If cookies are enabled, set the ``Cookie`` header in the environ to the
937 cookies that are applicable to the request host and path.
938
939 :meta private:
940
941 .. versionadded:: 2.3
942 """
943 if self._cookies is None:
944 return
945
946 url = urlsplit(get_current_url(environ))
947 server_name = url.hostname or "localhost"
948 value = "; ".join(
949 c._to_request_header()
950 for c in self._cookies.values()
951 if c._matches_request(server_name, url.path)
952 )
953
954 if value:
955 environ["HTTP_COOKIE"] = value
956 else:
957 environ.pop("HTTP_COOKIE", None)
958
959 def _update_cookies_from_response(
960 self, server_name: str, path: str, headers: list[str]

Callers 1

run_wsgi_appMethod · 0.95

Calls 5

_to_request_headerMethod · 0.80
_matches_requestMethod · 0.80
get_current_urlFunction · 0.70
valuesMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected