Package org.apache.juneau.rest.client
Class TransportBody
java.lang.Object
org.apache.juneau.rest.client.TransportBody
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 Summary
Modifier and TypeMethodDescriptionlongReturns the content length in bytes, or-1if unknown (signals chunked transfer).Returns the content type of this body (e.g.booleanReturnstrueif this body can be written more than once.static TransportBodyWraps the givenHttpBodyas aTransportBody.voidwriteTo(OutputStream out) Streams the body content to the given output stream.
-
Method Details
-
of
Wraps the givenHttpBodyas aTransportBody.- Parameters:
body- The HTTP body. Must not benull .- Returns:
- A new instance. Never
null .
-
getContentType
Returns the content type of this body (e.g."application/json; charset=UTF-8"), ornullif unknown.- Returns:
- The content type, possibly
null .
-
getContentLength
Returns the content length in bytes, or-1if unknown (signals chunked transfer).- Returns:
- The content length, or
-1.
-
writeTo
Streams the body content to the given output stream.The caller must not close
out.- Parameters:
out- The output stream. Must not benull .- Throws:
IOException- If an I/O error occurs.
-
isRepeatable
Returnstrueif this body can be written more than once.- Returns:
trueif repeatable.
-