Interface HttpResponse

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public interface HttpResponse.Handler
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Integer statusCode()
      abstract Headers headers()
      Optional<String> requestId() Returns the value of the request-id header, or an empty Optional if there's no such header in the response.
      abstract InputStream body()
      <T extends Any> T json(Class<T> clazz) Returns the response body parsed as JSON into an instance of the given class.
      HttpResponse buffered() Returns a response equivalent to this response, but whose body returns a new InputStream on each call, so it can be read repeatedly.
      abstract Unit close() Overridden from AutoCloseable to not have a checked exception in its signature.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • json

         <T extends Any> T json(Class<T> clazz)

        Returns the response body parsed as JSON into an instance of the given class.

        This method consumes the body stream. To also read the body in other ways, call buffered first and call this method on the returned response.

      • buffered

         HttpResponse buffered()

        Returns a response equivalent to this response, but whose body returns a new InputStream on each call, so it can be read repeatedly.

        The first call to the returned response's body fully reads this response's body into memory, so this response should no longer be used directly. Closing the returned response closes this response. Calling buffered on the returned response returns it unchanged.