Module bus.http

Class RealResponseBody

java.lang.Object
org.miaixz.bus.http.bodys.ResponseBody
org.miaixz.bus.http.bodys.RealResponseBody
All Implemented Interfaces:
Closeable, AutoCloseable

public class RealResponseBody extends ResponseBody
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 Details

    • RealResponseBody

      public RealResponseBody(String contentType, long length, org.miaixz.bus.core.io.source.BufferSource source)
      Constructs a new RealResponseBody instance.
      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:
      contentType in class ResponseBody
      Returns:
      The media type, or null if not present.
    • contentLength

      public long contentLength()
      Returns the content length of this response body.
      Specified by:
      contentLength in class ResponseBody
      Returns:
      The content length.
    • source

      public org.miaixz.bus.core.io.source.BufferSource source()
      Returns the data source for this response body.
      Specified by:
      source in class ResponseBody
      Returns:
      The data source.