]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fail more gracefully when SSL is not supported, and on non-HTTP urls
authorBen Darnell <ben@bendarnell.com>
Sun, 26 Jun 2011 18:24:29 +0000 (11:24 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 26 Jun 2011 18:24:29 +0000 (11:24 -0700)
tornado/simple_httpclient.py

index ad15a2d32d71470ff182f5e1a1503e5623abb06f..a8b90af1a9fb4d0eee8aafe4a999af45d17ffddf 100644 (file)
@@ -133,6 +133,12 @@ class _HTTPConnection(object):
         self._timeout = None
         with stack_context.StackContext(self.cleanup):
             parsed = urlparse.urlsplit(_unicode(self.request.url))
+            if ssl is None and parsed.scheme == "https":
+                raise ValueError("HTTPS requires either python2.6+ or "
+                                 "curl_httpclient")
+            if parsed.scheme not in ("http", "https"):
+                raise ValueError("Unsupported url scheme: %s" %
+                                 self.request.url)
             # urlsplit results have hostname and port results, but they
             # didn't support ipv6 literals until python 2.7.
             netloc = parsed.netloc