Add header accessors (#2696)
This commit is contained in:
@@ -88,6 +88,12 @@ class Header(CIMultiDict):
|
||||
very similar to a regular dictionary.
|
||||
"""
|
||||
|
||||
def __getattr__(self, key: str) -> str:
|
||||
if key.startswith("_"):
|
||||
return self.__getattribute__(key)
|
||||
key = key.rstrip("_").replace("_", "-")
|
||||
return ",".join(self.getall(key, default=[]))
|
||||
|
||||
def get_all(self, key: str):
|
||||
"""
|
||||
Convenience method mapped to ``getall()``.
|
||||
|
||||
Reference in New Issue
Block a user