Implements interfaces: twisted.web.iweb.IAgent

Agent is a very basic HTTP client. It supports HTTP and HTTPS scheme URIs.

Present Since9.0
Method __init__ Create an Agent.
Class Method usingEndpointFactory Create a new Agent that will use the endpoint factory to figure out how to connect to the server.
Method request Issue a request to the server indicated by the given uri.
Instance Variable _pool An HTTPConnectionPool instance.
Instance Variable _endpointFactory The IAgentEndpointFactory which will be used to create endpoints for outgoing connections.
Method _init Initialize a new Agent.
Method _getEndpoint Get an endpoint for the given URI, using self._endpointFactory.

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.
_endpointFactory =
The IAgentEndpointFactory which will be used to create endpoints for outgoing connections.
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)
@classmethod
def usingEndpointFactory(cls, reactor, endpointFactory, pool=None): (source)

Create a new Agent that will use the endpoint factory to figure out how to connect to the server.

ParametersreactorA provider of twisted.internet.interfaces.IReactorTime.
endpointFactoryUsed to construct endpoints which the HTTP client will connect with. (type: an IAgentEndpointFactory provider.)
poolAn HTTPConnectionPool instance, or None, in which case a non-persistent HTTPConnectionPool instance will be created. (type: HTTPConnectionPool)
ReturnsA new Agent.
def _init(self, reactor, endpointFactory, pool): (source)

Initialize a new Agent.

ParametersreactorA provider of relevant reactor interfaces, at a minimum twisted.internet.interfaces.IReactorTime.
endpointFactoryUsed to construct endpoints which the HTTP client will connect with. (type: an IAgentEndpointFactory provider.)
poolAn HTTPConnectionPool instance, or None, in which case a non-persistent HTTPConnectionPool instance will be created. (type: HTTPConnectionPool)
ReturnsA new Agent.
def _getEndpoint(self, uri): (source)

Get an endpoint for the given URI, using self._endpointFactory.

ParametersuriThe URI of the request. (type: URI)
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 2016-04-04 15:02:49.