|
12 | 12 | from .wsgi import parse_wsgi_environ, WSGIContext |
13 | 13 | from .asgi import parse_asgi_scope, ASGIContext |
14 | 14 | from .extract_route_params import extract_route_params |
| 15 | +from ..helpers.headers import Headers |
15 | 16 |
|
16 | 17 | UINPUT_SOURCES = ["body", "cookies", "query", "headers", "xml", "route_params"] |
17 | 18 | current_context = contextvars.ContextVar[Optional["Context"]]( |
@@ -49,7 +50,7 @@ def __init__(self, context_obj=None, body=None, req=None, source=None): |
49 | 50 | self.parsed_userinput = {} |
50 | 51 | self.xml = {} |
51 | 52 | self.outgoing_req_redirects = [] |
52 | | - self.headers: Dict[str, List[str]] = dict() |
| 53 | + self.headers: Headers = Headers() |
53 | 54 | self.query: Dict[str, List[str]] = dict() |
54 | 55 | self.cookies: Dict[str, List[str]] = dict() |
55 | 56 | self.executed_middleware = False |
@@ -140,10 +141,5 @@ def get_route_metadata(self): |
140 | 141 | "url": self.url, |
141 | 142 | } |
142 | 143 |
|
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 | | - |
148 | 144 | 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