Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
tornado.httpclient.AsyncHTTPClient Class Reference
Inheritance diagram for tornado.httpclient.AsyncHTTPClient:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __new__
def close
def configurable_base
def configurable_default
def configure
def fetch
def fetch_impl
def initialize

Public Attributes

 defaults
 io_loop

Private Member Functions

def _async_clients

Private Attributes

 _closed

Detailed Description

An non-blocking HTTP client.

Example usage::

    def handle_request(response):
        if response.error:
            print "Error:", response.error
        else:
            print response.body

    http_client = AsyncHTTPClient()
    http_client.fetch("http://www.google.com/", handle_request)

The constructor for this class is magic in several respects: It
actually creates an instance of an implementation-specific
subclass, and instances are reused as a kind of pseudo-singleton
(one per `.IOLoop`).  The keyword argument ``force_instance=True``
can be used to suppress this singleton behavior.  Unless
``force_instance=True`` is used, no arguments other than
``io_loop`` should be passed to the `AsyncHTTPClient` constructor.
The implementation subclass as well as arguments to its
constructor can be set with the static method `configure()`

All `AsyncHTTPClient` implementations support a ``defaults``
keyword argument, which can be used to set default values for
`HTTPRequest` attributes.  For example::

    AsyncHTTPClient.configure(
        None, defaults=dict(user_agent="MyUserAgent"))
    # or with force_instance:
    client = AsyncHTTPClient(force_instance=True,
        defaults=dict(user_agent="MyUserAgent"))

Definition at line 101 of file httpclient.py.


Member Function Documentation

def tornado.httpclient.AsyncHTTPClient.__new__ (   cls,
  io_loop = None,
  force_instance = False,
  kwargs 
)

Definition at line 151 of file httpclient.py.

Definition at line 145 of file httpclient.py.

Destroys this HTTP client, freeing any file descriptors used.

This method is **not needed in normal use** due to the way
that `AsyncHTTPClient` objects are transparently reused.
``close()`` is generally only necessary when either the
`.IOLoop` is also being closed, or the ``force_instance=True``
argument was used when creating the `AsyncHTTPClient`.

No other methods may be called on the `AsyncHTTPClient` after
``close()``.

Definition at line 177 of file httpclient.py.

Returns the base class of a configurable hierarchy.

This will normally return the class in which it is defined.
(which is *not* necessarily the same as the cls classmethod parameter).

Reimplemented from tornado.util.Configurable.

Definition at line 136 of file httpclient.py.

Returns the implementation class to be used if none is configured.

Reimplemented from tornado.util.Configurable.

Definition at line 140 of file httpclient.py.

def tornado.httpclient.AsyncHTTPClient.configure (   cls,
  impl,
  kwargs 
)
Configures the `AsyncHTTPClient` subclass to use.

``AsyncHTTPClient()`` actually creates an instance of a subclass.
This method may be called with either a class object or the
fully-qualified name of such a class (or ``None`` to use the default,
``SimpleAsyncHTTPClient``)

If additional keyword arguments are given, they will be passed
to the constructor of each subclass instance created.  The
keyword argument ``max_clients`` determines the maximum number
of simultaneous `~AsyncHTTPClient.fetch()` operations that can
execute in parallel on each `.IOLoop`.  Additional arguments
may be supported depending on the implementation class in use.

Example::

   AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")

Reimplemented from tornado.util.Configurable.

Definition at line 252 of file httpclient.py.

def tornado.httpclient.AsyncHTTPClient.fetch (   self,
  request,
  callback = None,
  kwargs 
)
Executes a request, asynchronously returning an `HTTPResponse`.

The request may be either a string URL or an `HTTPRequest` object.
If it is a string, we construct an `HTTPRequest` using any additional
kwargs: ``HTTPRequest(request, **kwargs)``

This method returns a `.Future` whose result is an
`HTTPResponse`.  The ``Future`` will raise an `HTTPError` if
the request returned a non-200 response code.

If a ``callback`` is given, it will be invoked with the `HTTPResponse`.
In the callback interface, `HTTPError` is not automatically raised.
Instead, you must check the response's ``error`` attribute or
call its `~HTTPResponse.rethrow` method.

Definition at line 198 of file httpclient.py.

def tornado.httpclient.AsyncHTTPClient.fetch_impl (   self,
  request,
  callback 
)

Definition at line 248 of file httpclient.py.

def tornado.httpclient.AsyncHTTPClient.initialize (   self,
  io_loop,
  defaults = None 
)

Definition at line 170 of file httpclient.py.


Member Data Documentation

Definition at line 170 of file httpclient.py.

Definition at line 170 of file httpclient.py.

Definition at line 170 of file httpclient.py.


The documentation for this class was generated from the following file:


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Thu Aug 27 2015 14:50:40