Skip to content

Commit

Permalink
Follow redirects by default
Browse files Browse the repository at this point in the history
This is made harder by Yelp/bravado#494
It is necessary because of gssapi/mod_auth_gssapi#316

Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed Sep 30, 2024
1 parent 36e38c3 commit 7fc652d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fasjson_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class InvalidJSONError(RequestException):
from .formats import mask_format


class RequestsClientFollowingRedirects(requests_client.RequestsClient):
def separate_params(self, request_params):
request_params["follow_redirects"] = True
return super().separate_params(request_params)


class Client:
"""FASJSON client class that builds API methods based on openapi specs.
Expand Down Expand Up @@ -66,7 +72,7 @@ def _spec_url(self):
return urljoin(self._base_url, f"specs/v{self._api_version}.json")

def _make_bravado_client(self):
http_client = requests_client.RequestsClient()
http_client = RequestsClientFollowingRedirects()
server_hostname = urlsplit(self._base_url).netloc
if self._auth:
http_client.authenticator = GssapiAuthenticator(
Expand Down
3 changes: 3 additions & 0 deletions fasjson_client/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def __call__(self, **kwargs):
Raises:
APIError: if the API doesn't return a successful response
"""
# Unfortunately this does not work because of
# https://github.com/Yelp/bravado/issues/494
# kwargs.setdefault("_request_options", {})["follow_redirects"] = True
try:
call_result = self.operation(**kwargs).response().result
except HTTPError as e:
Expand Down

0 comments on commit 7fc652d

Please sign in to comment.