def finish(self): # Prevent the socket from being closed, except for status 401 (auth needed) # TODO: if no Content-Length is specified, should close. if not self.handler.last_status.startswith('200') and self.command == 'POST': # Request was a POST but it did not succeed, so we must purge the # request body so it doesn't run into the next request. self.request.read(-1) if self.headers.get('Connection', '').lower() != 'keep-alive' or self.handler.last_status.startswith('401'): WSGIRequestHandler.finish(self)
def close(self): WSGIRequestHandler.finish(self) asyncore.dispatcher.close(self)