diff --git a/fasjson_client/client.py b/fasjson_client/client.py index 84ed14ad..96b471d4 100644 --- a/fasjson_client/client.py +++ b/fasjson_client/client.py @@ -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. @@ -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( diff --git a/fasjson_client/response.py b/fasjson_client/response.py index c7f0c282..33c64a05 100644 --- a/fasjson_client/response.py +++ b/fasjson_client/response.py @@ -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: