MCPcopy
hub / github.com/encode/httpx / __getitem__

Method __getitem__

httpx/_models.py:284–302  ·  view source on GitHub ↗

Return a single header value. If there are multiple headers with the same key, then we concatenate them with commas. See: https://tools.ietf.org/html/rfc7230#section-3.2.2

(self, key: str)

Source from the content-addressed store, hash-verified

282 return Headers(self, encoding=self.encoding)
283
284 def __getitem__(self, key: str) -> str:
285 """
286 Return a single header value.
287
288 If there are multiple headers with the same key, then we concatenate
289 them with commas. See: https://tools.ietf.org/html/rfc7230#section-3.2.2
290 """
291 normalized_key = key.lower().encode(self.encoding)
292
293 items = [
294 header_value.decode(self.encoding)
295 for _, header_key, header_value in self._list
296 if header_key == normalized_key
297 ]
298
299 if items:
300 return ", ".join(items)
301
302 raise KeyError(key)
303
304 def __setitem__(self, key: str, value: str) -> None:
305 """

Callers

nothing calls this directly

Calls 2

joinMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected