Skip to content

Commit

Permalink
Remove unused 'redirect_handler' code
Browse files Browse the repository at this point in the history
In be74586 the redirect_handler code
was removed but only partially.

This change removes the rest of the dead code related to
redirect_handler.
  • Loading branch information
Shaheer-rossoneri14 authored and hashhar committed Aug 5, 2023
1 parent d6047a8 commit 6eaef4b
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 20 deletions.
1 change: 0 additions & 1 deletion tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def test_request_headers(mock_get_and_post):
}
),
http_scheme="http",
redirect_handler=None,
)

def assert_headers(headers):
Expand Down
16 changes: 0 additions & 16 deletions trino/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ def __init__(
http_session: Any = None,
http_scheme: str = None,
auth: Optional[Any] = constants.DEFAULT_AUTH,
redirect_handler: Any = None,
max_attempts: int = MAX_ATTEMPTS,
request_timeout: Union[float, Tuple[float, float]] = constants.DEFAULT_REQUEST_TIMEOUT,
handle_retry=_RetryWithExponentialBackoff(),
Expand Down Expand Up @@ -434,7 +433,6 @@ def __init__(
self._auth.set_http_session(self._http_session)
self._exceptions += self._auth.get_exceptions()

self._redirect_handler = redirect_handler
self._request_timeout = request_timeout
self._handle_retry = handle_retry
self.max_attempts = max_attempts
Expand Down Expand Up @@ -557,22 +555,8 @@ def post(self, sql: str, additional_http_headers: Optional[Dict[str, Any]] = Non
data=data,
headers=http_headers,
timeout=self._request_timeout,
allow_redirects=self._redirect_handler is None,
proxies=PROXIES,
)
if self._redirect_handler is not None:
while http_response is not None and http_response.is_redirect:
location = http_response.headers["Location"]
url = self._redirect_handler.handle(location)
logger.info("redirect %s from %s to %s", http_response.status_code, location, url)
http_response = self._post(
url,
data=data,
headers=http_headers,
timeout=self._request_timeout,
allow_redirects=False,
proxies=PROXIES,
)
return http_response

def get(self, url: str):
Expand Down
3 changes: 0 additions & 3 deletions trino/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def __init__(
http_scheme=constants.HTTP,
auth=constants.DEFAULT_AUTH,
extra_credential=None,
redirect_handler=None,
max_attempts=constants.DEFAULT_MAX_ATTEMPTS,
request_timeout=constants.DEFAULT_REQUEST_TIMEOUT,
isolation_level=IsolationLevel.AUTOCOMMIT,
Expand Down Expand Up @@ -192,7 +191,6 @@ def __init__(
self.http_scheme = http_scheme if not parsed_host.scheme else parsed_host.scheme
self.auth = auth
self.extra_credential = extra_credential
self.redirect_handler = redirect_handler
self.max_attempts = max_attempts
self.request_timeout = request_timeout
self.client_tags = client_tags
Expand Down Expand Up @@ -251,7 +249,6 @@ def _create_request(self):
self._http_session,
self.http_scheme,
self.auth,
self.redirect_handler,
self.max_attempts,
self.request_timeout,
)
Expand Down

0 comments on commit 6eaef4b

Please sign in to comment.