Interface BlockingHttpClient

All Superinterfaces:
AutoCloseable, Closeable

public interface BlockingHttpClient extends 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
Author:
Graeme Rocher
  • Method Summary

    Modifier and Type
    Method
    Description
    default <I, O> HttpResponse<O>
    exchange(HttpRequest<I> request)
    Perform an HTTP request for the given request object emitting the full HTTP response from returned Publisher.
    default <I, O> HttpResponse<O>
    exchange(HttpRequest<I> request, 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> HttpResponse<O>
    exchange(HttpRequest<I> request, Argument<O> bodyType, 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> HttpResponse<O>
    exchange(HttpRequest<I> request, 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> HttpResponse<O>
    Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
    default <O> HttpResponse<O>
    exchange(String uri, Class<O> bodyType)
    Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
    default <O, E> HttpResponse<O>
    exchange(String uri, Class<O> bodyType, Class<E> errorType)
    Perform a GET request for the given request object emitting the full HTTP response from returned Publisher.
    default <I> String
    retrieve(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(HttpRequest<I> request, 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(HttpRequest<I> request, Argument<O> bodyType, 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(HttpRequest<I> request, 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 String
    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(String uri, 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(String uri, Class<O> bodyType, 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 Details

    • exchange

      <I, O, E> HttpResponse<O> exchange(HttpRequest<I> request, Argument<O> bodyType, 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> HttpResponse<O> exchange(HttpRequest<I> request, 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> HttpResponse<O> exchange(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> HttpResponse<O> exchange(HttpRequest<I> request, 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(HttpRequest<I> request, 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(HttpRequest<I> request, Argument<O> bodyType, 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(HttpRequest<I> request, 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> String retrieve(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 String retrieve(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(String uri, 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(String uri, Class<O> bodyType, 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> HttpResponse<O> exchange(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> HttpResponse<O> exchange(String uri, 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> HttpResponse<O> exchange(String uri, Class<O> bodyType, 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