diff --git a/cdxj_indexer/postquery.py b/cdxj_indexer/postquery.py index 360f28b..01edbf8 100644 --- a/cdxj_indexer/postquery.py +++ b/cdxj_indexer/postquery.py @@ -5,7 +5,7 @@ from urllib.parse import unquote_plus, urlencode from io import BytesIO -from multipart import parse_options_header, MultipartParser +from multipart import MultipartParser from warcio.utils import to_native_str from cdxj_indexer.amf import amf_parse @@ -95,19 +95,18 @@ def handle_binary(query_data): query = handle_binary(query_data) elif mime.startswith("multipart/"): - env = { - "REQUEST_METHOD": "POST", - "CONTENT_TYPE": mime, - "CONTENT_LENGTH": len(query_data), - } + # env = { + # "REQUEST_METHOD": "POST", + # "CONTENT_TYPE": mime, + # "CONTENT_LENGTH": len(query_data), + # } - args = dict(fp=BytesIO(query_data), environ=env, keep_blank_values=True) + # args = dict(fp=BytesIO(query_data), environ=env, keep_blank_values=True) try: - _, params = parse_options_header(mime) - boundary = params["boundary"] + boundary = mime.split("boundary=")[1] parser = MultipartParser(stream, boundary, charset="utf8") - except ValueError: + except (ValueError, IndexError): # Content-Type multipart/form-data may lack "boundary" info query = handle_binary(query_data) else: