Fix response header parsing in python3

This commit is contained in:
Gavin M. Roy 2016-09-13 22:00:12 -04:00
parent 080a480ff7
commit a22c66fda5

View file

@ -73,7 +73,7 @@ class InfluxDBMixin(object):
handler = '{}.{}'.format(self.__module__, self.__class__.__name__)
self.influxdb.set_tags({'handler': handler, 'method': request.method})
if request.headers.get('Accept'):
accept = request.headers['Accept'].split(';')[0].strip()
accept = request.headers.get('Accept').split(';')[0].strip()
self.influxdb.set_tag('accept', accept)
for host, handlers in application.handlers:
if not host.match(request.host):
@ -89,8 +89,8 @@ class InfluxDBMixin(object):
if hasattr(self, 'correlation_id'):
self.influxdb.set_tag('correlation_id', self.correlation_id)
self.influxdb.set_tag('status_code', self._status_code)
content_type = self._headers['Content-Type'].split(';')[0].strip()
self.influxdb.set_tag('content_type', content_type)
ctype = self._headers['Content-Type'].decode('utf-8')
self.influxdb.set_tag('content_type', ctype.split(';')[0].strip())
self.influxdb.set_field('duration', self.request.request_time())
self.influxdb.set_field('content_length',
int(self._headers['Content-Length']))