Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions nylas/handler/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def _validate_response(response: Response) -> dict:

return json

def _validate_download_response(response:Response) -> Union[bytes, Response, dict]:
if response.ok:
return response.content
return _validate_response(response)

def _build_query_params(base_url: str, query_params: dict = None) -> str:
query_param_parts = []
Expand Down Expand Up @@ -126,9 +130,9 @@ def _execute_download_request(

# If we stream an iterator for streaming the content, otherwise return the entire byte array
if stream:
return response
return response if response.ok else _validate_response(response)

return response.content if response.content else None
return _validate_download_response(response) if response.content else None
except requests.exceptions.Timeout as exc:
raise NylasSdkTimeoutError(url=request["url"], timeout=timeout) from exc

Expand Down