Interface StreamingHttpClient
- All Superinterfaces:
AutoCloseable
,Closeable
,HttpClient
,LifeCycle<HttpClient>
- All Known Implementing Classes:
DefaultHttpClient
HttpClient
that supports streaming responses.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.http.client.HttpClient
DEFAULT_ERROR_TYPE
-
Method Summary
Modifier and TypeMethodDescriptionstatic StreamingHttpClient
Create a newStreamingHttpClient
.static StreamingHttpClient
create
(@Nullable URL url, @NonNull HttpClientConfiguration configuration) Create a newStreamingHttpClient
with the specified configuration.<I> Publisher<ByteBuffer<?>>
dataStream
(@NonNull HttpRequest<I> request) Request a stream of data where each emitted item is aByteBuffer
instance.<I> Publisher<ByteBuffer<?>>
dataStream
(@NonNull HttpRequest<I> request, @NonNull Argument<?> errorType) Request a stream of data where each emitted item is aByteBuffer
instance.<I> Publisher<HttpResponse<ByteBuffer<?>>>
exchangeStream
(@NonNull HttpRequest<I> request) Requests a stream data where each emitted item is aByteBuffer
wrapped in theHttpResponse
object (which remains the same for each emitted item).<I> Publisher<HttpResponse<ByteBuffer<?>>>
exchangeStream
(@NonNull HttpRequest<I> request, @NonNull Argument<?> errorType) Requests a stream data where each emitted item is aByteBuffer
wrapped in theHttpResponse
object (which remains the same for each emitted item).jsonStream
(@NonNull HttpRequest<I> request) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.<I,
O> Publisher<O> jsonStream
(@NonNull HttpRequest<I> request, @NonNull Argument<O> type) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.<I,
O> Publisher<O> jsonStream
(@NonNull HttpRequest<I> request, @NonNull Argument<O> type, @NonNull Argument<?> errorType) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.default <I,
O> Publisher<O> jsonStream
(@NonNull HttpRequest<I> request, @NonNull Class<O> type) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
-
Method Details
-
dataStream
Request a stream of data where each emitted item is aByteBuffer
instance.- Type Parameters:
I
- The request body type- Parameters:
request
- The request- Returns:
- A
Publisher
that emits a stream ofByteBuffer
instances
-
dataStream
<I> Publisher<ByteBuffer<?>> dataStream(@NonNull @NonNull HttpRequest<I> request, @NonNull @NonNull Argument<?> errorType) Request a stream of data where each emitted item is aByteBuffer
instance.- Type Parameters:
I
- The request body type- Parameters:
request
- The requesterrorType
- The type that the response body should be coerced into if the server responds with an error- Returns:
- A
Publisher
that emits a stream ofByteBuffer
instances - Since:
- 3.1.0
-
exchangeStream
Requests a stream data where each emitted item is aByteBuffer
wrapped in theHttpResponse
object (which remains the same for each emitted item).- Type Parameters:
I
- The request body type- Parameters:
request
- TheHttpRequest
- Returns:
- A
Publisher
that emits a stream ofByteBuffer
instances wrapped by aHttpResponse
-
exchangeStream
<I> Publisher<HttpResponse<ByteBuffer<?>>> exchangeStream(@NonNull @NonNull HttpRequest<I> request, @NonNull @NonNull Argument<?> errorType) Requests a stream data where each emitted item is aByteBuffer
wrapped in theHttpResponse
object (which remains the same for each emitted item).- Type Parameters:
I
- The request body type- Parameters:
request
- TheHttpRequest
errorType
- The type that the response body should be coerced into if the server responds with an error- Returns:
- A
Publisher
that emits a stream ofByteBuffer
instances wrapped by aHttpResponse
- Since:
- 3.1.0
-
jsonStream
Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
The downstream
Subscriber
can regulate demand via the subscription- Type Parameters:
I
- The request body type- Parameters:
request
- TheHttpRequest
to execute- Returns:
- A
Publisher
that emits the fullHttpResponse
object
-
jsonStream
<I,O> Publisher<O> jsonStream(@NonNull @NonNull HttpRequest<I> request, @NonNull @NonNull Argument<O> type) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
The downstream
Subscriber
can regulate demand via the subscription. Incoming data is buffered.- Type Parameters:
I
- The request body typeO
- The response type- Parameters:
request
- TheHttpRequest
to executetype
- The type of object to convert the JSON into- Returns:
- A
Publisher
that emits the fullHttpResponse
object
-
jsonStream
<I,O> Publisher<O> jsonStream(@NonNull @NonNull HttpRequest<I> request, @NonNull @NonNull Argument<O> type, @NonNull @NonNull Argument<?> errorType) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
The downstream
Subscriber
can regulate demand via the subscription. Incoming data is buffered.- Type Parameters:
I
- The request body typeO
- The response type- Parameters:
request
- TheHttpRequest
to executetype
- The type of object to convert the JSON intoerrorType
- The type that the response body should be coerced into if the server responds with an error- Returns:
- A
Publisher
that emits the fullHttpResponse
object - Since:
- 3.1.0
-
jsonStream
default <I,O> Publisher<O> jsonStream(@NonNull @NonNull HttpRequest<I> request, @NonNull @NonNull Class<O> type) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
The downstream
Subscriber
can regulate demand via the subscription- Type Parameters:
I
- The request body typeO
- The response type- Parameters:
request
- TheHttpRequest
to executetype
- The type of object to convert the JSON into- Returns:
- A
Publisher
that emits the fullHttpResponse
object
-
create
Create a newStreamingHttpClient
. Note that this method should only be used outside the context of a Micronaut application. The returnedStreamingHttpClient
is not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application useInject
to inject a client instead.- Parameters:
url
- The base URL- Returns:
- The client
-
create
static StreamingHttpClient create(@Nullable @Nullable URL url, @NonNull @NonNull HttpClientConfiguration configuration) Create a newStreamingHttpClient
with the specified configuration. Note that this method should only be used outside the context of an application. Within Micronaut useInject
to inject a client instead- Parameters:
url
- The base URLconfiguration
- the client configuration- Returns:
- The client
- Since:
- 2.2.0
-