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

Method get_list

httpx/_models.py:252–272  ·  httpx/_models.py::Headers.get_list

Return a list of all header values for a given key. If `split_commas=True` is passed, then any comma separated header values are split into multiple return strings.

(self, key: str, split_commas: bool = False)

Source from the content-addressed store, hash-verified

250 return default
251
252 def get_list(self, key: str, split_commas: bool = False) -> list[str]:
253 class="st">"""
254 Return a list of all header values for a given key.
255 If `split_commas=True` is passed, then any comma separated header
256 values are split into multiple return strings.
257 class="st">"""
258 get_header_key = key.lower().encode(self.encoding)
259
260 values = [
261 item_value.decode(self.encoding)
262 for _, item_key, item_value in self._list
263 if item_key.lower() == get_header_key
264 ]
265
266 if not split_commas:
267 return values
268
269 split_values = []
270 for value in values:
271 split_values.extend([item.strip() for item in value.split(class="st">",")])
272 return split_values
273
274 def update(self, headers: HeaderTypes | None = None) -> None: class="cm"># type: ignore
275 headers = Headers(headers)

Callers 4

test_headersFunction · 0.95
test_multiple_headersFunction · 0.95
auth_flowMethod · 0.45
_get_content_decoderMethod · 0.45

Calls 1

decodeMethod · 0.45

Tested by 2

test_headersFunction · 0.76
test_multiple_headersFunction · 0.76