Interface HttpRequestBody
-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public interface HttpRequestBody implements AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classHttpRequestBody.Companion
-
Method Summary
Modifier and Type Method Description abstract UnitwriteTo(OutputStream outputStream)abstract StringcontentType()abstract LongcontentLength()abstract Booleanrepeatable()Determines if a request can be repeated in a meaningful way, for example before doing a retry. <T extends Any> Tjson(Class<T> clazz)Returns the body parsed as JSON into an instance of the given class. HttpRequestBodybuffered()Returns a body equivalent to this body, but which is fully written into memory, so it's repeatable. abstract Unitclose()Overridden from AutoCloseable to not have a checked exception in its signature. -
-
Method Detail
-
writeTo
abstract Unit writeTo(OutputStream outputStream)
-
contentType
abstract String contentType()
-
contentLength
abstract Long contentLength()
-
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.
-
close
abstract Unit close()
Overridden from AutoCloseable to not have a checked exception in its signature.
-
-
-
-