MCPcopy
hub / github.com/httpie/cli / HTTPHeadersDict

Class HTTPHeadersDict

httpie/cli/dicts.py:12–46  ·  view source on GitHub ↗

Headers are case-insensitive and multiple values are supported through the `add()` API.

Source from the content-addressed store, hash-verified

10
11
12class HTTPHeadersDict(CIMultiDict, BaseMultiDict):
13 """
14 Headers are case-insensitive and multiple values are supported
15 through the `add()` API.
16 """
17
18 def add(self, key, value):
19 """
20 Add or update a new header.
21
22 If the given `value` is `None`, then all the previous
23 values will be overwritten and the value will be set
24 to `None`.
25 """
26 if value is None:
27 self[key] = value
28 return None
29
30 # If the previous value for the given header is `None`
31 # then discard it since we are explicitly giving a new
32 # value for it.
33 if key in self and self.getone(key) is None:
34 self.popone(key)
35
36 super().add(key, value)
37
38 def remove_item(self, key, value):
39 """
40 Remove a (key, value) pair from the dict.
41 """
42 existing_values = self.popall(key)
43 existing_values.remove(value)
44
45 for value in existing_values:
46 self.add(key, value)
47
48
49class RequestJSONDataDict(OrderedDict):

Callers 8

build_responseMethod · 0.90
finalize_headersFunction · 0.85
make_default_headersFunction · 0.85
__init__Method · 0.85
_compute_new_headersMethod · 0.85
write_raw_dataFunction · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected