forked from oldweb-today/netcapsule
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
www: override info.cern.ch and cernvax.cern.ch to allow for loading d…
…efault.html from proxy server! proxy serves default.html and rewritten content from pywb, filtering out most headers to avoid breaking browser add icon for www pywb: use blank header, /all/ endpoint app: set default dims to 1024x768, add per-browser override configurable in config.yaml addresses oldweb-today#20
- Loading branch information
Showing
12 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from bottle import request, route, HTTPResponse, run | ||
from argparse import ArgumentParser | ||
|
||
import requests | ||
|
||
pywb_prefix = 'localhost' | ||
proxy_host = '10.0.2.2' | ||
start_ts = '1990' | ||
start_url = '' | ||
|
||
ALLOWED_HEADERS = ('content-type', 'content-length', 'location', 'date', | ||
'last-modified', 'set-cookie', 'server', 'content-encoding') | ||
|
||
@route('/default.html') | ||
def do_default(): | ||
return do_proxy(start_ts + '/' + start_url) | ||
|
||
|
||
@route('/all/<url:re:.*>') | ||
def do_proxy(url): | ||
headers = {'User-Agent': request.environ.get('HTTP_USER_AGENT'), | ||
'Host': proxy_host, | ||
'Accept-Encoding': 'identity', | ||
} | ||
|
||
r = requests.get(url=pywb_prefix + url, headers=headers, | ||
stream=True, | ||
allow_redirects=False) | ||
|
||
resp_headers = [] | ||
for n, v in r.headers.iteritems(): | ||
if n == 'content-type': | ||
v = v.split(';')[0].strip() | ||
|
||
if n.lower() in ALLOWED_HEADERS: | ||
resp_headers.append((n, v)) | ||
|
||
resp = HTTPResponse(body=r.iter_content(8192), | ||
status=str(r.status_code) + ' ' + r.reason, | ||
headers=resp_headers) | ||
|
||
return resp | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = ArgumentParser('netcapsule http1.0 proxy') | ||
parser.add_argument('--pywb-prefix') | ||
parser.add_argument('--start-url') | ||
parser.add_argument('--start-ts') | ||
parser.add_argument('--port', type=int) | ||
|
||
r = parser.parse_args() | ||
|
||
global pywb_prefix | ||
pywb_prefix = r.pywb_prefix | ||
|
||
global start_ts | ||
start_ts = r.start_ts | ||
|
||
global start_url | ||
start_url = r.start_url | ||
|
||
port = r.port or 8081 | ||
|
||
run(host='0.0.0.0', port=port) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.