From 613378529bb3da90b1766f5ebf8837d33d9539a6 Mon Sep 17 00:00:00 2001 From: benoitc Date: Mon, 20 Feb 2012 06:03:23 +0100 Subject: [PATCH] close #297 . When the path starts with //, urlsplit considers it as a relative uri while the RDF says it shouldnt ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2). While I'm remove unncessary tests on netloc. The path never contains a netloc or port. --- gunicorn/http/message.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gunicorn/http/message.py b/gunicorn/http/message.py index 565e71bd..77e21b3b 100644 --- a/gunicorn/http/message.py +++ b/gunicorn/http/message.py @@ -102,9 +102,6 @@ class Request(Message): self.method = None self.uri = None - self.scheme = None - self.host = None - self.port = 80 self.path = None self.query = None self.fragment = None @@ -166,15 +163,17 @@ class Request(Message): self.method = bits[0].upper() # URI - self.uri = bits[1] - parts = urlparse.urlsplit(bits[1]) - self.scheme = parts.scheme or '' - self.host = parts.netloc or None - if parts.port is None: - self.port = 80 + # When the path starts with //, urlsplit considers it as a + # relative uri while the RDF says it shouldnt + # http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 + # considers it as an absolute url. + # fix issue #297 + if bits[1].startswith("//"): + self.uri = bits[1][1:] else: - self.host = self.host.rsplit(":", 1)[0] - self.port = parts.port + self.uri = bits[1] + + parts = urlparse.urlsplit(self.uri) self.path = parts.path or "" self.query = parts.query or "" self.fragment = parts.fragment or ""