Use sent instead of response_length in access log

Previously, resp.response_length is used for the b atom of the access
log formatter. If the application does not set a content-length header,
response_length is left as `None`, resulting in b being set to the
fallback "-". resp.sent is a more reliable way to determine the number
of bytes in the response body.
This commit is contained in:
Matt Long 2014-11-12 23:56:35 +00:00 committed by Berker Peksag
parent 783984cabd
commit 71f7d353f0

View File

@ -243,7 +243,7 @@ class Logger(object):
'r': "%s %s %s" % (environ['REQUEST_METHOD'],
environ['RAW_URI'], environ["SERVER_PROTOCOL"]),
's': status,
'b': resp.response_length and str(resp.response_length) or '-',
'b': resp.sent and str(resp.sent) or '-',
'f': environ.get('HTTP_REFERER', '-'),
'a': environ.get('HTTP_USER_AGENT', '-'),
'T': request_time.seconds,