mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
cookie rewrite: remove max-age, add test
This commit is contained in:
parent
ceeb25a899
commit
d21f8079ca
@ -30,6 +30,10 @@ class WbUrlCookieRewriter(object):
|
|||||||
if morsel.get('expires'):
|
if morsel.get('expires'):
|
||||||
del morsel['expires']
|
del morsel['expires']
|
||||||
|
|
||||||
|
# don't use max-age, just expire at end of session
|
||||||
|
if morsel.get('max-age'):
|
||||||
|
del morsel['max-age']
|
||||||
|
|
||||||
results.append((header, morsel.OutputString()))
|
results.append((header, morsel.OutputString()))
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -6,11 +6,14 @@ r"""
|
|||||||
>>> rewrite_cookie('some=value; Path=/;')
|
>>> rewrite_cookie('some=value; Path=/;')
|
||||||
[('Set-Cookie', 'some=value; Path=/pywb/20131226101010/http://example.com/')]
|
[('Set-Cookie', 'some=value; Path=/pywb/20131226101010/http://example.com/')]
|
||||||
|
|
||||||
|
>>> rewrite_cookie('some=value; Path=../;', rewriter=urlrewriter2)
|
||||||
|
[('Set-Cookie', 'some=value; Path=/preview/em_/http://example.com/')]
|
||||||
|
|
||||||
>>> rewrite_cookie('some=value; Path=/diff/path/;')
|
>>> rewrite_cookie('some=value; Path=/diff/path/;')
|
||||||
[('Set-Cookie', 'some=value; Path=/pywb/20131226101010/http://example.com/diff/path/')]
|
[('Set-Cookie', 'some=value; Path=/pywb/20131226101010/http://example.com/diff/path/')]
|
||||||
|
|
||||||
# if domain set, set path to root
|
# if domain set, set path to root
|
||||||
>>> rewrite_cookie('some=value; Domain=.example.com; Path=/diff/path/;')
|
>>> rewrite_cookie('some=value; Domain=.example.com; Path=/diff/path/; Max-Age=1500')
|
||||||
[('Set-Cookie', 'some=value; Path=/pywb/')]
|
[('Set-Cookie', 'some=value; Path=/pywb/')]
|
||||||
|
|
||||||
>>> rewrite_cookie('abc=def; Path=file.html; Expires=Wed, 13 Jan 2021 22:23:01 GMT')
|
>>> rewrite_cookie('abc=def; Path=file.html; Expires=Wed, 13 Jan 2021 22:23:01 GMT')
|
||||||
@ -28,6 +31,9 @@ from pywb.rewrite.url_rewriter import UrlRewriter
|
|||||||
|
|
||||||
urlrewriter = UrlRewriter('20131226101010/http://example.com/some/path/index.html', '/pywb/')
|
urlrewriter = UrlRewriter('20131226101010/http://example.com/some/path/index.html', '/pywb/')
|
||||||
|
|
||||||
def rewrite_cookie(cookie_str):
|
urlrewriter2 = UrlRewriter('em_/http://example.com/', '/preview/')
|
||||||
return WbUrlCookieRewriter(urlrewriter).rewrite(cookie_str)
|
|
||||||
|
|
||||||
|
def rewrite_cookie(cookie_str, rewriter=urlrewriter):
|
||||||
|
return WbUrlCookieRewriter(rewriter).rewrite(cookie_str)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user