t.w.c.Agent(_AgentBase) : class documentation

Part of twisted.web.client View Source View In Hierarchy

Agent is a very basic HTTP client. It supports HTTP and HTTPS scheme URIs (but performs no certificate checking by default).
Present Since9.0
Method __init__ Create an Agent.
Method request Issue a request to the server indicated by the given uri.
Instance Variable _pool An HTTPConnectionPool instance.
Instance Variable _policyForHTTPS A web context factory which will be used to create SSL context objects for any SSL connections the agent needs to make.
Instance Variable _connectTimeout If not None, the timeout passed to TCP4ClientEndpoint or SSL4ClientEndpoint for specifying the connection timeout.
Instance Variable _bindAddress If not None, the address passed to TCP4ClientEndpoint or SSL4ClientEndpoint for specifying the local address to bind to.
Method _getEndpoint Get an endpoint for the given host and port, using a transport selected based on scheme.

Inherited from _AgentBase:

Instance Variable _reactor The IReactorTime implementation which will be used by the pool, and perhaps by subclasses as well.
Method _computeHostValue Compute the string to use for the value of the Host header, based on the given scheme, host name, and port number.
Method _requestWithEndpoint Issue a new request, given the endpoint and the path sent as part of the request.
_pool =
An HTTPConnectionPool instance.
_policyForHTTPS =
A web context factory which will be used to create SSL context objects for any SSL connections the agent needs to make.
_connectTimeout =
If not None, the timeout passed to TCP4ClientEndpoint or SSL4ClientEndpoint for specifying the connection timeout.
_bindAddress =
If not None, the address passed to TCP4ClientEndpoint or SSL4ClientEndpoint for specifying the local address to bind to.
def __init__(self, reactor, contextFactory=BrowserLikePolicyForHTTPS(), connectTimeout=None, bindAddress=None, pool=None): (source)
Create an Agent.
ParametersreactorA provider of twisted.internet.interfaces.IReactorTCP and twisted.internet.interfaces.IReactorSSL for this Agent to place outgoing connections. (type: twisted.internet.interfaces.IReactorTCP and twisted.internet.interfaces.IReactorSSL)
contextFactoryA factory for TLS contexts, to control the verification parameters of OpenSSL. The default is to use a BrowserLikePolicyForHTTPS, so unless you have special requirements you can leave this as-is. (type: IPolicyForHTTPS.)
connectTimeoutThe amount of time that this Agent will wait for the peer to accept a connection. (type: float)
bindAddressThe local address for client sockets to bind to. (type: bytes)
poolAn HTTPConnectionPool instance, or None, in which case a non-persistent HTTPConnectionPool instance will be created. (type: HTTPConnectionPool)
def _getEndpoint(self, scheme, host, port): (source)
Get an endpoint for the given host and port, using a transport selected based on scheme.
ParametersschemeA string like 'http' or 'https' (the only two supported values) to use to determine how to establish the connection.
hostA str giving the hostname which will be connected to in order to issue a request.
portAn int giving the port number the connection will be on.
ReturnsAn endpoint which can be used to connect to given address.
def request(self, method, uri, headers=None, bodyProducer=None): (source)
Issue a request to the server indicated by the given uri.

An existing connection from the connection pool may be used or a new one may be created.

HTTP and HTTPS schemes are supported in uri.

See Alsotwisted.web.iweb.IAgent.request
API Documentation for Twisted, generated by pydoctor at 2014-05-12 18:27:00.