class documentation
class Agent(_AgentBase): (source)
Constructor: Agent(reactor, contextFactory, connectTimeout, bindAddress, pool)
Implements interfaces: twisted.web.iweb.IAgent
Agent is a very basic HTTP client. It supports HTTP and HTTPS scheme URIs.
| Present Since | |
| 9.0 |
| Class Method | using |
Create a new Agent that will use the endpoint factory to figure out how to connect to the server. |
| Method | __init__ |
Create an Agent. |
| Method | request |
Issue a request to the server indicated by the given uri. |
| Method | _get |
Get an endpoint for the given URI, using self._endpointFactory. |
| Method | _init |
Initialize a new Agent. |
| Instance Variable | _endpoint |
The IAgentEndpointFactory which will be used to create endpoints for outgoing connections. |
| Instance Variable | _pool |
An HTTPConnectionPool instance. |
Inherited from _AgentBase:
| Method | _compute |
Compute the string to use for the value of the Host header, based on the given scheme, host name, and port number. |
| Method | _request |
Issue a new request, given the endpoint and the path sent as part of the request. |
| Instance Variable | _reactor |
The IReactorTime implementation which will be used by the pool, and perhaps by subclasses as well. |
Create a new Agent that will use the endpoint factory to figure out how to connect to the server.
| Parameters | |
reactor:see HostnameEndpoint.__init__ for acceptable reactor types. | A reactor for this Agent to place outgoing connections. |
endpointIAgentEndpointFactory provider. | Used to construct endpoints which the HTTP client will connect with. |
pool:HTTPConnectionPool | An HTTPConnectionPool instance, or None, in which case a non-persistent HTTPConnectionPool instance will be created. |
| Returns | |
A new Agent. | |
def __init__(self, reactor, contextFactory=BrowserLikePolicyForHTTPS(), connectTimeout=None, bindAddress=None, pool=None):
(source)
¶
overrides
twisted.web.client._AgentBase.__init__Create an Agent.
| Parameters | |
reactor:see HostnameEndpoint.__init__ for acceptable reactor types. | A reactor for this Agent to place outgoing connections. |
contextIPolicyForHTTPS. | A 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. |
connectfloat | The amount of time that this Agent will wait for the peer to accept a connection. |
bindbytes | The local address for client sockets to bind to. |
pool:HTTPConnectionPool | An HTTPConnectionPool instance, or None, in which case a non-persistent HTTPConnectionPool instance will be created. |
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 Also | |
twisted.web.iweb.IAgent.request |
Get an endpoint for the given URI, using self._endpointFactory.
| Parameters | |
uri:URI | The URI of the request. |
| Returns | |
| An endpoint which can be used to connect to given address. | |
Initialize a new Agent.
| Parameters | |
reactor:see HostnameEndpoint.__init__ for acceptable reactor types. | A reactor for this Agent to place outgoing connections. |
endpointIAgentEndpointFactory provider. | Used to construct endpoints which the HTTP client will connect with. |
pool:HTTPConnectionPool | An HTTPConnectionPool instance, or None, in which case a non-persistent HTTPConnectionPool instance will be created. |
| Returns | |
A new Agent. | |