1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +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:
Ilya Kreymer 2014-05-05 22:12:45 -07:00
parent d2795dfdaa
commit 46449ac188
3 changed files with 15 additions and 4 deletions

View File

@ -54,7 +54,7 @@ class RewriteContent:
def rewrite_content(self, urlrewriter, headers, stream,
head_insert_func=None, urlkey='',
sanitize_only=False, cdx=None):
sanitize_only=False, cdx=None, mod=None):
if sanitize_only:
status_headers, stream = self.sanitize_content(headers, stream)
@ -75,6 +75,14 @@ class RewriteContent:
# special case -- need to ungzip the body
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
encoding = None
first_buff = None

View File

@ -98,7 +98,8 @@ class LiveRewriter(object):
req_headers={},
timestamp=None,
follow_redirects=False,
proxies=None):
proxies=None,
mod=None):
ts_err = url.split('///')
@ -135,7 +136,8 @@ class LiveRewriter(object):
stream,
head_insert_func=head_insert_func,
urlkey=urlkey,
cdx=cdx))
cdx=cdx,
mod=mod))
return result

View File

@ -125,7 +125,8 @@ class ReplayView(object):
head_insert_func=head_insert_func,
urlkey=cdx['urlkey'],
sanitize_only=wbrequest.wb_url.is_identity,
cdx=cdx))
cdx=cdx,
mod=wbrequest.wb_url.mod))
(status_headers, response_iter, is_rewritten) = result