Upon executing self.write_error(401), the connection is not terminated, but proceeds to next line. This is not the expected behavior. Can anyone confirm.
The underlying socket is closed by write_error, but the following lines of code are executed anyway. write_error() does not cause the calling method (your code) to terminate. This is expected. You can do things like write log messages, etc., after sending your response to the client.
The underlying socket shouldn't be closed, assuming the client is using HTTP 1.1. The connection will be kept alive for future requests unless the client closes the connection. This is also expected.
Ah, thanks, didn't notice that in the code.
Thanks. Will try it and revert if any questions.