mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
proxy: add custom rewrite prefix in proxy mode with 'pywb-proxy-rewrite: prefix' header
This commit is contained in:
parent
0cf6b40af9
commit
ba19ff1cd5
@ -9,7 +9,7 @@ import base64
|
||||
import socket
|
||||
import ssl
|
||||
|
||||
from pywb.rewrite.url_rewriter import SchemeOnlyUrlRewriter
|
||||
from pywb.rewrite.url_rewriter import SchemeOnlyUrlRewriter, UrlRewriter
|
||||
from pywb.rewrite.rewrite_content import RewriteContent
|
||||
from pywb.utils.wbexception import BadRequestException
|
||||
|
||||
@ -193,9 +193,18 @@ class ProxyRouter(object):
|
||||
if response:
|
||||
return response
|
||||
|
||||
host_prefix = env['pywb.proxy_scheme'] + '://' + self.magic_name
|
||||
rel_prefix = ''
|
||||
|
||||
custom_prefix = env.get('HTTP_PYWB_REWRITE_PREFIX', '')
|
||||
if custom_prefix:
|
||||
host_prefix = custom_prefix
|
||||
urlrewriter_class = UrlRewriter
|
||||
abs_prefix = True
|
||||
else:
|
||||
host_prefix = env['pywb.proxy_scheme'] + '://' + self.magic_name
|
||||
urlrewriter_class = SchemeOnlyUrlRewriter
|
||||
abs_prefix = False
|
||||
|
||||
# special case for proxy calendar
|
||||
if (env['pywb.proxy_host'] == 'query.' + self.magic_name):
|
||||
url = env['pywb.proxy_req_uri'][1:]
|
||||
@ -211,8 +220,8 @@ class ProxyRouter(object):
|
||||
host_prefix=host_prefix,
|
||||
rel_prefix=rel_prefix,
|
||||
wburl_class=route.handler.get_wburl_type(),
|
||||
urlrewriter_class=SchemeOnlyUrlRewriter,
|
||||
use_abs_prefix=False,
|
||||
urlrewriter_class=urlrewriter_class,
|
||||
use_abs_prefix=abs_prefix,
|
||||
is_proxy=True)
|
||||
|
||||
if matcher:
|
||||
|
Loading…
x
Reference in New Issue
Block a user