mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fixing zero bytes case in atoms access log
This commit is contained in:
parent
587dc630cc
commit
0af5641117
1
.cache/v/cache/lastfailed
vendored
Normal file
1
.cache/v/cache/lastfailed
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
@ -299,7 +299,7 @@ class Logger(object):
|
|||||||
'U': environ.get('PATH_INFO'),
|
'U': environ.get('PATH_INFO'),
|
||||||
'q': environ.get('QUERY_STRING'),
|
'q': environ.get('QUERY_STRING'),
|
||||||
'H': environ.get('SERVER_PROTOCOL'),
|
'H': environ.get('SERVER_PROTOCOL'),
|
||||||
'b': getattr(resp, 'sent', None) and str(resp.sent) or '-',
|
'b': getattr(resp, 'sent', None) is not None and str(resp.sent) or '-',
|
||||||
'B': getattr(resp, 'sent', None),
|
'B': getattr(resp, 'sent', None),
|
||||||
'f': environ.get('HTTP_REFERER', '-'),
|
'f': environ.get('HTTP_REFERER', '-'),
|
||||||
'a': environ.get('HTTP_USER_AGENT', '-'),
|
'a': environ.get('HTTP_USER_AGENT', '-'),
|
||||||
|
|||||||
@ -31,6 +31,23 @@ def test_atoms_defaults():
|
|||||||
assert atoms['{content-type}o'] == 'application/json'
|
assert atoms['{content-type}o'] == 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
def test_atoms_zero_bytes():
|
||||||
|
response = SimpleNamespace(
|
||||||
|
status='200', response_length=0,
|
||||||
|
headers=(('Content-Type', 'application/json'),), sent=0,
|
||||||
|
)
|
||||||
|
request = SimpleNamespace(headers=(('Accept', 'application/json'),))
|
||||||
|
environ = {
|
||||||
|
'REQUEST_METHOD': 'GET', 'RAW_URI': '/my/path?foo=bar',
|
||||||
|
'PATH_INFO': '/my/path', 'QUERY_STRING': 'foo=bar',
|
||||||
|
'SERVER_PROTOCOL': 'HTTP/1.1',
|
||||||
|
}
|
||||||
|
logger = Logger(Config())
|
||||||
|
atoms = logger.atoms(response, request, environ, datetime.timedelta(seconds=1))
|
||||||
|
assert atoms['b'] == '0'
|
||||||
|
assert atoms['B'] == 0
|
||||||
|
|
||||||
|
|
||||||
def test_get_username_from_basic_auth_header():
|
def test_get_username_from_basic_auth_header():
|
||||||
request = SimpleNamespace(headers=())
|
request = SimpleNamespace(headers=())
|
||||||
response = SimpleNamespace(
|
response = SimpleNamespace(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user