|
30 | 30 | class SimpleAsyncHTTPClient(object):
|
31 | 31 | """Non-blocking HTTP client with no external dependencies.
|
32 | 32 |
|
33 |
| - WARNING: This class is still in development and not yet recommended |
34 |
| - for production use. |
35 |
| -
|
36 | 33 | This class implements an HTTP 1.1 client on top of Tornado's IOStreams.
|
37 | 34 | It does not currently implement all applicable parts of the HTTP
|
38 | 35 | specification, but it does enough to work with major web service APIs
|
39 | 36 | (mostly tested against the Twitter API so far).
|
40 | 37 |
|
41 |
| - Many features found in the curl-based AsyncHTTPClient are not yet |
42 |
| - implemented. The currently-supported set of parameters to HTTPRequest |
43 |
| - are url, method, headers, body, streaming_callback, and header_callback. |
44 |
| - Connections are not reused, and no attempt is made to limit the number |
45 |
| - of outstanding requests. |
| 38 | + This class has not been tested extensively in production and |
| 39 | + should be considered somewhat experimental as of the release of |
| 40 | + tornado 1.2. It is intended to become the default AsyncHTTPClient |
| 41 | + implementation in a future release. It may either be used |
| 42 | + directly, or to facilitate testing of this class with an existing |
| 43 | + application, setting the environment variable |
| 44 | + USE_SIMPLE_HTTPCLIENT=1 will cause this class to transparently |
| 45 | + replace tornado.httpclient.AsyncHTTPClient. |
| 46 | +
|
| 47 | + Some features found in the curl-based AsyncHTTPClient are not yet |
| 48 | + supported. In particular, proxies are not supported, connections |
| 49 | + are not reused, and callers cannot select the network interface to be |
| 50 | + used. |
46 | 51 |
|
47 | 52 | Python 2.6 or higher is required for HTTPS support. Users of Python 2.5
|
48 | 53 | should use the curl-based AsyncHTTPClient if HTTPS support is required.
|
| 54 | +
|
49 | 55 | """
|
50 | 56 | _ASYNC_CLIENTS = weakref.WeakKeyDictionary()
|
51 | 57 |
|
@@ -190,9 +196,11 @@ def _on_connect(self, parsed):
|
190 | 196 | if (self.request.method not in self._SUPPORTED_METHODS and
|
191 | 197 | not self.request.allow_nonstandard_methods):
|
192 | 198 | raise KeyError("unknown method %s" % self.request.method)
|
193 |
| - if self.request.network_interface: |
194 |
| - raise NotImplementedError( |
195 |
| - "network interface selection not supported") |
| 199 | + for key in ('network_interface', |
| 200 | + 'proxy_host', 'proxy_port', |
| 201 | + 'proxy_username', 'proxy_password'): |
| 202 | + if getattr(self.request, key, None): |
| 203 | + raise NotImplementedError('%s not supported' % key) |
196 | 204 | if "Host" not in self.request.headers:
|
197 | 205 | self.request.headers["Host"] = parsed.netloc
|
198 | 206 | if self.request.auth_username:
|
|
0 commit comments