Fixed proxy logging.
It wasn't logging the full path, depending on if WebOb's path_info_pop had been called. Change-Id: I612d4cae7a4dc1bf5164356af329496245ad85dc
This commit is contained in:
parent
0d38c710a5
commit
7923c56afa
@ -117,7 +117,7 @@ class ProxyLoggingMiddleware(object):
|
||||
req = Request(env)
|
||||
if client_disconnect: # log disconnected clients as '499' status code
|
||||
status_int = 499
|
||||
req_path = get_valid_utf8_str(env.get('PATH_INFO', ''))
|
||||
req_path = get_valid_utf8_str(req.path)
|
||||
the_request = quote(unquote(req_path))
|
||||
if req.query_string:
|
||||
the_request = the_request + '?' + req.query_string
|
||||
|
@ -245,6 +245,22 @@ class TestProxyLogging(unittest.TestCase):
|
||||
resp = app(req.environ, start_response)
|
||||
body = ''.join(resp)
|
||||
|
||||
def test_req_path_info_popping(self):
|
||||
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank('/v1/something', environ={'REQUEST_METHOD': 'GET'})
|
||||
req.path_info_pop()
|
||||
self.assertEquals(req.environ['PATH_INFO'], '/something')
|
||||
resp = app(req.environ, start_response)
|
||||
resp_body = ''.join(resp)
|
||||
log_parts = app.access_logger.msg.split()
|
||||
self.assertEquals(log_parts[3], 'GET')
|
||||
self.assertEquals(log_parts[4], '/v1/something')
|
||||
self.assertEquals(log_parts[5], 'HTTP/1.0')
|
||||
self.assertEquals(log_parts[6], '200')
|
||||
self.assertEquals(resp_body, 'FAKE APP')
|
||||
self.assertEquals(log_parts[11], str(len(resp_body)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user