From 4f54c06121494c68421381798fb88680423330a4 Mon Sep 17 00:00:00 2001 From: benoitc Date: Fri, 26 Mar 2010 15:53:53 +0100 Subject: [PATCH] make specific case for websockets --- gunicorn/http/response.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gunicorn/http/response.py b/gunicorn/http/response.py index 33f69685..002f191a 100644 --- a/gunicorn/http/response.py +++ b/gunicorn/http/response.py @@ -17,12 +17,19 @@ class Response(object): for name, value in headers: assert isinstance(name, basestring), "%r is not a string" % name - assert isinstance(value, basestring), "%r is not a string" % value - assert not is_hoppish(name), "%s is a hop-by-hop header." % name - if name.lower().strip() == "transfer-encoding": - if value.lower().strip() == "chunked": - self.chunked = True - self.headers.append((name.strip(), value.strip())) + if is_hoppish(name): + lname = name.lower().strip() + if lname == "transfer-encoding": + if value.lower().strip() == "chunked": + self.chunked = True + elif lname == "connection": + # handle websocket + if value.lower().strip() != "upgrade": + continue + else: + # ignore hopbyhop headers + continue + self.headers.append((name.strip(), str(value).strip())) def default_headers(self): return [