From: Andrew Rabert Date: Wed, 5 Apr 2017 02:29:34 +0000 (-0400) Subject: Fetch full URL if applicable X-Git-Tag: v5.0.0~82^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e2bbdafd0d9dc7e20c72d18b275b8289b6ea7fe;p=thirdparty%2Ftornado.git Fetch full URL if applicable --- diff --git a/tornado/testing.py b/tornado/testing.py index eff2684d2..2456f2164 100644 --- a/tornado/testing.py +++ b/tornado/testing.py @@ -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):