Headers are case-insensitive and multiple values are supported through the `add()` API.
| 10 | |
| 11 | |
| 12 | class 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 | |
| 49 | class RequestJSONDataDict(OrderedDict): |
no outgoing calls
no test coverage detected