Skip to content

Commit 4276e71

Browse files
authored
Merge pull request #16 from hubmapconsortium/Derek-Furst/add-tweaks
reimplemented previous manual sdk fixes to correct 303 handling, and …
2 parents 3c18aeb + 023d756 commit 4276e71

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/hubmap_search_sdk/_base_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ def _build_request(
462462
raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`")
463463

464464
headers = self._build_headers(options, retries_taken=retries_taken)
465+
# If it's a GET request and there's no body (no json_data or extra_json), remove Content-Type
466+
if options.method.lower()=='get' and not json_data:
467+
headers.pop('Content-Type', None)
465468
params = _merge_mappings(self.default_query, options.params)
466469
content_type = headers.get("Content-Type")
467470
files = options.files
@@ -999,6 +1002,15 @@ def _request(
9991002
response.raise_for_status()
10001003
except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code
10011004
log.debug("Encountered httpx.HTTPStatusError", exc_info=True)
1005+
if response.status_code in (301, 302, 303, 307, 308):
1006+
return self._process_response(
1007+
cast_to=cast_to,
1008+
options=options,
1009+
response=response,
1010+
stream=stream,
1011+
stream_cls=stream_cls,
1012+
retries_taken=retries_taken,
1013+
)
10021014

10031015
if remaining_retries > 0 and self._should_retry(err.response):
10041016
err.response.close()

0 commit comments

Comments
 (0)