Package io.wcm.caravan.io.http.response
Interface Body
-
- All Superinterfaces:
AutoCloseable
,Closeable
@ProviderType public interface Body extends Closeable
Generic HTTP body.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InputStream
asInputStream()
It is the responsibility of the caller to close the stream.Reader
asReader()
It is the responsibility of the caller to close the stream.String
asString()
Returns body as string and closes the stream.boolean
isRepeatable()
True ifasInputStream()
andasReader()
can be called more than once.Integer
length()
length in bytes, if known.
-
-
-
Method Detail
-
length
Integer length()
length in bytes, if known. Null if not.
Note
This is an integer as most implementations cannot do bodies greater than 2GB. Moreover, the scope of this interface doesn't include large bodies.- Returns:
- Length of the body
-
isRepeatable
boolean isRepeatable()
True ifasInputStream()
andasReader()
can be called more than once.- Returns:
- True if repeatable
-
asInputStream
InputStream asInputStream() throws IOException
It is the responsibility of the caller to close the stream.- Returns:
- Stream representation
- Throws:
IOException
- Error generating Stream
-
asReader
Reader asReader() throws IOException
It is the responsibility of the caller to close the stream.- Returns:
- Reader representation
- Throws:
IOException
- Error generating Reader
-
asString
String asString() throws IOException
Returns body as string and closes the stream.- Returns:
- String representation
- Throws:
IOException
- Error generating String
-
-