From a2ffbde2f6d0b9554369416360f75acf745e73be Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Wed, 8 Mar 2017 12:30:20 -0800 Subject: [PATCH] dockerfile: add portalocker rewriterapp: don't add memento headers for ajax responses to avoid replay issues --- Dockerfile | 2 +- pywb/urlrewrite/rewriterapp.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4facc66..e37c9c1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ COPY uwsgi.ini /uwsgi/ RUN pip install gevent==1.1.2 certauth youtube-dl boto uwsgi urllib3 RUN pip install git+https://github.com/t0m/pyamf.git@python3 RUN pip install webassets pyyaml brotlipy -RUN pip install six chardet 'requests<2.12' redis jinja2 'surt>=0.3.0' webencodings +RUN pip install six chardet 'requests<2.12' redis jinja2 'surt>=0.3.0' webencodings portalocker RUN mkdir /pywb ADD . /pywb diff --git a/pywb/urlrewrite/rewriterapp.py b/pywb/urlrewrite/rewriterapp.py index 691615e7..81947f99 100644 --- a/pywb/urlrewrite/rewriterapp.py +++ b/pywb/urlrewrite/rewriterapp.py @@ -209,7 +209,8 @@ class RewriterApp(object): except (ValueError, TypeError): pass - if self.is_ajax(environ): + is_ajax = self.is_ajax(environ) + if is_ajax: head_insert_func = None urlrewriter.rewrite_opts['is_ajax'] = True else: @@ -244,11 +245,11 @@ class RewriterApp(object): if ' ' not in status_headers.statusline: status_headers.statusline += ' None' - self._add_memento_links(urlrewriter, full_prefix, memento_dt, status_headers) + if not is_ajax: + self._add_memento_links(urlrewriter, full_prefix, memento_dt, status_headers) - #if cdx['timestamp'] != wb_url.timestamp: - status_headers.headers.append(('Content-Location', urlrewriter.get_new_url(timestamp=cdx['timestamp'], - url=cdx['url']))) + status_headers.headers.append(('Content-Location', urlrewriter.get_new_url(timestamp=cdx['timestamp'], + url=cdx['url']))) #gen = buffer_iter(status_headers, gen)