修复图片
This commit is contained in:
@@ -99,7 +99,7 @@ def modify_request_headers(request_data):
|
||||
def handle_request(request_data):
|
||||
"""Handle a single request from device B - completely independent thread"""
|
||||
if isinstance(request_data, bytes):
|
||||
request_data_str = request_data.decode('utf-8')
|
||||
request_data_str = request_data.decode('utf-8', errors='replace')
|
||||
else:
|
||||
request_data_str = request_data
|
||||
|
||||
@@ -136,7 +136,7 @@ def handle_request(request_data):
|
||||
|
||||
if b"\r\n\r\n" in response and content_length == 0 and not is_chunked:
|
||||
headers_end = response.find(b"\r\n\r\n")
|
||||
headers = response[:headers_end].decode('utf-8')
|
||||
headers = response[:headers_end].decode('utf-8', errors='replace')
|
||||
|
||||
for line in headers.split("\r\n"):
|
||||
if line.lower().startswith("content-length:"):
|
||||
@@ -163,7 +163,7 @@ def handle_request(request_data):
|
||||
status_code = "500"
|
||||
if b"\r\n\r\n" in response:
|
||||
headers_end = response.find(b"\r\n\r\n")
|
||||
headers = response[:headers_end].decode('utf-8')
|
||||
headers = response[:headers_end].decode('utf-8', errors='replace')
|
||||
for line in headers.split("\r\n"):
|
||||
if line.startswith("HTTP/"):
|
||||
status_code = line.split()[1]
|
||||
@@ -220,7 +220,7 @@ def listen_for_requests(sock):
|
||||
data += chunk
|
||||
if b"\r\n\r\n" in data:
|
||||
headers_end = data.find(b"\r\n\r\n")
|
||||
headers = data[:headers_end].decode('utf-8')
|
||||
headers = data[:headers_end].decode('utf-8', errors='replace')
|
||||
|
||||
content_length = 0
|
||||
for line in headers.split("\r\n"):
|
||||
|
||||
Reference in New Issue
Block a user