v1.0.125: Sonnet fix — CORS inside nginx if, raw binary ZIP, multipart fallback
This commit is contained in:
+13
-10
@@ -286,16 +286,19 @@ class Handler(BaseHTTPRequestHandler):
|
||||
length = int(self.headers.get("Content-Length", 0))
|
||||
body = self.rfile.read(length)
|
||||
|
||||
# Парсим multipart через email.parser
|
||||
msg = BytesParser().parsebytes(
|
||||
b"Content-Type: " + content_type.encode() + b"\r\n\r\n" + body
|
||||
)
|
||||
zip_data = None
|
||||
if msg.is_multipart():
|
||||
for part in msg.get_payload():
|
||||
if part.get_filename():
|
||||
zip_data = part.get_payload(decode=True)
|
||||
break
|
||||
# Raw binary (браузер) или multipart (curl fallback)
|
||||
if "multipart" in content_type:
|
||||
msg = BytesParser().parsebytes(
|
||||
b"Content-Type: " + content_type.encode() + b"\r\n\r\n" + body
|
||||
)
|
||||
zip_data = None
|
||||
if msg.is_multipart():
|
||||
for part in msg.get_payload():
|
||||
if part.get_filename():
|
||||
zip_data = part.get_payload(decode=True)
|
||||
break
|
||||
else:
|
||||
zip_data = body
|
||||
else:
|
||||
zip_data = body
|
||||
|
||||
|
||||
Reference in New Issue
Block a user