Class JettyClient
java.lang.Object
org.attribyte.api.http.impl.jetty.JettyClient
- All Implemented Interfaces:
AsyncClient,Client
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an uninitialized client.JettyClient(ClientOptions options) Creates a client with specified options. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.util.concurrent.ListenableFuture<Response> Sends a request with default options that completes with aListenableFuture.com.google.common.util.concurrent.ListenableFuture<Response> asyncSend(Request request, RequestOptions options) Sends a request with specified options that completes with aListenableFuture.completableSend(Request request) Sends a request with default options that completes with aCompletableFuture.completableSend(Request request, RequestOptions options) Sends a request with specified options that completes with aCompletableFuture.voidinit(String prefix, Properties props, org.attribyte.api.Logger logger) Initializes the client.static org.eclipse.jetty.client.HttpClientjettyClientFromOptions(ClientOptions options) Creates and initializes a new Jetty client from HTTP client options.Sends a request with default options.send(Request request, RequestOptions options) Sends a request with specified options.voidshutdown()Releases resources, interrupts threads, etc.Sends a request and allows the response to be streamed when it is available.test(Request request, RequestOptions options) Run a test, hashing the content and accumulating the length, but not buffering.
-
Constructor Details
-
JettyClient
public JettyClient()Creates an uninitialized client. -
JettyClient
Creates a client with specified options.- Parameters:
options- The options.- Throws:
org.attribyte.api.InitializationException- if options are invalid or other initialization error.
-
-
Method Details
-
jettyClientFromOptions
Creates and initializes a new Jetty client from HTTP client options.- Parameters:
options- The options.- Returns:
- The initialized (but not started) client.
-
init
public void init(String prefix, Properties props, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException Description copied from interface:ClientInitializes the client. Must be called before first use. -
send
Description copied from interface:ClientSends a request with default options.- Specified by:
sendin interfaceClient- Parameters:
request- The request.- Returns:
- The response.
- Throws:
IOException- on I/O error.
-
send
Description copied from interface:ClientSends a request with specified options.- Specified by:
sendin interfaceClient- Parameters:
request- The request.options- The request options.- Returns:
- The response.
- Throws:
IOException- on I/O error.
-
asyncSend
Description copied from interface:AsyncClientSends a request with default options that completes with aListenableFuture.- Specified by:
asyncSendin interfaceAsyncClient- Parameters:
request- The request.- Returns:
- The (listenable) response future.
-
asyncSend
public com.google.common.util.concurrent.ListenableFuture<Response> asyncSend(Request request, RequestOptions options) Description copied from interface:AsyncClientSends a request with specified options that completes with aListenableFuture.- Specified by:
asyncSendin interfaceAsyncClient- Parameters:
request- The request.options- The request options.- Returns:
- The (listenable) response future.
-
completableSend
Description copied from interface:AsyncClientSends a request with default options that completes with aCompletableFuture.- Specified by:
completableSendin interfaceAsyncClient- Parameters:
request- The request.- Returns:
- The (completable) response future.
-
completableSend
Description copied from interface:AsyncClientSends a request with specified options that completes with aCompletableFuture.- Specified by:
completableSendin interfaceAsyncClient- Parameters:
request- The request.options- The request options.- Returns:
- The (completable) response future.
-
test
Run a test, hashing the content and accumulating the length, but not buffering.- Parameters:
request- The request.options- The request options.- Returns:
- The response.
-
stream
public StreamedResponse stream(Request request, long timeout, TimeUnit timeoutUnits) throws TimeoutException, InterruptedException, ExecutionException Sends a request and allows the response to be streamed when it is available.- Parameters:
request- The request.timeout- The time to wait for the response to return status and headers.timeoutUnits- The timeout units.- Returns:
- The streamed response.
- Throws:
TimeoutException- on timeout.InterruptedException- on interrupted.ExecutionException- on send exception.
-
shutdown
Description copied from interface:ClientReleases resources, interrupts threads, etc. Called when application using the client is terminated.
-