public class ReactiveRequest extends Object
A reactive wrapper over Jetty's HttpClient Request.
A ReactiveRequest can be obtained via a builder:
// Built with HttpClient and a string URI. ReactiveRequest request = ReactiveRequest.newBuilder(httpClient, uri()).build(); // Built by wrapping a Request. Request req = httpClient.newRequest(...); ... ReactiveRequest request = ReactiveRequest.newBuilder(req).build();
Once created, a ReactiveRequest can be sent to obtain a Publisher
for a ReactiveResponse passing a function that handles the response
content:
Publisher<T> response = request.response((response, content) -> { ... });
| Modifier and Type | Class | Description |
|---|---|---|
static class |
ReactiveRequest.Builder |
A Builder for ReactiveRequest.
|
static interface |
ReactiveRequest.Content |
A Publisher of content chunks that also specifies the content length and type.
|
static class |
ReactiveRequest.Event |
A ReactiveRequest event.
|
| Modifier | Constructor | Description |
|---|---|---|
protected |
ReactiveRequest(org.eclipse.jetty.client.api.Request request) |
| Modifier and Type | Method | Description |
|---|---|---|
ReactiveResponse |
getReactiveResponse() |
|
org.eclipse.jetty.client.api.Request |
getRequest() |
|
static ReactiveRequest.Builder |
newBuilder(org.eclipse.jetty.client.api.Request request) |
|
static ReactiveRequest.Builder |
newBuilder(org.eclipse.jetty.client.HttpClient httpClient,
String uri) |
|
org.reactivestreams.Publisher<ReactiveRequest.Event> |
requestEvents() |
|
org.reactivestreams.Publisher<ReactiveResponse> |
response() |
Creates a Publisher that sends the request when a Subscriber requests the response
via
Subscription.request(long), discarding the response content. |
<T> org.reactivestreams.Publisher<T> |
response(BiFunction<ReactiveResponse,org.reactivestreams.Publisher<ContentChunk>,org.reactivestreams.Publisher<T>> contentFn) |
Creates a Publisher that sends the request when a Subscriber requests the response
via
Subscription.request(long), processing the response content with the given
function. |
org.reactivestreams.Publisher<ReactiveResponse.Event> |
responseEvents() |
|
String |
toString() |
protected ReactiveRequest(org.eclipse.jetty.client.api.Request request)
public static ReactiveRequest.Builder newBuilder(org.eclipse.jetty.client.HttpClient httpClient, String uri)
httpClient - the HttpClient instanceuri - the target URI for the request - must be properly encoded alreadypublic static ReactiveRequest.Builder newBuilder(org.eclipse.jetty.client.api.Request request)
request - the request instancepublic ReactiveResponse getReactiveResponse()
public org.eclipse.jetty.client.api.Request getRequest()
public org.reactivestreams.Publisher<ReactiveResponse> response()
Creates a Publisher that sends the request when a Subscriber requests the response
via Subscription.request(long), discarding the response content.
public <T> org.reactivestreams.Publisher<T> response(BiFunction<ReactiveResponse,org.reactivestreams.Publisher<ContentChunk>,org.reactivestreams.Publisher<T>> contentFn)
Creates a Publisher that sends the request when a Subscriber requests the response
via Subscription.request(long), processing the response content with the given
function.
contentFn - the function that processes the response contentpublic org.reactivestreams.Publisher<ReactiveRequest.Event> requestEvents()
public org.reactivestreams.Publisher<ReactiveResponse.Event> responseEvents()
Copyright © 2017 The Jetty Project. All rights reserved.