WSGI HTTP Error Status

Bot-Publishing Inc. info at botpublishing.com
Fri Jan 8 20:00:06 UTC 2021


Please ignore this question. I found the issue - it is not related to the
Nginx Unit.

On Wed, Jan 6, 2021 at 7:46 PM Bot-Publishing Inc. <info at botpublishing.com>
wrote:

> Hello,
>
> I am trying to return an  HTTP Error Status 500 under certain conditions,
> but for some reason 200 status is always returned. Although, the response
> body is correctly populated.
>
> I am using the following code (WSGI python module):
> ===================================================
> def application(environ, start_response):
>     try:
>         #... main code
>
>     except Exception as error:
>         logger.exception(error)
>
>         start_response(
>             '500',
>             [('Content-Type', 'application/json')])
>
>         resp = {"Status": 500,
>                 "Error": str(error),
>                 "ErrorType": type(error).__name__}
>
>     else:
>         start_response(
>             '200 OK', [('Content-Type', 'application/json')])
>
>         resp = {}
>         #... set response
>
>     finally:
>         resp = json.dumps(resp, indent=4).encode("utf-8")
>         yield resp
> ========================================================
>
> Would appreciate any help.
> gen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/unit/attachments/20210108/89445203/attachment.htm>


More information about the unit mailing list