mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
rewrite: fix header rewrite test
proxy_pac: use http host header if available for proxy host
This commit is contained in:
parent
407da7528b
commit
f5c27d7b06
@ -300,8 +300,7 @@ class ProxyRouter(object):
|
|||||||
|
|
||||||
# Proxy Auto-Config (PAC) script for the proxy
|
# Proxy Auto-Config (PAC) script for the proxy
|
||||||
def make_pac_response(self, env):
|
def make_pac_response(self, env):
|
||||||
import os
|
hostname = env.get('HTTP_HOST')
|
||||||
hostname = os.environ.get('PYWB_HOST_NAME')
|
|
||||||
if not hostname:
|
if not hostname:
|
||||||
server_hostport = env['SERVER_NAME'] + ':' + env['SERVER_PORT']
|
server_hostport = env['SERVER_NAME'] + ':' + env['SERVER_PORT']
|
||||||
hostonly = env['SERVER_NAME']
|
hostonly = env['SERVER_NAME']
|
||||||
@ -319,7 +318,6 @@ class ProxyRouter(object):
|
|||||||
|
|
||||||
buff += direct.format(hostonly)
|
buff += direct.format(hostonly)
|
||||||
|
|
||||||
#buff += '\n return "PROXY {0}";\n}}\n'.format(self.hostpaths[0])
|
|
||||||
buff += '\n return "PROXY {0}";\n}}\n'.format(server_hostport)
|
buff += '\n return "PROXY {0}";\n}}\n'.format(server_hostport)
|
||||||
|
|
||||||
content_type = 'application/x-ns-proxy-autoconfig'
|
content_type = 'application/x-ns-proxy-autoconfig'
|
||||||
|
@ -40,17 +40,19 @@ HTTP Headers Rewriting
|
|||||||
'removed_header_dict': {'content-encoding': 'gzip',
|
'removed_header_dict': {'content-encoding': 'gzip',
|
||||||
'transfer-encoding': 'chunked'},
|
'transfer-encoding': 'chunked'},
|
||||||
'status_headers': StatusAndHeaders(protocol = '', statusline = '200 OK', headers = [ ('X-Archive-Orig-Content-Length', '199999'),
|
'status_headers': StatusAndHeaders(protocol = '', statusline = '200 OK', headers = [ ('X-Archive-Orig-Content-Length', '199999'),
|
||||||
('Content-Type', 'text/javascript')]),
|
('Content-Type', 'text/javascript'),
|
||||||
|
('X-Archive-Orig-Transfer-Encoding', 'chunked')]),
|
||||||
'text_type': 'js'}
|
'text_type': 'js'}
|
||||||
|
|
||||||
# Binary -- transfer-encoding removed
|
# Binary -- transfer-encoding rewritten
|
||||||
>>> _test_headers([('Content-Length', '200000'), ('Content-Type', 'image/png'), ('Set-Cookie', 'foo=bar; Path=/;'), ('Content-Encoding', 'gzip'), ('Transfer-Encoding', 'chunked')])
|
>>> _test_headers([('Content-Length', '200000'), ('Content-Type', 'image/png'), ('Set-Cookie', 'foo=bar; Path=/;'), ('Content-Encoding', 'gzip'), ('Transfer-Encoding', 'chunked')])
|
||||||
{'charset': None,
|
{'charset': None,
|
||||||
'removed_header_dict': {'transfer-encoding': 'chunked'},
|
'removed_header_dict': {'transfer-encoding': 'chunked'},
|
||||||
'status_headers': StatusAndHeaders(protocol = '', statusline = '200 OK', headers = [ ('Content-Length', '200000'),
|
'status_headers': StatusAndHeaders(protocol = '', statusline = '200 OK', headers = [ ('Content-Length', '200000'),
|
||||||
('Content-Type', 'image/png'),
|
('Content-Type', 'image/png'),
|
||||||
('Set-Cookie', 'foo=bar; Path=/web/20131010/http://example.com/'),
|
('Set-Cookie', 'foo=bar; Path=/web/20131010/http://example.com/'),
|
||||||
('Content-Encoding', 'gzip')]),
|
('Content-Encoding', 'gzip'),
|
||||||
|
('X-Archive-Orig-Transfer-Encoding', 'chunked')]),
|
||||||
'text_type': None}
|
'text_type': None}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user