@route('/download')
def download():
    (browser_type, archive, url) = get_params()
    response_key = get_cache_key(archive, browser_type, url)
    result = rc.get(response_key)
    if (not result):
        raise HTTPError(status=404, body='Url Not Archived')
    result = json.loads(result)
    if (not ('download_url' in result)):
        raise HTTPError(status=404, body='Download Not Available')
    headers = {}
    session = result.get('download_session')
    if session:
        headers['Cookie'] = session
    r = requests.get(result['download_url'], headers=headers, stream=True)
    if (r.status_code != 200):
        raise HTTPError(status=400, body='Invalid Download Result: {0} {1}'.format(r.status_code, r.reason))
    pass_headers = ('Content-Disposition', 'Content-Length', 'Content-Type')
    for h in pass_headers:
        response.set_header(h, r.headers.get(h))
    response.body = r.iter_content()
    return response
@route('/download')
def download():
    (browser_type, archive, url) = get_params()
    response_key = get_cache_key(archive, browser_type, url)
    result = rc.get(response_key)
    if (not result):
        raise HTTPError(status=404, body='Url Not Archived')
    result = json.loads(result)
    if (not ('download_url' in result)):
        raise HTTPError(status=404, body='Download Not Available')
    headers = {}
    session = result.get('download_session')
    if session:
        headers['Cookie'] = session
    r = requests.get(result['download_url'], headers=headers, stream=True)
    if (r.status_code != 200):
        raise HTTPError(status=400, body='Invalid Download Result: {0} {1}'.format(r.status_code, r.reason))
    pass_headers = ('Content-Disposition', 'Content-Length', 'Content-Type')
    for h in pass_headers:
        response.set_header(h, r.headers.get(h))
    response.body = r.iter_content()
    return response