Skip to content

Commit 466edc0

Browse files
authored
Merge pull request #361 from arXiv/ARXIVCE-4110-allow-missing-contenttype
ARXIVCE-4110: parse data manually when no contentType
2 parents 11f4c66 + ef955f5 commit 466edc0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

search/routes/classic_api/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from search.controllers import classic_api
1414
from search.routes.consts import ATOM_XML
1515
from search.routes.classic_api import exceptions
16+
from urllib.parse import parse_qs
1617

1718
logger = logging.getLogger(__name__)
1819

@@ -23,11 +24,16 @@
2324
# @scoped(required=scopes.READ_PUBLIC)
2425
def query() -> Response:
2526
"""Provide the main query endpoint."""
26-
logger.debug("Got query: %s", request.args)
2727
if request.method == "POST":
28-
args = request.form
28+
ct = request.headers.get("Content-Type", "")
29+
if not ct:
30+
raw = request.get_data(as_text=True)
31+
args = {k: v[0] for k, v in parse_qs(raw).items()}
32+
else:
33+
args = request.form
2934
else:
3035
args = request.args
36+
#logger.debug("Got query: %s", request.args)
3137
data, status_code, headers = classic_api.query(args)
3238
response_data = serialize.as_atom( # type: ignore
3339
data.results, query=data.query

0 commit comments

Comments
 (0)