java.lang.Object
org.miaixz.bus.http.bodys.ResponseBody
org.miaixz.bus.http.bodys.RealResponseBody
- All Implemented Interfaces:
Closeable,AutoCloseable
A concrete implementation of
ResponseBody.
This class represents the content of an HTTP response and can only be used once. It provides access to the media type, content length, and data source of the response content. The media type is stored as a string to avoid parsing errors.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionRealResponseBody(String contentType, long length, org.miaixz.bus.core.io.source.BufferSource source) Constructs a newRealResponseBodyinstance. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the content length of this response body.org.miaixz.bus.core.lang.MediaTypeReturns the media type of this response body.org.miaixz.bus.core.io.source.BufferSourcesource()Returns the data source for this response body.Methods inherited from class org.miaixz.bus.http.bodys.ResponseBody
bytes, byteStream, charStream, close, create, create, create, create, string
-
Constructor Details
-
RealResponseBody
public RealResponseBody(String contentType, long length, org.miaixz.bus.core.io.source.BufferSource source) Constructs a newRealResponseBodyinstance.- Parameters:
contentType- The media type as a string, which may be null.length- The content length.source- The data source.
-
-
Method Details
-
contentType
public org.miaixz.bus.core.lang.MediaType contentType()Returns the media type of this response body.- Specified by:
contentTypein classResponseBody- Returns:
- The media type, or null if not present.
-
contentLength
public long contentLength()Returns the content length of this response body.- Specified by:
contentLengthin classResponseBody- Returns:
- The content length.
-
source
public org.miaixz.bus.core.io.source.BufferSource source()Returns the data source for this response body.- Specified by:
sourcein classResponseBody- Returns:
- The data source.
-