From 1d5b23413f62fd730ed55ee634f569df59861e25 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Tue, 23 Feb 2016 18:09:09 -0800 Subject: [PATCH] proxy: ensure proxy cert download sets content length proxy options: 'use_default_coll' must specify exact default coll (otherwise a random coll is chosen, as ordering is not defined) travis: add py3.4, py3.5! --- .travis.yml | 3 +++ pywb/framework/proxy.py | 8 ++++++-- pywb/framework/proxy_resolvers.py | 9 +++++---- tests/test_config.yaml | 2 +- tests/test_config_memento.yaml | 1 + 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3ddcdff5..9c02ee8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ language: python python: - "2.6" - "2.7" + - "3.3" + - "3.4" + - "3.5" os: - linux diff --git a/pywb/framework/proxy.py b/pywb/framework/proxy.py index 1822321f..6b1cc739 100644 --- a/pywb/framework/proxy.py +++ b/pywb/framework/proxy.py @@ -441,9 +441,11 @@ class ProxyRouter(object): buff = fh.read() content_type = 'application/x-x509-ca-cert' + headers = [('Content-Length', str(len(buff)))] return WbResponse.bin_stream([buff], - content_type=content_type) + content_type=content_type, + headers=headers) elif env['pywb.proxy_req_uri'] == self.CERT_DL_P12: if not self.ca: @@ -452,6 +454,8 @@ class ProxyRouter(object): buff = self.ca.get_root_PKCS12() content_type = 'application/x-pkcs12' + headers = [('Content-Length', str(len(buff)))] return WbResponse.bin_stream([buff], - content_type=content_type) + content_type=content_type, + headers=headers) diff --git a/pywb/framework/proxy_resolvers.py b/pywb/framework/proxy_resolvers.py index fbae3073..880cbc1c 100644 --- a/pywb/framework/proxy_resolvers.py +++ b/pywb/framework/proxy_resolvers.py @@ -21,7 +21,7 @@ import json class BaseCollResolver(object): def __init__(self, routes, config): self.routes = routes - self.use_default_coll = config.get('use_default_coll', True) + self.use_default_coll = config.get('use_default_coll') @property def pre_connect(self): @@ -58,9 +58,10 @@ class BaseCollResolver(object): # if 'use_default_coll', find first WbUrl-handling collection elif self.use_default_coll: - for route in self.routes: - if isinstance(route.handler, WbUrlHandler): - return route, route.path, matcher, ts, None + raise Exception('use_default_coll: true no longer supported, please specify collection name') + #for route in self.routes: + # if isinstance(route.handler, WbUrlHandler): + # return route, route.path, matcher, ts, None # otherwise, return the appropriate coll selection response else: diff --git a/tests/test_config.yaml b/tests/test_config.yaml index 6df347f1..85bd12be 100644 --- a/tests/test_config.yaml +++ b/tests/test_config.yaml @@ -114,7 +114,7 @@ enable_http_proxy: true # Additional proxy options (defaults) proxy_options: - use_default_coll: true + use_default_coll: pywb cookie_resolver: false diff --git a/tests/test_config_memento.yaml b/tests/test_config_memento.yaml index 79a31fe9..b8ef9947 100644 --- a/tests/test_config_memento.yaml +++ b/tests/test_config_memento.yaml @@ -22,6 +22,7 @@ enable_http_proxy: true proxy_options: use_banner: false use_client_rewrite: false + use_default_coll: pywb # enable cdx server api for timemap enable_cdx_api: true