summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorPaul Bailey <paul.m.bailey@gmail.com>2018-10-08 18:49:29 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2018-10-08 18:49:29 (GMT)
commit4c339970570d07916bee6ade51f4e9781d51627a (patch)
treed389f9afd8cdb4e2a02e4d941d983cbecccb07e6 /Lib/http
parentaf5658ae93b0a87ab4420a7dc30a07fa5a83e252 (diff)
downloadcpython-4c339970570d07916bee6ade51f4e9781d51627a.zip
cpython-4c339970570d07916bee6ade51f4e9781d51627a.tar.gz
cpython-4c339970570d07916bee6ade51f4e9781d51627a.tar.bz2
bpo-34911: Added support for secure websocket cookies (GH-9734)
Diffstat (limited to 'Lib/http')
-rw-r--r--Lib/http/cookiejar.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
index e0f1032..0ba8200 100644
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py
@@ -878,6 +878,7 @@ class DefaultCookiePolicy(CookiePolicy):
strict_ns_domain=DomainLiberal,
strict_ns_set_initial_dollar=False,
strict_ns_set_path=False,
+ secure_protocols=("https", "wss")
):
"""Constructor arguments should be passed as keyword arguments only."""
self.netscape = netscape
@@ -890,6 +891,7 @@ class DefaultCookiePolicy(CookiePolicy):
self.strict_ns_domain = strict_ns_domain
self.strict_ns_set_initial_dollar = strict_ns_set_initial_dollar
self.strict_ns_set_path = strict_ns_set_path
+ self.secure_protocols = secure_protocols
if blocked_domains is not None:
self._blocked_domains = tuple(blocked_domains)
@@ -1116,7 +1118,7 @@ class DefaultCookiePolicy(CookiePolicy):
return True
def return_ok_secure(self, cookie, request):
- if cookie.secure and request.type != "https":
+ if cookie.secure and request.type not in self.secure_protocols:
_debug(" secure cookie with non-secure request")
return False
return True