Skip to content

Commit 6f30d95

Browse files
committed
context: use new headers helper class
1 parent 8b6e0c1 commit 6f30d95

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

aikido_zen/context/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .wsgi import parse_wsgi_environ, WSGIContext
1313
from .asgi import parse_asgi_scope, ASGIContext
1414
from .extract_route_params import extract_route_params
15+
from ..helpers.headers import Headers
1516

1617
UINPUT_SOURCES = ["body", "cookies", "query", "headers", "xml", "route_params"]
1718
current_context = contextvars.ContextVar[Optional["Context"]](
@@ -49,7 +50,7 @@ def __init__(self, context_obj=None, body=None, req=None, source=None):
4950
self.parsed_userinput = {}
5051
self.xml = {}
5152
self.outgoing_req_redirects = []
52-
self.headers: Dict[str, List[str]] = dict()
53+
self.headers: Headers = Headers()
5354
self.query: Dict[str, List[str]] = dict()
5455
self.cookies: Dict[str, List[str]] = dict()
5556
self.executed_middleware = False
@@ -140,10 +141,5 @@ def get_route_metadata(self):
140141
"url": self.url,
141142
}
142143

143-
def get_header(self, key: str) -> Optional[str]:
144-
if key not in self.headers or not self.headers[key]:
145-
return None
146-
return self.headers[key][-1]
147-
148144
def get_user_agent(self) -> Optional[str]:
149-
return self.get_header("USER_AGENT")
145+
return self.headers.get_header("USER_AGENT")

0 commit comments

Comments
 (0)