mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
rewrite: pass wburl mod to rewritier, so that css/js rewriting
rules may override default content-type (in cases where it is incorrect) allows for rule based cusomization (to be added later)
This commit is contained in:
parent
d2795dfdaa
commit
46449ac188
@ -54,7 +54,7 @@ class RewriteContent:
|
|||||||
|
|
||||||
def rewrite_content(self, urlrewriter, headers, stream,
|
def rewrite_content(self, urlrewriter, headers, stream,
|
||||||
head_insert_func=None, urlkey='',
|
head_insert_func=None, urlkey='',
|
||||||
sanitize_only=False, cdx=None):
|
sanitize_only=False, cdx=None, mod=None):
|
||||||
|
|
||||||
if sanitize_only:
|
if sanitize_only:
|
||||||
status_headers, stream = self.sanitize_content(headers, stream)
|
status_headers, stream = self.sanitize_content(headers, stream)
|
||||||
@ -75,6 +75,14 @@ class RewriteContent:
|
|||||||
# special case -- need to ungzip the body
|
# special case -- need to ungzip the body
|
||||||
|
|
||||||
text_type = rewritten_headers.text_type
|
text_type = rewritten_headers.text_type
|
||||||
|
|
||||||
|
# see known js/css modifier specified, the context should run
|
||||||
|
# default text_type
|
||||||
|
if mod == 'js_':
|
||||||
|
text_type = 'js'
|
||||||
|
elif mod == 'cs_':
|
||||||
|
text_type = 'css'
|
||||||
|
|
||||||
stream_raw = False
|
stream_raw = False
|
||||||
encoding = None
|
encoding = None
|
||||||
first_buff = None
|
first_buff = None
|
||||||
|
@ -98,7 +98,8 @@ class LiveRewriter(object):
|
|||||||
req_headers={},
|
req_headers={},
|
||||||
timestamp=None,
|
timestamp=None,
|
||||||
follow_redirects=False,
|
follow_redirects=False,
|
||||||
proxies=None):
|
proxies=None,
|
||||||
|
mod=None):
|
||||||
|
|
||||||
ts_err = url.split('///')
|
ts_err = url.split('///')
|
||||||
|
|
||||||
@ -135,7 +136,8 @@ class LiveRewriter(object):
|
|||||||
stream,
|
stream,
|
||||||
head_insert_func=head_insert_func,
|
head_insert_func=head_insert_func,
|
||||||
urlkey=urlkey,
|
urlkey=urlkey,
|
||||||
cdx=cdx))
|
cdx=cdx,
|
||||||
|
mod=mod))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -125,7 +125,8 @@ class ReplayView(object):
|
|||||||
head_insert_func=head_insert_func,
|
head_insert_func=head_insert_func,
|
||||||
urlkey=cdx['urlkey'],
|
urlkey=cdx['urlkey'],
|
||||||
sanitize_only=wbrequest.wb_url.is_identity,
|
sanitize_only=wbrequest.wb_url.is_identity,
|
||||||
cdx=cdx))
|
cdx=cdx,
|
||||||
|
mod=wbrequest.wb_url.mod))
|
||||||
|
|
||||||
(status_headers, response_iter, is_rewritten) = result
|
(status_headers, response_iter, is_rewritten) = result
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user