Class 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 |
| cookieSupported | boolean | false | Whether to support HTTP cookie, storing and automatically sending them back |
| connectBlocking | boolean | false | Indicates whether the connect operation is blocking. See HttpClient.isConnectBlocking(). |
| connectTimeout | long | 15000 | The max time in milliseconds a connection can take to connect to destinations |
| destinationIdleTimeout | long | 0 | the time in milliseconds after which idle destinations are removed |
| followRedirects | boolean | true | Whether to follow HTTP redirects |
| httpComplianceMode | String | RFC7230 | Indicate the HTTP compliance mode among the following options: "RFC7230", "RFC2616", "LEGACY", "RFC7230_LEGACY".
See HttpCompliance. |
| httpClientTransportMode | String | HTTP1_1 | Indicate the HTTP client transport mode among the following options: "HTTP1_1", "HTTP2", "HTTP3", "DYNAMIC". See
HttpClientTransport. |
| idleTimeout | long | 30000 | The max time in milliseconds a connection can be idle (that is, without traffic of bytes in either direction) |
| maxConnectionsPerDestination | int | 64 | 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 |
| maxResponseHeaderSize | int | -1 | The max size in bytes of the response headers. -1 is unlimited. |
| proxyHost | String | System property "http.proxyHost" | The host name of the HTTP proxy. |
| proxyPort | int | System property "http.proxyPort" or "3128" | The port of the HTTP proxy. |
| 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 |
| strictEventOrdering | boolean | false | Whether request events must be strictly ordered |
| 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 |
| http3PemWorkDir | string | No default value | Directory where are exported trusted certificates, required for HTTP3 support. There is no default value to let you configure a secured enough directory. |
DefaultSslContextFactory class.- Author:
- Jerome Louvel, Tal Liron
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a low-level HTTP client call from a high-level uniform call.protected org.eclipse.jetty.client.HttpClientCreates a Jetty HTTP client.longThe timeout in milliseconds for the DNS resolution of host addresses.org.eclipse.jetty.client.AuthenticationStoreReturns the wrapped Jetty authentication store.The address to bind socket channels to.longThe max time in milliseconds a connection can take to connect to destinations.org.eclipse.jetty.http.HttpCookieStoreReturns the wrapped Jetty cookie store.longThe timeout in milliseconds for idle destinations to be removed.Returns the executor.Directory where are extracted the supported certificates.org.eclipse.jetty.client.HttpClientReturns the wrapped Jetty HTTP client.Returns the HTTP client transport mode among the following options: "HTTP1_1", "HTTP2", "HTTP3", "DYNAMIC.Returns the HTTP compliance mode among the following options: "RFC7230", "RFC2616", "LEGACY", "RFC7230_LEGACY".longThe max time in milliseconds a connection can be idle (that is, without traffic of bytes in either direction).intSets the max number of connections to open to each destination.intThe max number of HTTP redirects that are followed.intSets the max number of requests that may be queued to a destination.intReturns the max size in bytes of the response headers.Returns the host name of the HTTP proxy, if specified.intReturns the port of the HTTP proxy, if specified, 3128 otherwise.intThe size in bytes of the buffer used to write requests.intThe size in bytes of the buffer used to read responses.org.eclipse.jetty.util.thread.SchedulerThe scheduler.The "User-Agent" HTTP header string.booleanIndicates whether the connect operation is blocking.booleanWhether to support cookies, storing and automatically sending them back.booleanWhether to follow HTTP redirects.booleanWhether request events must be strictly ordered.voidsetAuthenticationStore(org.eclipse.jetty.client.AuthenticationStore authenticationStore) Sets the wrapped Jetty authentication store.voidsetCookieStore(org.eclipse.jetty.http.HttpCookieStore cookieStore) Sets the wrapped Jetty cookie store.voidsetExecutor(Executor executor) Sets the executor.voidstart()Start callback.voidstop()Stop callback.Methods inherited from class org.restlet.engine.adapter.HttpClientHelper
getAdapter, getSocketConnectTimeoutMs, handle, setAdapterMethods inherited from class org.restlet.engine.connector.ConnectorHelper
getConnectorService, getContext, getProtocols, updateMethods inherited from class org.restlet.engine.RestletHelper
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
-
Constructor Details
-
HttpClientHelper
Constructor. Properties can still be set before the wrapped Jetty HTTP client is effectively created and configured via thecreateHttpClient()method.- Parameters:
client- The client connector to help.
-
-
Method Details
-
create
Creates a low-level HTTP client call from a high-level uniform call.- Specified by:
createin classHttpClientHelper- Parameters:
request- The high-level request.- Returns:
- A low-level HTTP client call.
-
createHttpClient
protected org.eclipse.jetty.client.HttpClient createHttpClient()Creates a Jetty HTTP client.- Returns:
- A new HTTP client.
-
getAddressResolutionTimeout
public long getAddressResolutionTimeout()The timeout in milliseconds for the DNS resolution of host addresses. Defaults to 15000.- Returns:
- The address resolution timeout.
-
getAuthenticationStore
public org.eclipse.jetty.client.AuthenticationStore getAuthenticationStore()Returns the wrapped Jetty authentication store.- Returns:
- The wrapped Jetty authentication store.
-
setAuthenticationStore
public void setAuthenticationStore(org.eclipse.jetty.client.AuthenticationStore authenticationStore) Sets the wrapped Jetty authentication store.- Parameters:
authenticationStore- The wrapped Jetty authentication store.
-
getBindAddress
The address to bind socket channels to. Default to null.- Returns:
- The bind address or null.
-
getConnectTimeout
public long getConnectTimeout()The max time in milliseconds a connection can take to connect to destinations. Defaults to 15000.- Returns:
- The connect timeout.
-
getCookieStore
public org.eclipse.jetty.http.HttpCookieStore getCookieStore()Returns the wrapped Jetty cookie store.- Returns:
- The wrapped Jetty cookie store.
-
setCookieStore
public void setCookieStore(org.eclipse.jetty.http.HttpCookieStore cookieStore) Sets the wrapped Jetty cookie store.- Parameters:
cookieStore- The wrapped Jetty cookie store.
-
getDestinationIdleTimeout
public long getDestinationIdleTimeout()The timeout in milliseconds for idle destinations to be removed. Defaults to 0.- Returns:
- The address resolution timeout.
-
getExecutor
Returns the executor. By default, returns an instance ofQueuedThreadPool.- Returns:
- Returns the executor.
-
setExecutor
Sets the executor.- Parameters:
executor- The executor.
-
getHttpClient
public org.eclipse.jetty.client.HttpClient getHttpClient()Returns the wrapped Jetty HTTP client.- Returns:
- The wrapped Jetty HTTP client.
-
getHttpComplianceMode
Returns the HTTP compliance mode among the following options: "RFC7230", "RFC2616", "LEGACY", "RFC7230_LEGACY". SeeHttpCompliance. Default to "RFC7230".- Returns:
- The HTTP compliance mode.
-
getHttpClientTransportMode
Returns the HTTP client transport mode among the following options: "HTTP1_1", "HTTP2", "HTTP3", "DYNAMIC. SeeHttpClientTransport. Default to "HTTP1_1".- Returns:
- The HTTP client transport mode.
-
getHttp3PemWorkDir
Directory where are extracted the supported certificates.- Returns:
- Directory where are extracted the supported certificates.
-
getIdleTimeout
public long getIdleTimeout()The max time in milliseconds a connection can be idle (that is, without traffic of bytes in either direction). Defaults to 30000.- Returns:
- The idle timeout.
-
getMaxConnectionsPerDestination
public int getMaxConnectionsPerDestination()Sets the max number of connections to open to each destination. Defaults to 64.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).- Returns:
- The maximum connections per destination.
-
getMaxRedirects
public int getMaxRedirects()The max number of HTTP redirects that are followed. Defaults to 8.- Returns:
- The maximum redirects.
-
getMaxRequestsQueuedPerDestination
public int getMaxRequestsQueuedPerDestination()Sets the max number of requests that may be queued to a destination. Defaults to 1024.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).
- Returns:
- The maximum requests queues per destination.
-
getMaxResponseHeadersSize
public int getMaxResponseHeadersSize()Returns the max size in bytes of the response headers. Default is -1 that is unlimited.- Returns:
- the max size in bytes of the response headers.
-
getProxyHost
Returns the host name of the HTTP proxy, if specified.- Returns:
- the host name of the HTTP proxy, if specified.
-
getProxyPort
public int getProxyPort()Returns the port of the HTTP proxy, if specified, 3128 otherwise.- Returns:
- the port of the HTTP proxy.
-
getRequestBufferSize
public int getRequestBufferSize()The size in bytes of the buffer used to write requests. Defaults to 4096.- Returns:
- The request buffer size.
-
getResponseBufferSize
public int getResponseBufferSize()The size in bytes of the buffer used to read responses. Defaults to 16384.- Returns:
- The response buffer size.
-
getScheduler
public org.eclipse.jetty.util.thread.Scheduler getScheduler()The scheduler. Defaults to null. When null, creates a new instance ofScheduledExecutorScheduler.- Returns:
- The scheduler.
-
getUserAgentField
The "User-Agent" HTTP header string. When null, uses the Jetty default. Default to null.- Returns:
- The user agent field or null.
-
isConnectBlocking
public boolean isConnectBlocking()Indicates whether the connect operation is blocking. SeeHttpClient.isConnectBlocking().- Returns:
- True if the connect operation is blocking.
-
isCookieSupported
public boolean isCookieSupported()Whether to support cookies, storing and automatically sending them back. Defaults to false.- Returns:
- Whether to support cookies.
-
isFollowRedirects
public boolean isFollowRedirects()Whether to follow HTTP redirects. Defaults to true.- Returns:
- Whether to follow redirects.
-
isStrictEventOrdering
public boolean isStrictEventOrdering()Whether request events must be strictly ordered. Defaults to false.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.
- Returns:
- Whether request events must be strictly ordered.
-
start
Description copied from class:RestletHelperStart callback.- Overrides:
startin classConnectorHelper<Client>- Throws:
Exception
-
stop
Description copied from class:RestletHelperStop callback.- Overrides:
stopin classConnectorHelper<Client>- Throws:
Exception
-