更新日志

This commit is contained in:
cheney 2026-05-26 18:05:05 +08:00
parent be710920e9
commit d11390e453
2 changed files with 7 additions and 5 deletions

View File

@ -111,7 +111,7 @@ def handle_request(request_data):
if "\r\n\r\n" in modified_data:
body_size = len(modified_data) - modified_data.find("\r\n\r\n") - 4
log_info("System", "Request: %s %s - Body: %d bytes - ID: %s" % (method, path, body_size, request_id))
log_info("System", "Request: %s %s%s - Body: %d bytes - ID: %s" % (method, "http://" + TARGET_HOST + ":" + str(TARGET_PORT), path, body_size, request_id))
target_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
target_sock.settimeout(30)

View File

@ -242,11 +242,13 @@ def handle_browser_request(browser_conn, browser_addr):
'timestamp': time.time()
}
if isinstance(data, bytes):
modified_data = ("X-Proxy-Request-ID: " + request_id + "\r\n").encode('utf-8') + data
if b"\r\n\r\n" in data:
headers_end = data.find(b"\r\n\r\n")
headers = data[:headers_end]
body = data[headers_end:]
modified_data = headers + ("\r\nX-Proxy-Request-ID: " + request_id).encode('utf-8') + body
else:
modified_data = "X-Proxy-Request-ID: " + request_id + "\r\n" + data
modified_data = modified_data.encode('utf-8')
modified_data = data + ("\r\nX-Proxy-Request-ID: " + request_id + "\r\n\r\n").encode('utf-8')
with a_device_lock:
try: