Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused 'redirect_handler' code #396

Merged
Show file tree
Hide file tree
Changes from all 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
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