Interface StreamingHttpClient

All Superinterfaces:
AutoCloseable, Closeable, HttpClient, io.micronaut.context.LifeCycle<HttpClient>

public interface StreamingHttpClient extends HttpClient
Extended version of the HttpClient that supports streaming responses.
Since:
1.0
  • Field Summary

    Fields inherited from interface io.micronaut.http.client.HttpClient

    DEFAULT_ERROR_TYPE
  • Method Summary

    Modifier and Type
    Method
    Description
    create(URL url)
    Create a new StreamingHttpClient.
    create(URL url, HttpClientConfiguration configuration)
    Create a new StreamingHttpClient with the specified configuration.
    <I> org.reactivestreams.Publisher<io.micronaut.core.io.buffer.ByteBuffer<?>>
    dataStream(io.micronaut.http.HttpRequest<I> request)
    Request a stream of data where each emitted item is a ByteBuffer instance.
    <I> org.reactivestreams.Publisher<io.micronaut.core.io.buffer.ByteBuffer<?>>
    dataStream(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<?> errorType)
    Request a stream of data where each emitted item is a ByteBuffer instance.
    <I> org.reactivestreams.Publisher<io.micronaut.http.HttpResponse<io.micronaut.core.io.buffer.ByteBuffer<?>>>
    exchangeStream(io.micronaut.http.HttpRequest<I> request)
    Requests a stream data where each emitted item is a ByteBuffer wrapped in the HttpResponse object (which remains the same for each emitted item).
    <I> org.reactivestreams.Publisher<io.micronaut.http.HttpResponse<io.micronaut.core.io.buffer.ByteBuffer<?>>>
    exchangeStream(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<?> errorType)
    Requests a stream data where each emitted item is a ByteBuffer wrapped in the HttpResponse object (which remains the same for each emitted item).
    <I> org.reactivestreams.Publisher<Map<String,Object>>
    jsonStream(io.micronaut.http.HttpRequest<I> request)
    Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
    <I, O> org.reactivestreams.Publisher<O>
    jsonStream(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> type)
    Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
    <I, O> org.reactivestreams.Publisher<O>
    jsonStream(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> type, io.micronaut.core.type.Argument<?> errorType)
    Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
    default <I, O> org.reactivestreams.Publisher<O>
    jsonStream(io.micronaut.http.HttpRequest<I> request, Class<O> type)
    Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.

    Methods inherited from interface io.micronaut.http.client.HttpClient

    exchange, exchange, exchange, exchange, exchange, exchange, refresh, retrieve, retrieve, retrieve, retrieve, retrieve, toBlocking

    Methods inherited from interface io.micronaut.context.LifeCycle

    close, isRunning, start, stop
  • Method Details

    • dataStream

      <I> org.reactivestreams.Publisher<io.micronaut.core.io.buffer.ByteBuffer<?>> dataStream(@NonNull io.micronaut.http.HttpRequest<I> request)
      Request a stream of data where each emitted item is a ByteBuffer instance.
      Type Parameters:
      I - The request body type
      Parameters:
      request - The request
      Returns:
      A Publisher that emits a stream of ByteBuffer instances
    • dataStream

      <I> org.reactivestreams.Publisher<io.micronaut.core.io.buffer.ByteBuffer<?>> dataStream(@NonNull io.micronaut.http.HttpRequest<I> request, @NonNull io.micronaut.core.type.Argument<?> errorType)
      Request a stream of data where each emitted item is a ByteBuffer instance.
      Type Parameters:
      I - The request body type
      Parameters:
      request - The request
      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 of ByteBuffer instances
      Since:
      3.1.0
    • exchangeStream

      <I> org.reactivestreams.Publisher<io.micronaut.http.HttpResponse<io.micronaut.core.io.buffer.ByteBuffer<?>>> exchangeStream(@NonNull io.micronaut.http.HttpRequest<I> request)
      Requests a stream data where each emitted item is a ByteBuffer wrapped in the HttpResponse object (which remains the same for each emitted item).
      Type Parameters:
      I - The request body type
      Parameters:
      request - The HttpRequest
      Returns:
      A Publisher that emits a stream of ByteBuffer instances wrapped by a HttpResponse
    • exchangeStream

      <I> org.reactivestreams.Publisher<io.micronaut.http.HttpResponse<io.micronaut.core.io.buffer.ByteBuffer<?>>> exchangeStream(@NonNull io.micronaut.http.HttpRequest<I> request, @NonNull io.micronaut.core.type.Argument<?> errorType)
      Requests a stream data where each emitted item is a ByteBuffer wrapped in the HttpResponse object (which remains the same for each emitted item).
      Type Parameters:
      I - The request body type
      Parameters:
      request - The HttpRequest
      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 of ByteBuffer instances wrapped by a HttpResponse
      Since:
      3.1.0
    • jsonStream

      <I> org.reactivestreams.Publisher<Map<String,Object>> jsonStream(@NonNull io.micronaut.http.HttpRequest<I> request)

      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 - The HttpRequest to execute
      Returns:
      A Publisher that emits the full HttpResponse object
    • jsonStream

      <I, O> org.reactivestreams.Publisher<O> jsonStream(@NonNull io.micronaut.http.HttpRequest<I> request, @NonNull io.micronaut.core.type.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 type
      O - The response type
      Parameters:
      request - The HttpRequest to execute
      type - The type of object to convert the JSON into
      Returns:
      A Publisher that emits the full HttpResponse object
    • jsonStream

      <I, O> org.reactivestreams.Publisher<O> jsonStream(@NonNull io.micronaut.http.HttpRequest<I> request, @NonNull io.micronaut.core.type.Argument<O> type, @NonNull io.micronaut.core.type.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 type
      O - The response type
      Parameters:
      request - The HttpRequest to execute
      type - The type of object to convert the JSON into
      errorType - The type that the response body should be coerced into if the server responds with an error
      Returns:
      A Publisher that emits the full HttpResponse object
      Since:
      3.1.0
    • jsonStream

      default <I, O> org.reactivestreams.Publisher<O> jsonStream(@NonNull io.micronaut.http.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.

      The downstream Subscriber can regulate demand via the subscription

      Type Parameters:
      I - The request body type
      O - The response type
      Parameters:
      request - The HttpRequest to execute
      type - The type of object to convert the JSON into
      Returns:
      A Publisher that emits the full HttpResponse object
    • create

      static StreamingHttpClient create(@Nullable URL url)
      Create a new StreamingHttpClient. Note that this method should only be used outside of the context of a Micronaut application. The returned StreamingHttpClient is not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application use Inject to inject a client instead.
      Parameters:
      url - The base URL
      Returns:
      The client
    • create

      static StreamingHttpClient create(@Nullable URL url, @NonNull HttpClientConfiguration configuration)
      Create a new StreamingHttpClient with the specified configuration. Note that this method should only be used outside of the context of an application. Within Micronaut use Inject to inject a client instead
      Parameters:
      url - The base URL
      configuration - the client configuration
      Returns:
      The client
      Since:
      2.2.0