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

Method _from_response_header

src/werkzeug/test.py:1431–1454  ·  view source on GitHub ↗
(cls, server_name: str, path: str, header: str)

Source from the content-addressed store, hash-verified

1429
1430 @classmethod
1431 def _from_response_header(cls, server_name: str, path: str, header: str) -> te.Self:
1432 header, _, parameters_str = header.partition(";")
1433 key, _, value = header.partition("=")
1434 decoded_key, decoded_value = next(parse_cookie(header).items()) # type: ignore[call-overload]
1435 params = {}
1436
1437 for item in parameters_str.split(";"):
1438 k, sep, v = item.partition("=")
1439 params[k.strip().lower()] = v.strip() if sep else None
1440
1441 return cls(
1442 key=key.strip(),
1443 value=value.strip(),
1444 decoded_key=decoded_key,
1445 decoded_value=decoded_value,
1446 expires=parse_date(params.get("expires")),
1447 max_age=int(params["max-age"] or 0) if "max-age" in params else None,
1448 domain=params.get("domain") or server_name,
1449 origin_only="domain" not in params,
1450 path=params.get("path") or path.rpartition("/")[0] or "/",
1451 secure="secure" in params,
1452 http_only="httponly" in params,
1453 same_site=params.get("samesite"),
1454 )
1455
1456 @property
1457 def _storage_key(self) -> tuple[str, str, str]:

Callers 2

set_cookieMethod · 0.80

Calls 4

parse_dateFunction · 0.85
parse_cookieFunction · 0.70
itemsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected