From: Ben Darnell Date: Thu, 20 Jan 2011 19:59:45 +0000 (-0800) Subject: Set HTTPRequest.protocol correctly when using the built-in SSL support. X-Git-Tag: v1.2.0~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=377c160a1596efc4a406942c28835754e5bd1e8c;p=thirdparty%2Ftornado.git Set HTTPRequest.protocol correctly when using the built-in SSL support. Closes #202. --- diff --git a/tornado/httpserver.py b/tornado/httpserver.py index b3725de0b..3788ede15 100644 --- a/tornado/httpserver.py +++ b/tornado/httpserver.py @@ -459,7 +459,12 @@ class HTTPRequest(object): self.protocol = "http" else: self.remote_ip = remote_ip - self.protocol = protocol or "http" + if protocol: + self.protocol = protocol + elif isinstance(connection.stream, iostream.SSLIOStream): + self.protocol = "https" + else: + self.protocol = "http" self.host = host or self.headers.get("Host") or "127.0.0.1" self.files = files or {} self.connection = connection diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index 44a38b379..687cd07f1 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -18,6 +18,7 @@ except ImportError: class HelloWorldRequestHandler(RequestHandler): def get(self): + assert self.request.protocol == "https" self.finish("Hello world") def post(self):