修复图片
This commit is contained in:
parent
6240e453b0
commit
be710920e9
@ -99,7 +99,7 @@ def modify_request_headers(request_data):
|
|||||||
def handle_request(request_data):
|
def handle_request(request_data):
|
||||||
"""Handle a single request from device B - completely independent thread"""
|
"""Handle a single request from device B - completely independent thread"""
|
||||||
if isinstance(request_data, bytes):
|
if isinstance(request_data, bytes):
|
||||||
request_data_str = request_data.decode('utf-8')
|
request_data_str = request_data.decode('utf-8', errors='replace')
|
||||||
else:
|
else:
|
||||||
request_data_str = request_data
|
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:
|
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_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"):
|
for line in headers.split("\r\n"):
|
||||||
if line.lower().startswith("content-length:"):
|
if line.lower().startswith("content-length:"):
|
||||||
@ -163,7 +163,7 @@ def handle_request(request_data):
|
|||||||
status_code = "500"
|
status_code = "500"
|
||||||
if b"\r\n\r\n" in response:
|
if b"\r\n\r\n" in response:
|
||||||
headers_end = response.find(b"\r\n\r\n")
|
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"):
|
for line in headers.split("\r\n"):
|
||||||
if line.startswith("HTTP/"):
|
if line.startswith("HTTP/"):
|
||||||
status_code = line.split()[1]
|
status_code = line.split()[1]
|
||||||
@ -220,7 +220,7 @@ def listen_for_requests(sock):
|
|||||||
data += chunk
|
data += chunk
|
||||||
if b"\r\n\r\n" in data:
|
if b"\r\n\r\n" in data:
|
||||||
headers_end = data.find(b"\r\n\r\n")
|
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
|
content_length = 0
|
||||||
for line in headers.split("\r\n"):
|
for line in headers.split("\r\n"):
|
||||||
|
|||||||
@ -140,7 +140,7 @@ def process_response_from_a():
|
|||||||
|
|
||||||
if b"\r\n\r\n" in response and not headers_found:
|
if b"\r\n\r\n" in response and not headers_found:
|
||||||
headers_end = response.find(b"\r\n\r\n")
|
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')
|
||||||
headers_found = True
|
headers_found = True
|
||||||
|
|
||||||
for line in headers.split("\r\n"):
|
for line in headers.split("\r\n"):
|
||||||
@ -201,7 +201,7 @@ def handle_browser_request(browser_conn, browser_addr):
|
|||||||
data += chunk
|
data += chunk
|
||||||
if b"\r\n\r\n" in data:
|
if b"\r\n\r\n" in data:
|
||||||
headers_end = data.find(b"\r\n\r\n")
|
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
|
content_length = 0
|
||||||
for line in headers.split("\r\n"):
|
for line in headers.split("\r\n"):
|
||||||
@ -216,7 +216,7 @@ def handle_browser_request(browser_conn, browser_addr):
|
|||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
|
|
||||||
request_lines = data.decode('utf-8').split("\r\n")
|
request_lines = data.decode('utf-8', errors='replace').split("\r\n")
|
||||||
if request_lines:
|
if request_lines:
|
||||||
first_line = request_lines[0]
|
first_line = request_lines[0]
|
||||||
parts = first_line.split()
|
parts = first_line.split()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user