Skip to content

Commit 6eaef4b

Browse files
Shaheer-rossoneri14hashhar
authored andcommitted
Remove unused 'redirect_handler' code
In be74586 the redirect_handler code was removed but only partially. This change removes the rest of the dead code related to redirect_handler.
1 parent d6047a8 commit 6eaef4b

File tree

3 files changed

+0
-20
lines changed

3 files changed

+0
-20
lines changed

tests/unit/test_client.py

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ def test_request_headers(mock_get_and_post):
117117
}
118118
),
119119
http_scheme="http",
120-
redirect_handler=None,
121120
)
122121

123122
def assert_headers(headers):

trino/client.py

-16
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ def __init__(
401401
http_session: Any = None,
402402
http_scheme: str = None,
403403
auth: Optional[Any] = constants.DEFAULT_AUTH,
404-
redirect_handler: Any = None,
405404
max_attempts: int = MAX_ATTEMPTS,
406405
request_timeout: Union[float, Tuple[float, float]] = constants.DEFAULT_REQUEST_TIMEOUT,
407406
handle_retry=_RetryWithExponentialBackoff(),
@@ -434,7 +433,6 @@ def __init__(
434433
self._auth.set_http_session(self._http_session)
435434
self._exceptions += self._auth.get_exceptions()
436435

437-
self._redirect_handler = redirect_handler
438436
self._request_timeout = request_timeout
439437
self._handle_retry = handle_retry
440438
self.max_attempts = max_attempts
@@ -557,22 +555,8 @@ def post(self, sql: str, additional_http_headers: Optional[Dict[str, Any]] = Non
557555
data=data,
558556
headers=http_headers,
559557
timeout=self._request_timeout,
560-
allow_redirects=self._redirect_handler is None,
561558
proxies=PROXIES,
562559
)
563-
if self._redirect_handler is not None:
564-
while http_response is not None and http_response.is_redirect:
565-
location = http_response.headers["Location"]
566-
url = self._redirect_handler.handle(location)
567-
logger.info("redirect %s from %s to %s", http_response.status_code, location, url)
568-
http_response = self._post(
569-
url,
570-
data=data,
571-
headers=http_headers,
572-
timeout=self._request_timeout,
573-
allow_redirects=False,
574-
proxies=PROXIES,
575-
)
576560
return http_response
577561

578562
def get(self, url: str):

trino/dbapi.py

-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ def __init__(
147147
http_scheme=constants.HTTP,
148148
auth=constants.DEFAULT_AUTH,
149149
extra_credential=None,
150-
redirect_handler=None,
151150
max_attempts=constants.DEFAULT_MAX_ATTEMPTS,
152151
request_timeout=constants.DEFAULT_REQUEST_TIMEOUT,
153152
isolation_level=IsolationLevel.AUTOCOMMIT,
@@ -192,7 +191,6 @@ def __init__(
192191
self.http_scheme = http_scheme if not parsed_host.scheme else parsed_host.scheme
193192
self.auth = auth
194193
self.extra_credential = extra_credential
195-
self.redirect_handler = redirect_handler
196194
self.max_attempts = max_attempts
197195
self.request_timeout = request_timeout
198196
self.client_tags = client_tags
@@ -251,7 +249,6 @@ def _create_request(self):
251249
self._http_session,
252250
self.http_scheme,
253251
self.auth,
254-
self.redirect_handler,
255252
self.max_attempts,
256253
self.request_timeout,
257254
)

0 commit comments

Comments
 (0)