mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-16 12:21:13 +00:00
Sent cookies with more specific paths first.
This commit is contained in:
parent
c70bd68ef1
commit
8779158b2f
1 changed files with 5 additions and 1 deletions
6
linkcheck/cache/cookie.py
vendored
6
linkcheck/cache/cookie.py
vendored
|
|
@ -67,10 +67,14 @@ class CookieJar (object):
|
|||
|
||||
@synchronized(_lock)
|
||||
def get (self, scheme, host, port, path):
|
||||
"""Cookie cache getter function."""
|
||||
"""Cookie cache getter function. Return ordered list of cookies
|
||||
which match the given host, port and path.
|
||||
Cookies with more specific paths are listed first."""
|
||||
jar = self.cache.setdefault(host, set())
|
||||
cookies = [x for x in jar if x.check_expired() and \
|
||||
x.is_valid_for(scheme, host, port, path)]
|
||||
# order cookies with more specific (ie. longer) paths first
|
||||
cookies.sort(key=lambda c: len(c.attributes['path']), reverse=True)
|
||||
log.debug(LOG_CACHE, "Found %d cookies for host %r path %r",
|
||||
len(cookies), host, path)
|
||||
return cookies
|
||||
|
|
|
|||
Loading…
Reference in a new issue