mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
replay/memento: always include 'Content-Location' for in no-redir mode replay (not just for memento timegate), #122
This commit is contained in:
parent
66f5ad62b3
commit
c2f99d6cfd
@ -106,10 +106,10 @@ class MementoRespMixin(object):
|
||||
timestamp=ts,
|
||||
url=url)
|
||||
|
||||
# Must set content location
|
||||
if is_memento and is_timegate:
|
||||
self.status_headers.headers.append(('Content-Location',
|
||||
canon_link))
|
||||
# set in replay_views -- Must set content location
|
||||
#if is_memento and is_timegate:
|
||||
# self.status_headers.headers.append(('Content-Location',
|
||||
# canon_link))
|
||||
|
||||
# don't set memento link for very long urls...
|
||||
if len(canon_link) < 512:
|
||||
|
@ -191,6 +191,16 @@ class ReplayView(object):
|
||||
response_iter,
|
||||
self.buffer_max_size)
|
||||
|
||||
# Set Content-Location if not exact capture
|
||||
if not self.redir_to_exact:
|
||||
mod = wbrequest.options.get('replay_mod', wbrequest.wb_url.mod)
|
||||
canon_url = (wbrequest.urlrewriter.
|
||||
get_new_url(timestamp=cdx['timestamp'],
|
||||
url=cdx['url'],
|
||||
mod=mod))
|
||||
|
||||
status_headers.headers.append(('Content-Location', canon_url))
|
||||
|
||||
response = self.response_class(status_headers,
|
||||
response_iter,
|
||||
wbrequest=wbrequest,
|
||||
|
@ -303,23 +303,23 @@ class TestWb:
|
||||
|
||||
def test_redirect_non_exact_latest_replay_ts(self):
|
||||
resp = self.testapp.get('/pywb-non-exact/http://example.com/')
|
||||
assert resp.status_int == 302
|
||||
assert resp.status_int == 200
|
||||
|
||||
assert resp.headers['Location'].endswith('/http://example.com')
|
||||
assert resp.headers['Content-Location'].endswith('/http://example.com')
|
||||
|
||||
# extract ts, which should be current time
|
||||
ts = resp.headers['Location'].rsplit('/http://')[0].rsplit('/', 1)[-1]
|
||||
assert len(ts) == 14, ts
|
||||
resp = resp.follow()
|
||||
ts = resp.headers['Content-Location'].rsplit('/http://')[0].rsplit('/', 1)[-1]
|
||||
assert ts == '20140127171251'
|
||||
#resp = resp.follow()
|
||||
|
||||
self._assert_basic_html(resp)
|
||||
#self._assert_basic_html(resp)
|
||||
|
||||
# ensure the current ts is present in the links
|
||||
assert '"{0}"'.format(ts) in resp.body
|
||||
assert '/pywb-non-exact/{0}/http://www.iana.org/domains/example'.format(ts) in resp.body
|
||||
assert '/pywb-non-exact/http://www.iana.org/domains/example' in resp.body
|
||||
|
||||
# ensure ts is current ts
|
||||
assert timestamp_now() >= ts, ts
|
||||
#assert timestamp_now() >= ts, ts
|
||||
|
||||
def test_redirect_relative_3(self):
|
||||
# webtest uses Host: localhost:80 by default
|
||||
|
Loading…
x
Reference in New Issue
Block a user