Skip to content
Snippets Groups Projects
Commit ac6b8e7a authored by godog's avatar godog
Browse files

default Content-Type handling and Content-Length

parent 8b802ba3
No related branches found
No related tags found
No related merge requests found
...@@ -60,14 +60,17 @@ def passthrough(w, key, req, cache=True): ...@@ -60,14 +60,17 @@ def passthrough(w, key, req, cache=True):
copyfd(e, w.wfile) copyfd(e, w.wfile)
return return
w.send_response(200) w.send_response(200)
w.send_header('Content-Type', resp.headers['Content-Type']) w.send_header('Content-Type', resp.headers.get('Content-Type',
'application/octect-stream'))
if 'Content-Length' in resp.headers:
w.send_header('Content-Length', resp.headers['Content-Length']) w.send_header('Content-Length', resp.headers['Content-Length'])
w.end_headers() w.end_headers()
if not cache: if not cache:
copyfd(resp, w.wfile) copyfd(resp, w.wfile)
else: else:
with open(cache_path(key, 'ctype'), 'w') as fd: with open(cache_path(key, 'ctype'), 'w') as fd:
fd.write('%s\n' % resp.headers['Content-Type']) fd.write('%s\n' % resp.headers.get('Content-Type',
'application/octect-stream'))
with open(cache_path(key), 'w') as fd: with open(cache_path(key), 'w') as fd:
copyfd(resp, fd, w.wfile) copyfd(resp, fd, w.wfile)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment