7070)
7171
7272
73- def _normalize_wsgi_headers (environ : WSGIEnvironment ) -> dict :
74- """Extract and normalize HTTP headers from WSGI environment."""
75- headers = {}
73+ def _process_headers (environ : WSGIEnvironment ) -> Headers :
74+ headers = Headers ()
7675 if "CONTENT_TYPE" in environ :
77- headers ["content-type" ] = environ ["CONTENT_TYPE" ]. lower ()
76+ headers ["content-type" ] = environ ["CONTENT_TYPE" ]
7877 if "CONTENT_LENGTH" in environ :
79- headers ["content-length" ] = environ ["CONTENT_LENGTH" ]. lower ()
78+ headers ["content-length" ] = environ ["CONTENT_LENGTH" ]
8079
8180 for key , value in environ .items ():
8281 if key .startswith ("HTTP_" ):
@@ -85,17 +84,6 @@ def _normalize_wsgi_headers(environ: WSGIEnvironment) -> dict:
8584 return headers
8685
8786
88- def _process_headers (headers : dict ) -> Headers :
89- result = Headers ()
90- for key , value in headers .items ():
91- if isinstance (value , list | tuple ):
92- for v in value :
93- result .add (key , v )
94- else :
95- result .add (key , str (value ))
96- return result
97-
98-
9987def prepare_response_headers (
10088 base_headers : dict [str , list [str ]], selected_encoding : str
10189) -> dict [str , list [str ]]:
@@ -220,7 +208,7 @@ def __call__(
220208
221209 http_method = environ ["REQUEST_METHOD" ]
222210 http_scheme = environ .get ("wsgi.url_scheme" , "http" )
223- headers = _process_headers (_normalize_wsgi_headers ( environ ) )
211+ headers = _process_headers (environ )
224212 if ra := environ .get ("REMOTE_ADDR" ):
225213 port = environ .get ("REMOTE_PORT" , "0" )
226214 client_address = f"{ ra } :{ port } "
0 commit comments