Skip to content

Commit

Permalink
do not parse cookies on DB requests
Browse files Browse the repository at this point in the history
requests with Cookie headers set after Set-Cookie responses where being
rejected by DB gateway
  • Loading branch information
eskerda committed Sep 12, 2024
1 parent a178043 commit be31de1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions pybikes/deutschebahn.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def auth_headers(self):

def update(self, scraper=None):
scraper = scraper or PyBikesScraper()
scraper.parse_cookies = False
scraper.headers.update(self.auth_headers)
super(DB, self).update(scraper)

Expand Down
4 changes: 3 additions & 1 deletion pybikes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(
session=None,
requests_timeout=300,
ssl_verification=True,
parse_cookies=True,
):
self.headers = headers if isinstance(headers, dict) else {}
self.headers.setdefault('User-Agent', user_agent)
Expand Down Expand Up @@ -92,8 +93,9 @@ def request(self, url, method='GET', params=None, data=None, raw=False,
if raw:
data = response.content

if 'set-cookie' in response.headers:
if self.parse_cookies and 'set-cookie' in response.headers:
self.headers['Cookie'] = response.headers['set-cookie']

self.last_request = response

if self.cachedict is not None:
Expand Down

0 comments on commit be31de1

Please sign in to comment.