mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
memento timemap fix: further fix for ukwa/ukwa-pywb#37
- fix timemap in 'redirect-to-exact' mode, (ensure timegate redirect condition applies only to top-frame) - tests: add additional timemap tests, with and without exact redirect
This commit is contained in:
parent
c65f66e03a
commit
5da6122d83
@ -297,14 +297,14 @@ class RewriterApp(object):
|
||||
else:
|
||||
wb_url.mod = pref_mod
|
||||
else:
|
||||
# don't return top-frame response for timegate with exact redirects
|
||||
kwargs['is_timegate_redir'] = is_timegate and redirect_to_exact
|
||||
response = self.handle_custom_response(environ, wb_url,
|
||||
full_prefix, host_prefix,
|
||||
kwargs)
|
||||
|
||||
if response:
|
||||
# don't return top-frame response for timegate with exact redirects
|
||||
if not is_timegate or not redirect_to_exact:
|
||||
return self.format_response(response, wb_url, full_prefix, is_timegate, is_proxy)
|
||||
return self.format_response(response, wb_url, full_prefix, is_timegate, is_proxy)
|
||||
|
||||
if is_proxy:
|
||||
environ['pywb_proxy_magic'] = environ['wsgiprox.proxy_host']
|
||||
@ -767,7 +767,7 @@ class RewriterApp(object):
|
||||
if wb_url.is_query():
|
||||
return self.handle_query(environ, wb_url, kwargs, full_prefix)
|
||||
|
||||
if self.is_framed_replay(wb_url):
|
||||
if self.is_framed_replay(wb_url) and not kwargs.get('is_timegate_redir'):
|
||||
extra_params = self.get_top_frame_params(wb_url, kwargs)
|
||||
return self.frame_insert_view.get_top_frame(wb_url,
|
||||
full_prefix,
|
||||
|
@ -192,6 +192,9 @@ class TestMementoRedirectClassic(MementoMixin, BaseConfigTest):
|
||||
def setup_class(cls):
|
||||
super(TestMementoRedirectClassic, cls).setup_class('config_test_redirect_classic.yaml')
|
||||
|
||||
def _timemap_get(self, url, **kwargs):
|
||||
return self.testapp.get(url, extra_environ={'REQUEST_URI': url}, **kwargs)
|
||||
|
||||
def test_memento_top_frame_timegate(self, fmod):
|
||||
resp = self.testapp.get('/pywb/http://www.iana.org/')
|
||||
assert resp.status_code == 307
|
||||
@ -249,6 +252,26 @@ class TestMementoRedirectClassic(MementoMixin, BaseConfigTest):
|
||||
assert '"20140126200624"' in resp.text
|
||||
assert '"http://www.iana.org/"' in resp.text, resp.text
|
||||
|
||||
def test_timemap(self):
|
||||
"""
|
||||
Test application/link-format timemap
|
||||
"""
|
||||
|
||||
resp = self._timemap_get('/pywb/timemap/link/http://example.com?example=1')
|
||||
assert resp.status_int == 200
|
||||
assert resp.content_type == LINK_FORMAT
|
||||
|
||||
resp.charset = 'utf-8'
|
||||
|
||||
exp = """\
|
||||
<http://localhost:80/pywb/timemap/link/http://example.com?example=1>; rel="self"; type="application/link-format"; from="Fri, 03 Jan 2014 03:03:21 GMT",
|
||||
<http://localhost:80/pywb/http://example.com?example=1>; rel="timegate",
|
||||
<http://example.com?example=1>; rel="original",
|
||||
<http://example.com?example=1>; rel="memento"; datetime="Fri, 03 Jan 2014 03:03:21 GMT"; collection="pywb",
|
||||
<http://example.com?example=1>; rel="memento"; datetime="Fri, 03 Jan 2014 03:03:41 GMT"; collection="pywb"
|
||||
"""
|
||||
assert exp == resp.text
|
||||
|
||||
def test_memento_not_time_gate(self, fmod):
|
||||
headers = {'Accept-Datetime': 'Sun, 26 Jan 2014 20:06:24 GMT'}
|
||||
resp = self.testapp.get('/pywb/2/http://www.iana.org/', headers=headers)
|
||||
|
Loading…
x
Reference in New Issue
Block a user