From 1d326f88c4596adb780c4c2cf0bc10b810d135f1 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 23 Mar 2010 15:54:22 -0400 Subject: [PATCH] Fixed async responses. --- gunicorn/async/base.py | 2 +- gunicorn/http/response.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gunicorn/async/base.py b/gunicorn/async/base.py index 18d04a40..029a0fb5 100644 --- a/gunicorn/async/base.py +++ b/gunicorn/async/base.py @@ -26,7 +26,7 @@ class KeepaliveResponse(http.Response): return [ "HTTP/1.1 %s\r\n" % self.status, - "Server: %s\r\n" % self.SERVER_VERSION, + "Server: %s\r\n" % self.version, "Date: %s\r\n" % util.http_date(), "Connection: %s\r\n" % connection_hdr ] diff --git a/gunicorn/http/response.py b/gunicorn/http/response.py index 2f197d4b..7a1fafe6 100644 --- a/gunicorn/http/response.py +++ b/gunicorn/http/response.py @@ -24,15 +24,18 @@ class Response(object): self.chunked = True self.headers.append((name.strip(), value.strip())) + def default_headers(self): + return [ + "HTTP/1.1 %s\r\n" % self.status, + "Server: %s\r\n" % self.SERVER_VERSION, + "Date: %s\r\n" % util.http_date(), + "Connection: close\r\n" + ] + def send_headers(self): if self.headers_sent: return - tosend = [ - "HTTP/1.1 %s\r\n" % self.status, - "Server: %s\r\n" % self.version, - "Date: %s\r\n" % http_date(), - "Connection: close\r\n" - ] + tosend = self.default_headers() tosend.extend(["%s: %s\r\n" % (n, v) for n, v in self.headers]) write(self.req.socket, "%s\r\n" % "".join(tosend)) self.headers_sent = True