mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
wbrequest: add options dictionary to store misc request options
This commit is contained in:
parent
fa813bdd19
commit
a2973b04e7
@ -11,15 +11,13 @@ LINK_FORMAT = 'application/link-format'
|
||||
#=================================================================
|
||||
class MementoReqMixin(object):
|
||||
def _parse_extra(self):
|
||||
self.is_timegate = False
|
||||
|
||||
if not self.wb_url:
|
||||
return
|
||||
|
||||
if self.wb_url.type != self.wb_url.LATEST_REPLAY:
|
||||
return
|
||||
|
||||
self.is_timegate = True
|
||||
self.options['is_timegate'] = True
|
||||
|
||||
accept_datetime = self.env.get('HTTP_ACCEPT_DATETIME')
|
||||
if not accept_datetime:
|
||||
@ -48,7 +46,7 @@ class MementoRespMixin(object):
|
||||
if not wbrequest or not wbrequest.wb_url:
|
||||
return
|
||||
|
||||
is_timegate = wbrequest.is_timegate
|
||||
is_timegate = wbrequest.options.get('is_timegate', False)
|
||||
|
||||
if is_timegate:
|
||||
self.status_headers.headers.append(('Vary', 'accept-datetime'))
|
||||
@ -59,7 +57,7 @@ class MementoRespMixin(object):
|
||||
is_memento = False
|
||||
|
||||
# otherwise, if in proxy mode, then always a memento
|
||||
elif wbrequest.is_proxy:
|
||||
elif wbrequest.options['is_proxy']:
|
||||
is_memento = True
|
||||
|
||||
# otherwise only for replay
|
||||
@ -80,7 +78,7 @@ class MementoRespMixin(object):
|
||||
link.append(self.make_link(req_url, 'original'))
|
||||
|
||||
# for now, include timemap only in non-proxy mode
|
||||
if not wbrequest.is_proxy and (is_memento or is_timegate):
|
||||
if not wbrequest.options['is_proxy'] and (is_memento or is_timegate):
|
||||
link.append(self.make_timemap_link(wbrequest))
|
||||
|
||||
if is_memento and not is_timegate:
|
||||
|
@ -78,12 +78,11 @@ class WbRequest(object):
|
||||
|
||||
self.referrer = env.get('HTTP_REFERER')
|
||||
|
||||
self.is_ajax = self._is_ajax()
|
||||
self.options = dict()
|
||||
self.options['is_ajax'] = self._is_ajax()
|
||||
self.options['is_proxy'] = is_proxy
|
||||
|
||||
self.query_filter = []
|
||||
|
||||
self.is_proxy = is_proxy
|
||||
|
||||
self.custom_params = {}
|
||||
|
||||
# PERF
|
||||
|
@ -8,8 +8,6 @@ from pywb.utils.loaders import BlockLoader
|
||||
from pywb.framework.basehandlers import BaseHandler, WbUrlHandler
|
||||
from pywb.framework.wbrequestresponse import WbResponse
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
#=================================================================
|
||||
# Standard WB Handler
|
||||
|
@ -66,8 +66,9 @@ class BaseContentView(object):
|
||||
# render top level frame if in frame mode
|
||||
# (not supported in proxy mode)
|
||||
if (self.is_frame_mode and
|
||||
not wbrequest.is_proxy and
|
||||
not wbrequest.wb_url.mod):
|
||||
not wbrequest.wb_url.mod and
|
||||
not wbrequest.options['is_proxy'] and
|
||||
not wbrequest.options.get('is_timegate', False)):
|
||||
|
||||
embed_url = wbrequest.wb_url.to_str(mod=self._mp_mod)
|
||||
timestamp = datetime_to_timestamp(datetime.datetime.utcnow())
|
||||
@ -259,12 +260,10 @@ class ReplayView(BaseContentView):
|
||||
return content
|
||||
|
||||
def _redirect_if_needed(self, wbrequest, cdx):
|
||||
if wbrequest.is_proxy:
|
||||
if wbrequest.options['is_proxy']:
|
||||
return None
|
||||
|
||||
# todo: generalize this?
|
||||
redir_needed = (hasattr(wbrequest, 'is_timegate') and
|
||||
wbrequest.is_timegate)
|
||||
redir_needed = (wbrequest.options.get('is_timegate', False))
|
||||
|
||||
if not redir_needed and self.redir_to_exact:
|
||||
redir_needed = (cdx['timestamp'] != wbrequest.wb_url.timestamp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user