Skip to content

Commit

Permalink
netscape
Browse files Browse the repository at this point in the history
  • Loading branch information
glyph committed Jan 29, 2022
1 parent da59847 commit 94af36e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/treq/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,35 @@ def _scoped_cookiejar_from_dict(url_object, cookie_dict):
if cookie_dict is None:
return cookie_jar
for k, v in cookie_dict.items():
secure=(url_object.scheme == 'https')
port_specified = not (
(url_object.scheme == "https" and url_object.port == 443)
or (url_object.scheme == "http" and url_object.port == 80)
)
port = str(url_object.port)
domain = url_object.host
netscape_domain = domain if '.' in domain else domain + '.local'

cookie_jar.set_cookie(
Cookie(
version=0,
# Scoping
domain=netscape_domain,
port=port,
secure=secure,
port_specified=port_specified,

# Contents
name=k,
value=v,
domain=url_object.host,
port=str(url_object.port),
path="",
secure=(url_object.scheme == 'https'),

# Constant/always-the-same stuff
version=0,
path="/",
expires=None,
discard=False,
comment=None,
comment_url=None,
rfc2109=False,
port_specified=(
not (url_object.scheme == "https" and url_object.port == 443)
or (url_object.scheme == "http" and url_object.port == 80)
),
path_specified=False,
domain_specified=False,
domain_initial_dot=False,
Expand Down
1 change: 1 addition & 0 deletions src/treq/test/test_treq_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def print_response(response):
print('---')
print(response.code)
print(response.headers)
print(response.request.headers)
text = yield treq.text_content(response)
print(text)
print('---')
Expand Down

0 comments on commit 94af36e

Please sign in to comment.