<div dir="ltr">Please ignore this question. I found the issue - it is not related to the Nginx Unit.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 6, 2021 at 7:46 PM Bot-Publishing Inc. <<a href="mailto:info@botpublishing.com">info@botpublishing.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<br><div><br></div><div>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.</div><div><br></div><div>I am using the following code (WSGI python module):</div><div>===================================================</div><div>def application(environ, start_response):<br> try:<br> #... main code<br><br> except Exception as error:<br> logger.exception(error)<br> <br> start_response(<br> '500',<br> [('Content-Type', 'application/json')])<br><br> resp = {"Status": 500,<br> "Error": str(error),<br> "ErrorType": type(error).__name__}<br><br> else:<br> start_response(<br> '200 OK', [('Content-Type', 'application/json')])<br><br> resp = {}<br> #... set response<br> <br> finally:<br> resp = json.dumps(resp, indent=4).encode("utf-8")<br> yield resp<br></div><div>========================================================</div><div><br></div><div>Would appreciate any help.</div><div>gen</div></div>
</blockquote></div>