Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

Commit 81c0d37

Browse files
set correct headers
1 parent 0837a4c commit 81c0d37

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

cs_proxy/proxy.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def normalize_proxy_url(url):
2525
return '{0}index.html'.format(url)
2626
return url
2727

28+
def proxy_trough_helper(url):
29+
proxy_response = requests.get(url)
30+
response.set_header('Last-Modified', proxy_response.headers['Last-Modified'])
31+
response.set_header('Content-Type', proxy_response.headers['Content-Type'])
32+
response.set_header('Expires', proxy_response.headers['Expires'])
33+
return proxy_response
34+
2835

2936
#
3037
# BOTTLE APP
@@ -50,15 +57,15 @@ def hello():
5057
return 'ok'
5158

5259

53-
@route('/<url>')
60+
@route('/<url:re:.+>')
5461
@auth_basic(check_pass)
5562
def proxy_trough(url):
56-
return requests.get('{0}{1}'.format(args.githubPagesUrl, normalize_proxy_url(url)))
63+
return proxy_trough_helper('{0}{1}'.format(args.githubPagesUrl, normalize_proxy_url(url)))
5764

5865
@route('/')
5966
@auth_basic(check_pass)
6067
def proxy_trough_root_page():
61-
return requests.get('{0}{1}'.format(args.githubPagesUrl, '/index.html'))
68+
return proxy_trough_helper('{0}{1}'.format(args.githubPagesUrl, '/index.html'))
6269

6370

6471
#

0 commit comments

Comments
 (0)