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

Method to_header

src/werkzeug/datastructures/auth.py:293–314  ·  view source on GitHub ↗

Produce a ``WWW-Authenticate`` header value representing this data.

(self)

Source from the content-addressed store, hash-verified

291 return cls(scheme, None, rest)
292
293 def to_header(self) -> str:
294 """Produce a ``WWW-Authenticate`` header value representing this data."""
295 if self.token is not None:
296 return f"{self.type.title()} {self.token}"
297
298 if not self.parameters:
299 return self.type.title()
300
301 if self.type == "digest":
302 items = []
303
304 for key, value in self.parameters.items():
305 if key in {"realm", "domain", "nonce", "opaque", "qop"}:
306 value = quote_header_value(value, allow_token=False)
307 else:
308 value = quote_header_value(value)
309
310 items.append(f"{key}={value}")
311
312 return f"Digest {', '.join(items)}"
313
314 return f"{self.type.title()} {dump_header(self.parameters)}"
315
316 def __str__(self) -> str:
317 return self.to_header()

Callers 3

__str__Method · 0.95
__repr__Method · 0.95

Calls 5

quote_header_valueFunction · 0.85
dump_headerFunction · 0.85
titleMethod · 0.80
appendMethod · 0.80
itemsMethod · 0.45

Tested by 1