Header values should be strictly ASCII but both UTF-8 and Latin-1 exist. Use UTF-8B to

cope with all.
This commit is contained in:
L. Kärkkäinen 2020-03-08 14:17:38 +02:00
parent cbfeb1c99c
commit 990ac52a1a

View File

@ -120,7 +120,8 @@ class Http:
raise PayloadTooLarge("Request header exceeds the size limit")
# Parse header content
try:
reqline, *raw_headers = buf[:pos].decode().split("\r\n")
raw_headers = buf[:pos].decode(errors="surrogateescape")
reqline, *raw_headers = raw_headers.split("\r\n")
method, self.url, protocol = reqline.split(" ")
if protocol == "HTTP/1.1":
self.keep_alive = True