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)
| 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 | """ |