Interface HttpRequestBody

    • 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 Unit writeTo(OutputStream outputStream)
      abstract String contentType()
      abstract Long contentLength()
      abstract Boolean repeatable() Determines if a request can be repeated in a meaningful way, for example before doing a retry.
      <T extends Any> T json(Class<T> clazz) Returns the body parsed as JSON into an instance of the given class.
      HttpRequestBody buffered() Returns a body equivalent to this body, but which is fully written into memory, so it's repeatable.
      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

      • repeatable

         abstract Boolean repeatable()

        Determines if a request can be repeated in a meaningful way, for example before doing a retry.

        The most typical case when a request can't be retried is if the request body is being streamed. In this case the body data isn't available on subsequent attempts.

      • json

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

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

        This method writes the body (writeTo). If the body is not repeatable, then call buffered first and call this method on the returned body.

      • buffered

         HttpRequestBody buffered()

        Returns a body equivalent to this body, but which is fully written into memory, so it's repeatable.

        Returns this body unchanged if it's already repeatable. Otherwise, the returned body's first writeTo call (or a call that implies it, like json or an unknown contentLength) fully writes this body into memory, so this body should no longer be used directly. Closing the returned body closes this body.