File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33from base64 import b64encode
4- from collections import defaultdict
54from collections .abc import Mapping , MutableMapping , Sequence
65from io import BytesIO
76from typing import Any , Union , overload
@@ -51,17 +50,21 @@ def headers_raw_to_dict(headers_raw: bytes | None) -> HeadersDictOutput | None:
5150 return {}
5251
5352 headers = iter (BytesIO (headers_raw ).readline , b"" )
54- result_dict = defaultdict ( list )
53+ result_dict = {}
5554
5655 for header in headers :
57- parts = header .split (b":" , 1 )
58- if len ( parts ) != 2 :
56+ key , sep , value = header .partition (b":" )
57+ if not sep :
5958 continue
6059
61- key , value = map (bytes .strip , parts )
62- result_dict [key ].append (value )
60+ key , value = key .strip (), value .strip ()
6361
64- return dict (result_dict )
62+ if key in result_dict :
63+ result_dict [key ].append (value )
64+ else :
65+ result_dict [key ] = [value ]
66+
67+ return result_dict
6568
6669
6770@overload
You can’t perform that action at this time.
0 commit comments