Skip to content

Commit

Permalink
Revert "Add support for cookies"
Browse files Browse the repository at this point in the history
This reverts commit 30c1735.

Cookies are already persisted by the `requests.Session` object` in
`prestodb.PrestoRequest._http_session`. The `Set-Cookie` header is then
accessible through the *session* and not in the response.
  • Loading branch information
Greg Leclercq authored and ggreg committed Jun 12, 2018
1 parent 4f5be9c commit b5afd73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
20 changes: 3 additions & 17 deletions prestodb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def __init__(
# mypy cannot follow module import
self._http_session = self.http.Session() # type: ignore
self._http_session.headers.update(self.http_headers)
self._http_cookies = {}
self._auth = auth
if self._auth:
if http_scheme == constants.HTTP:
Expand Down Expand Up @@ -305,19 +304,9 @@ def max_attempts(self, value):
),
max_attempts=self._max_attempts,
)
def get(*args, **kwargs):
return self._http_session.get(
*args, cookies=self._http_cookies, **kwargs)
def post(*args, **kwargs):
return self._http_session.post(
*args, cookies=self._http_cookies, **kwargs)
def delete(*args, **kwargs):
return self._http_session.delete(
*args, cookies=self._http_cookies, **kwargs)

self._get = with_retry(get)
self._post = with_retry(post)
self._delete = with_retry(delete)
self._get = with_retry(self._http_session.get)
self._post = with_retry(self._http_session.post)
self._delete = with_retry(self._http_session.delete)

def get_url(self, path):
# type: (Text) -> Text
Expand Down Expand Up @@ -429,9 +418,6 @@ def process(self, http_response):
):
self._client_session.properties[key] = value

if http_response.cookies:
self._http_cookies.update(http_response.cookies)

self._next_uri = response.get('nextUri')

return PrestoStatus(
Expand Down
22 changes: 0 additions & 22 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,28 +420,6 @@ def test_presto_fetch_request(monkeypatch):
assert status.rows == RESP_DATA_GET_0['data']


def test_presto_fetch_request_with_cookie(monkeypatch):
monkeypatch.setattr(PrestoRequest.http.Response, 'json', get_json_get_0)

req = PrestoRequest(
host='coordinator',
port=8080,
user='test',
source='test',
catalog='test',
schema='test',
http_scheme='http',
session_properties={},
)

http_resp = PrestoRequest.http.Response()
http_resp.status_code = 200
http_resp.cookies['key'] = 'value'
req.process(http_resp)

assert req._http_cookies['key'] == 'value'


def test_presto_fetch_error(monkeypatch):
monkeypatch.setattr(
PrestoRequest.http.Response,
Expand Down

0 comments on commit b5afd73

Please sign in to comment.