Support swift.proxy_logging_status in request env

When logging a request, if the request environ has a
swift.proxy_logging_status item then use its value for the log
message status int.

The swift.proxy_logging_status hint may be used by other middlewares
when the desired logged status is different from the wire_status_int.

If the proxy_logging middleware detects a client disconnect then any
swift.proxy_logging_status item is ignored and a 499 status int is
logged, as per current behaviour. i.e.:

  * client disconnect overrides swift.proxy_logging_status and the
    response status
  * swift.proxy_logging_status overrides the response status

If the proxy_logging middleware catches an exception then the logged
status int will be 500 regardless of any swift.proxy_logging_status
item.

Co-Authored-By: Alistair Coles <alistairncoles@gmail.com>
Change-Id: I9b5cc6d5fb69a2957b8c4846ce1feed8c115e6b6
This commit is contained in:
Clay Gerrard
2021-04-05 13:00:24 -05:00
committed by ASHWIN A NAIR
parent 365db20275
commit 5af7719ef3
3 changed files with 173 additions and 27 deletions

View File

@@ -198,6 +198,13 @@ filter factory::
return webhook_filter
Middlewares can override the status integer that is logged by proxy_logging
middleware by setting ``swift.proxy_logging_status`` in the request WSGI
environment. The value should be an integer. The value will replace the default
status integer in the log message, unless the proxy_logging middleware detects
a client disconnect or exception while handling the request, in which case
``swift.proxy_logging_status`` is overridden by a 499 or 500 respectively.
--------------
Swift Metadata
--------------