handle keepalive = 0

Keepalive=0 means that we aren't waiting for the next connection. So
make sure to send appropriate "close" header and that we handle the first
connection.
This commit is contained in:
benoitc 2012-07-04 09:34:12 +02:00
parent cdd3e1dc2b
commit 5615464923

View File

@ -30,6 +30,11 @@ class AsyncWorker(base.Worker):
try: try:
parser = http.RequestParser(self.cfg, client) parser = http.RequestParser(self.cfg, client)
try: try:
if not self.cfg.keepalive:
req = parser.next()
self.handle_request(req, client, addr)
else:
# keepalive loop
while True: while True:
req = None req = None
with self.timeout_ctx(): with self.timeout_ctx():
@ -66,6 +71,10 @@ class AsyncWorker(base.Worker):
self.log.info("Autorestarting worker after current request.") self.log.info("Autorestarting worker after current request.")
resp.force_close() resp.force_close()
self.alive = False self.alive = False
if not self.cfg.keepalive:
resp.force_close()
respiter = self.wsgi(environ, resp.start_response) respiter = self.wsgi(environ, resp.start_response)
if respiter == ALREADY_HANDLED: if respiter == ALREADY_HANDLED:
return False return False