Interface Body
-
- All Superinterfaces:
java.lang.AutoCloseable
public interface Body extends java.lang.AutoCloseableGeneric HTTP request / response body. It is responsibility of the caller to close the body instance explicitly (or throughGenericResponseinstance) to release all associated resources.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_BUFFER_SIZE
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.io.InputStreambody()Gets the body asInputStreamdefault byte[]bodyAsBytes()Gets the body asbytedefault java.lang.StringbodyAsString()Gets the body asStringvoidclose()Releases all resources associated with this body stream.java.lang.StringcontentType()Content type of this bodystatic Bodyfrom(byte[] body, java.lang.String contentType)Constructs the generic response body out ofInputStreamwith assumed content typestatic Bodyfrom(java.io.InputStream body, java.lang.String contentType)Constructs the generic response body out ofInputStreamwith assumed content type
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
from
@Nullable static Body from(@Nullable java.io.InputStream body, @Nullable java.lang.String contentType)
Constructs the generic response body out ofInputStreamwith assumed content type- Parameters:
body- response body streamcontentType- content type- Returns:
- generic response body instance
-
from
@Nullable static Body from(@Nullable byte[] body, @Nullable java.lang.String contentType)
Constructs the generic response body out ofInputStreamwith assumed content type- Parameters:
body- response body streamcontentType- content type- Returns:
- generic response body instance
-
contentType
java.lang.String contentType()
Content type of this body- Returns:
- content type
-
body
java.io.InputStream body()
Gets the body asInputStream- Returns:
- body as
InputStream
-
bodyAsString
default java.lang.String bodyAsString()
Gets the body asString- Returns:
- body as
String
-
bodyAsBytes
default byte[] bodyAsBytes()
Gets the body asbyte- Returns:
- body as
byte
-
close
void close() throws java.io.IOExceptionReleases all resources associated with this body stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.io.IOException
-
-