Move Warcprox-Meta header construction to warcproxy

This commit is contained in:
Vangelis Banos 2017-11-02 08:24:28 +00:00
parent 56f0118374
commit ca3121102e
2 changed files with 4 additions and 3 deletions

View File

@ -172,8 +172,8 @@ class ProxyingRecordingHTTPResponse(http_client.HTTPResponse):
self.msg['Via'] = via_header_value(
self.msg.get('Via'), '%0.1f' % (self.version / 10.0))
if extra_response_headers:
rmeta = {"capture-metadata": extra_response_headers}
self.msg['Warcprox-Meta'] = json.dumps(rmeta, separators=',:')
for header, value in extra_response_headers.items():
self.msg[header] = value
for k,v in self.msg.items():
if k.lower() not in (

View File

@ -182,7 +182,8 @@ class WarcProxyHandler(warcprox.mitmproxy.MitmProxyHandler):
extra_response_headers = {}
if warcprox_meta and 'accept' in warcprox_meta and \
'capture-metadata' in warcprox_meta['accept']:
extra_response_headers['timestamp'] = timestamp.strftime('%Y-%m-%dT%H:%M:%SZ')
rmeta = {'capture-metadata': {'timestamp': timestamp.strftime('%Y-%m-%dT%H:%M:%SZ')}}
extra_response_headers['Warcprox-Meta'] = json.dumps(rmeta, separators=',:')
req, prox_rec_res = warcprox.mitmproxy.MitmProxyHandler._proxy_request(
self, extra_response_headers=extra_response_headers)