Class TransportBody

java.lang.Object
org.apache.juneau.rest.client.TransportBody

public final class TransportBody extends Object
The body of a transport-layer request — a thin wrapper around HttpBody that gives transports a stable contract without needing to know about higher-level body types.

Transport implementations call HttpBody.writeTo(OutputStream) to stream the body directly to the underlying connection, avoiding full in-memory buffering.

Since:
9.2.1
  • Method Details

    • of

      public static TransportBody of(HttpBody body)
      Wraps the given HttpBody as a TransportBody.
      Parameters:
      body - The HTTP body. Must not be null.
      Returns:
      A new instance. Never null.
    • getContentType

      Returns the content type of this body (e.g. "application/json; charset=UTF-8"), or null if unknown.
      Returns:
      The content type, possibly null.
    • getContentLength

      public long getContentLength()
      Returns the content length in bytes, or -1 if unknown (signals chunked transfer).
      Returns:
      The content length, or -1.
    • writeTo

      public void writeTo(OutputStream out) throws IOException
      Streams the body content to the given output stream.

      The caller must not close out.

      Parameters:
      out - The output stream. Must not be null.
      Throws:
      IOException - If an I/O error occurs.
    • isRepeatable

      public boolean isRepeatable()
      Returns true if this body can be written more than once.
      Returns:
      true if repeatable.