mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
cookie_rewriter: add 'exact' cookie rewriter which never changes the
path/domain
This commit is contained in:
parent
388f31e08f
commit
20070e95b6
@ -55,6 +55,24 @@ class MinimalScopeCookieRewriter(WbUrlBaseCookieRewriter):
|
||||
return morsel
|
||||
|
||||
|
||||
#=================================================================
|
||||
class ExactPathCookieRewriter(WbUrlBaseCookieRewriter):
|
||||
"""
|
||||
Rewrite cookies only using exact path, useful for live rewrite
|
||||
without a timestamp and to minimize cookie pollution
|
||||
|
||||
If path or domain present, simply remove
|
||||
"""
|
||||
|
||||
def rewrite_cookie(self, name, morsel):
|
||||
if morsel.get('domain'):
|
||||
del morsel['domain']
|
||||
# else set cookie to rewritten path
|
||||
if morsel.get('path'):
|
||||
del morsel['path']
|
||||
|
||||
self._remove_age_opts(morsel)
|
||||
return morsel
|
||||
#=================================================================
|
||||
class RootScopeCookieRewriter(WbUrlBaseCookieRewriter):
|
||||
"""
|
||||
@ -79,5 +97,7 @@ class RootScopeCookieRewriter(WbUrlBaseCookieRewriter):
|
||||
def get_cookie_rewriter(cookie_scope):
|
||||
if cookie_scope == 'root':
|
||||
return RootScopeCookieRewriter
|
||||
elif cookie_scope == 'exact':
|
||||
return ExactPathCookieRewriter
|
||||
else:
|
||||
return MinimalScopeCookieRewriter
|
||||
|
Loading…
x
Reference in New Issue
Block a user