]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fetch full URL if applicable
authorAndrew Rabert <draje@nullsum.net>
Wed, 5 Apr 2017 02:29:34 +0000 (22:29 -0400)
committerAndrew Rabert <draje@nullsum.net>
Wed, 5 Apr 2017 02:29:34 +0000 (22:29 -0400)
tornado/testing.py

index eff2684d2c1bccace94120928cb76933f719a046..2456f2164086e16f1ce875ef10eac017821335b9 100644 (file)
@@ -395,14 +395,20 @@ class AsyncHTTPTestCase(AsyncTestCase):
         raise NotImplementedError()
 
     def fetch(self, path, **kwargs):
-        """Convenience method to synchronously fetch a url.
+        """Convenience method to synchronously fetch a URL.
 
         The given path will be appended to the local server's host and
         port.  Any additional kwargs will be passed directly to
         `.AsyncHTTPClient.fetch` (and so could be used to pass
         ``method="POST"``, ``body="..."``, etc).
+
+        If the path begins with http:// or https://, it will be treated as a
+        full URL and will be fetched as-is.
         """
-        self.http_client.fetch(self.get_url(path), self.stop, **kwargs)
+        if path.lower().startswith(('http://', 'https://')):
+            self.http_client.fetch(path, self.stop, **kwargs)
+        else:
+            self.http_client.fetch(self.get_url(path), self.stop, **kwargs)
         return self.wait()
 
     def get_httpserver_options(self):