Skip to content

Commit

Permalink
Release 0.0.1-beta10
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Sep 11, 2024
1 parent 2be7b38 commit e8fdb56
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions src/gooey/core/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio
import email.utils
import json as json_module
import json
import re
import time
import typing
Expand Down Expand Up @@ -90,7 +90,8 @@ def _should_retry(response: httpx.Response) -> bool:


def remove_omit_from_dict(
original: typing.Dict[str, typing.Optional[typing.Any]], omit: typing.Optional[typing.Any]
original: typing.Dict[str, typing.Optional[typing.Any]],
omit: typing.Optional[typing.Any],
) -> typing.Dict[str, typing.Any]:
if omit is None:
return original
Expand Down Expand Up @@ -142,7 +143,8 @@ def get_request_body(
# If both data and json are None, we send json data in the event extra properties are specified
json_body = maybe_filter_request_body(json, request_options, omit)

return json_body, data_body
# If you have an empty JSON body, you should just send None
return (json_body if json_body != {} else None), data_body if data_body != {} else None


class HttpClient:
Expand Down Expand Up @@ -188,8 +190,6 @@ def request(
else self.base_timeout
)

if not json and isinstance(data, typing.Mapping):
data = {"json": json_module.dumps(data)}
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)

response = self.httpx_client.request(
Expand Down Expand Up @@ -246,24 +246,7 @@ def request(
omit=omit,
)

location = response.headers.get("location")
if not location:
return response

while True:
response = self.request(location, method="get")
if not response.is_success:
print(response)
print("body", response.json())
return response
else:
body = response.json()
if body.get("status") in ["starting", "running"]:
continue
else: # failed, completed, or something not in the spec
print(response)
print("body", body)
return response
return response

@contextmanager
def stream(
Expand Down

0 comments on commit e8fdb56

Please sign in to comment.