public class HttpClientHelper extends HttpClientHelper
Parameter name | Value type | Default value | Description |
---|---|---|---|
addressResolutionTimeout | long | 15000 | The timeout in milliseconds for the DNS resolution of host addresses |
bindAddress | String | null | The address to bind socket channels to. You must set both this and bindPort |
bindPort | int | null | The address to bind socket channels to. You must set both this and bindAddress |
connectTimeout | long | 15000 | The max time in milliseconds a connection can take to connect to destinations |
dispatchIo | boolean | true | Whether to dispatch I/O operations from the selector thread to a different thread |
followRedirects | boolean | true | Whether to follow HTTP redirects |
idleTimeout | long | 60000 | The max time in milliseconds a connection can be idle (that is, without traffic of bytes in either direction) |
maxConnectionsPerDestination | int | 10 | Sets the max number of connections to open to each destination |
maxRedirects | int | 8 | The max number of HTTP redirects that are followed |
maxRequestsQueuedPerDestination | int | 1024 | Sets the max number of requests that may be queued to a destination |
requestBufferSize | int | 4096 | The size in bytes of the buffer used to write requests |
responseBufferSize | int | 16384 | The size in bytes of the buffer used to read responses |
stopTimeout | long | 60000 | Stop timeout in milliseconds; the maximum time allowed for the service to shutdown |
strictEventOrdering | boolean | false | Whether request events must be strictly ordered |
tcpNoDelay | boolean | true | Whether TCP_NODELAY is enabled |
userAgentField | String | null | The "User-Agent" HTTP header string; when null, uses the Jetty default |
sslContextFactory | String | org.restlet.ext.ssl.DefaultSslContextFactory | Let you specify a SslContextFactory qualified class name as a
parameter, or an instance as an attribute for a more complete and flexible
SSL context setting |
DefaultSslContextFactory
class.Constructor and Description |
---|
HttpClientHelper(Client client)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ClientCall |
create(Request request)
Creates a low-level HTTP client call from a high-level uniform call.
|
long |
getAddressResolutionTimeout()
The timeout in milliseconds for the DNS resolution of host addresses.
|
java.net.SocketAddress |
getBindAddress()
The address to bind socket channels to.
|
long |
getConnectTimeout()
The max time in milliseconds a connection can take to connect to
destinations.
|
java.net.CookieStore |
getCookieStore()
The cookie store.
|
java.util.concurrent.Executor |
getExecutor()
The executor.
|
org.eclipse.jetty.client.HttpClient |
getHttpClient()
Returns the wrapped Jetty HTTP client.
|
long |
getIdleTimeout()
The max time in milliseconds a connection can be idle (that is, without
traffic of bytes in either direction).
|
int |
getMaxConnectionsPerDestination()
Sets the max number of connections to open to each destination.
|
int |
getMaxRedirects()
The max number of HTTP redirects that are followed.
|
int |
getMaxRequestsQueuedPerDestination()
Sets the max number of requests that may be queued to a destination.
|
int |
getRequestBufferSize()
The size in bytes of the buffer used to write requests.
|
int |
getResponseBufferSize()
The size in bytes of the buffer used to read responses.
|
org.eclipse.jetty.util.thread.Scheduler |
getScheduler()
The scheduler.
|
long |
getStopTimeout()
Stop timeout in milliseconds.
|
java.lang.String |
getUserAgentField()
The "User-Agent" HTTP header string.
|
boolean |
isDispatchIO()
Whether to dispatch I/O operations from the selector thread to a
different thread.
|
boolean |
isFollowRedirects()
Whether to follow HTTP redirects.
|
boolean |
isStrictEventOrdering()
Whether request events must be strictly ordered.
|
boolean |
isTcpNoDelay()
Whether TCP_NODELAY is enabled.
|
void |
start() |
void |
stop() |
getAdapter, getSocketConnectTimeoutMs, handle, setAdapter
getConnectorService, getContext, getProtocols, update
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
public HttpClientHelper(Client client)
client
- The client to help.public ClientCall create(Request request)
create
in class HttpClientHelper
request
- The high-level request.public long getAddressResolutionTimeout()
public java.net.SocketAddress getBindAddress()
public long getConnectTimeout()
public java.net.CookieStore getCookieStore()
InMemoryCookieStore
.public java.util.concurrent.Executor getExecutor()
QueuedThreadPool
.public org.eclipse.jetty.client.HttpClient getHttpClient()
public long getIdleTimeout()
public int getMaxConnectionsPerDestination()
RFC 2616 suggests that 2 connections should be opened per each
destination, but browsers commonly open 6. If this client is used for
load testing, it is common to have only one destination (the server to
load test), and it is recommended to set this value to a high value (at
least as much as the threads present in the executor
).
public int getMaxRedirects()
public int getMaxRequestsQueuedPerDestination()
If this client performs a high rate of requests to a destination, and all the connections managed by that destination are busy with other requests, then new requests will be queued up in the destination. This parameter controls how many requests can be queued before starting to reject them. If this client is used for load testing, it is common to have this parameter set to a high value, although this may impact latency (requests sit in the queue for a long time before being sent).
public int getRequestBufferSize()
public int getResponseBufferSize()
public org.eclipse.jetty.util.thread.Scheduler getScheduler()
ScheduledExecutorScheduler
.public long getStopTimeout()
The maximum time allowed for the service to shutdown.
public java.lang.String getUserAgentField()
public boolean isDispatchIO()
This implementation never blocks on I/O operation, but invokes application callbacks that may take time to execute or block on other I/O. If application callbacks are known to take time or block on I/O, then this should be set to true. If application callbacks are known to be quick and never block on I/O, then this may be set to false.
public boolean isFollowRedirects()
public boolean isStrictEventOrdering()
Client listeners may send a second request. If the second request is for the same destination, there is an inherent race condition for the use of the connection: the first request may still be associated with the connection, so the second request cannot use that connection and is forced to open another one.
From the point of view of connection usage, the connection is reusable just before the "complete" event, so it would be possible to reuse that connection from complete listeners; but in this case the second request's events will fire before the "complete" events of the first request.
This setting enforces strict event ordering so that a "begin" event of a second request can never fire before the "complete" event of a first request, but at the expense of an increased usage of connections.
When not enforced, a "begin" event of a second request may happen before the "complete" event of a first request and allow for better usage of connections.
public boolean isTcpNoDelay()
public void start() throws java.lang.Exception
start
in class ConnectorHelper<Client>
java.lang.Exception
public void stop() throws java.lang.Exception
stop
in class ConnectorHelper<Client>
java.lang.Exception
Copyright © 2005-2020 Restlet.