Interface BlockingHttpClient

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable

    public interface BlockingHttpClient
    extends java.io.Closeable
    A blocking HTTP client interface that features a subset of the operations provided by HttpClient and is designed primarily for testing purposes.
    Since:
    1.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default <I,​O>
      io.micronaut.http.HttpResponse<O>
      exchange​(io.micronaut.http.HttpRequest<I> request)
      Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher.
      default <I,​O>
      io.micronaut.http.HttpResponse<O>
      exchange​(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> bodyType)
      Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
      <I,​O,​E>
      io.micronaut.http.HttpResponse<O>
      exchange​(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> bodyType, io.micronaut.core.type.Argument<E> errorType)
      Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
      default <I,​O>
      io.micronaut.http.HttpResponse<O>
      exchange​(io.micronaut.http.HttpRequest<I> request, java.lang.Class<O> bodyType)
      Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
      default <O> io.micronaut.http.HttpResponse<O> exchange​(java.lang.String uri)
      Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
      default <O> io.micronaut.http.HttpResponse<O> exchange​(java.lang.String uri, java.lang.Class<O> bodyType)
      Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
      default <O,​E>
      io.micronaut.http.HttpResponse<O>
      exchange​(java.lang.String uri, java.lang.Class<O> bodyType, java.lang.Class<E> errorType)
      Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
      default <I> java.lang.String retrieve​(io.micronaut.http.HttpRequest<I> request)
      Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
      default <I,​O>
      O
      retrieve​(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> bodyType)
      Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
      default <I,​O,​E>
      O
      retrieve​(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> bodyType, io.micronaut.core.type.Argument<E> errorType)
      Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
      default <I,​O>
      O
      retrieve​(io.micronaut.http.HttpRequest<I> request, java.lang.Class<O> bodyType)
      Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
      default java.lang.String retrieve​(java.lang.String uri)
      Perform an HTTP GET request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
      default <O> O retrieve​(java.lang.String uri, java.lang.Class<O> bodyType)
      Perform an HTTP GET request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
      default <O,​E>
      O
      retrieve​(java.lang.String uri, java.lang.Class<O> bodyType, java.lang.Class<E> errorType)
      Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
      • Methods inherited from interface java.io.Closeable

        close
    • Method Detail

      • exchange

        <I,​O,​E> io.micronaut.http.HttpResponse<O> exchange​(io.micronaut.http.HttpRequest<I> request,
                                                                       io.micronaut.core.type.Argument<O> bodyType,
                                                                       io.micronaut.core.type.Argument<E> errorType)

        Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.

        This method will send a Content-Length header and except a content length header the response and is designed for simple non-streaming exchanges of data

        By default the exchange Content-Type is application/json, unless otherwise specified in the passed HttpRequest

        Type Parameters:
        I - The request body type
        O - The response body type
        E - The error type
        Parameters:
        request - The HttpRequest to execute
        bodyType - The body type
        errorType - The error type
        Returns:
        The full HttpResponse object
        Throws:
        HttpClientResponseException - when an error status is returned
      • exchange

        default <I,​O> io.micronaut.http.HttpResponse<O> exchange​(io.micronaut.http.HttpRequest<I> request,
                                                                       io.micronaut.core.type.Argument<O> bodyType)

        Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.

        This method will send a Content-Length header and except a content length header the response and is designed for simple non-streaming exchanges of data

        By default the exchange Content-Type is application/json, unless otherwise specified in the passed HttpRequest

        Type Parameters:
        I - The request body type
        O - The response body type
        Parameters:
        request - The HttpRequest to execute
        bodyType - The body type
        Returns:
        The full HttpResponse object
        Throws:
        HttpClientResponseException - when an error status is returned
      • exchange

        default <I,​O> io.micronaut.http.HttpResponse<O> exchange​(io.micronaut.http.HttpRequest<I> request)
        Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher.
        Type Parameters:
        I - The request body type
        O - The response body type
        Parameters:
        request - The HttpRequest to execute
        Returns:
        The full HttpResponse object
        Throws:
        HttpClientResponseException - when an error status is returned
      • exchange

        default <I,​O> io.micronaut.http.HttpResponse<O> exchange​(io.micronaut.http.HttpRequest<I> request,
                                                                       java.lang.Class<O> bodyType)
        Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
        Type Parameters:
        I - The request body type
        O - The response body type
        Parameters:
        request - The HttpRequest to execute
        bodyType - The body type
        Returns:
        The full HttpResponse object
        Throws:
        HttpClientResponseException - when an error status is returned
      • retrieve

        default <I,​O> O retrieve​(io.micronaut.http.HttpRequest<I> request,
                                       io.micronaut.core.type.Argument<O> bodyType)
        Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
        Type Parameters:
        I - The request body type
        O - The response body type
        Parameters:
        request - The HttpRequest to execute
        bodyType - The body type
        Returns:
        A result of the given type or null the URI returns a 404
        Throws:
        HttpClientResponseException - when an error status is returned
      • retrieve

        default <I,​O,​E> O retrieve​(io.micronaut.http.HttpRequest<I> request,
                                               io.micronaut.core.type.Argument<O> bodyType,
                                               io.micronaut.core.type.Argument<E> errorType)
        Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
        Type Parameters:
        I - The request body type
        O - The response body type
        E - The error type
        Parameters:
        request - The HttpRequest to execute
        bodyType - The body type
        errorType - The error type
        Returns:
        A result of the given type or null the URI returns a 404
        Throws:
        HttpClientResponseException - when an error status is returned
      • retrieve

        default <I,​O> O retrieve​(io.micronaut.http.HttpRequest<I> request,
                                       java.lang.Class<O> bodyType)
        Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
        Type Parameters:
        I - The request body type
        O - The response body type
        Parameters:
        request - The HttpRequest to execute
        bodyType - The body type
        Returns:
        A result of the given type or null the URI returns a 404
        Throws:
        HttpClientResponseException - when an error status is returned
      • retrieve

        default <I> java.lang.String retrieve​(io.micronaut.http.HttpRequest<I> request)
        Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
        Type Parameters:
        I - The request body type
        Parameters:
        request - The HttpRequest to execute
        Returns:
        A string result or null if a 404 is returned
        Throws:
        HttpClientResponseException - when an error status is returned
      • retrieve

        default java.lang.String retrieve​(java.lang.String uri)
        Perform an HTTP GET request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
        Parameters:
        uri - The URI
        Returns:
        A string result or null if a 404 is returned
        Throws:
        HttpClientResponseException - when an error status is returned
      • retrieve

        default <O> O retrieve​(java.lang.String uri,
                               java.lang.Class<O> bodyType)
        Perform an HTTP GET request for the given request object emitting the full HTTP response from returned Publisher and converting the response body to the specified type.
        Type Parameters:
        O - The body generic type
        Parameters:
        uri - The URI
        bodyType - The body type
        Returns:
        A result or null if a 404 is returned
        Throws:
        HttpClientResponseException - when an error status is returned
      • retrieve

        default <O,​E> O retrieve​(java.lang.String uri,
                                       java.lang.Class<O> bodyType,
                                       java.lang.Class<E> errorType)
        Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
        Type Parameters:
        O - The response body type
        E - The error type
        Parameters:
        uri - The URI of the GET request
        bodyType - The body type
        errorType - The error type
        Returns:
        The full HttpResponse object
        Throws:
        HttpClientResponseException - when an error status is returned
      • exchange

        default <O> io.micronaut.http.HttpResponse<O> exchange​(java.lang.String uri)
        Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
        Type Parameters:
        O - The response body type
        Parameters:
        uri - The URI of the GET request
        Returns:
        The full HttpResponse object
        Throws:
        HttpClientResponseException - when an error status is returned
      • exchange

        default <O> io.micronaut.http.HttpResponse<O> exchange​(java.lang.String uri,
                                                               java.lang.Class<O> bodyType)
        Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
        Type Parameters:
        O - The response body type
        Parameters:
        uri - The URI of the GET request
        bodyType - The body type
        Returns:
        The full HttpResponse object
        Throws:
        HttpClientResponseException - when an error status is returned
      • exchange

        default <O,​E> io.micronaut.http.HttpResponse<O> exchange​(java.lang.String uri,
                                                                       java.lang.Class<O> bodyType,
                                                                       java.lang.Class<E> errorType)
        Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
        Type Parameters:
        O - The response body type
        E - The error type
        Parameters:
        uri - The URI of the GET request
        bodyType - The body type
        errorType - The error type
        Returns:
        The full HttpResponse object
        Throws:
        HttpClientResponseException - when an error status is returned