mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 13:11:15 -07:00
Update websocket-client-1.2.1
This commit is contained in:
parent
c67f18d65c
commit
aa127ecbda
21 changed files with 1756 additions and 1045 deletions
|
@ -1,7 +1,26 @@
|
|||
try:
|
||||
import Cookie
|
||||
except:
|
||||
import http.cookies as Cookie
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
_cookiejar.py
|
||||
websocket - WebSocket client library for Python
|
||||
|
||||
Copyright 2021 engn33r
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
import http.cookies
|
||||
|
||||
|
||||
class SimpleCookieJar(object):
|
||||
|
@ -10,26 +29,20 @@ class SimpleCookieJar(object):
|
|||
|
||||
def add(self, set_cookie):
|
||||
if set_cookie:
|
||||
try:
|
||||
simpleCookie = Cookie.SimpleCookie(set_cookie)
|
||||
except:
|
||||
simpleCookie = Cookie.SimpleCookie(set_cookie.encode('ascii', 'ignore'))
|
||||
simpleCookie = http.cookies.SimpleCookie(set_cookie)
|
||||
|
||||
for k, v in simpleCookie.items():
|
||||
domain = v.get("domain")
|
||||
if domain:
|
||||
if not domain.startswith("."):
|
||||
domain = "." + domain
|
||||
cookie = self.jar.get(domain) if self.jar.get(domain) else Cookie.SimpleCookie()
|
||||
cookie = self.jar.get(domain) if self.jar.get(domain) else http.cookies.SimpleCookie()
|
||||
cookie.update(simpleCookie)
|
||||
self.jar[domain.lower()] = cookie
|
||||
|
||||
def set(self, set_cookie):
|
||||
if set_cookie:
|
||||
try:
|
||||
simpleCookie = Cookie.SimpleCookie(set_cookie)
|
||||
except:
|
||||
simpleCookie = Cookie.SimpleCookie(set_cookie.encode('ascii', 'ignore'))
|
||||
simpleCookie = http.cookies.SimpleCookie(set_cookie)
|
||||
|
||||
for k, v in simpleCookie.items():
|
||||
domain = v.get("domain")
|
||||
|
@ -48,5 +61,7 @@ class SimpleCookieJar(object):
|
|||
if host.endswith(domain) or host == domain[1:]:
|
||||
cookies.append(self.jar.get(domain))
|
||||
|
||||
return "; ".join(filter(None, ["%s=%s" % (k, v.value) for cookie in filter(None, sorted(cookies)) for k, v in
|
||||
sorted(cookie.items())]))
|
||||
return "; ".join(filter(
|
||||
None, sorted(
|
||||
["%s=%s" % (k, v.value) for cookie in filter(None, cookies) for k, v in cookie.items()]
|
||||
)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue