Package org.apache.juneau.http
Class HttpBodies
java.lang.Object
org.apache.juneau.http.HttpBodies
Static factory methods for creating common HTTP body types.
Import statically for clean DSL-style usage:
import static HttpBodies.*;
RestRequest
See Also:
- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic ByteArrayBodybyteArrayBody(byte[] bytes) Creates a body backed by a byte array.static ByteArrayBodybyteArrayBody(byte[] bytes, String contentType) Creates a body backed by a byte array with a specific content type.static FileBodyCreates a body backed by a file.static FileBodyCreates a body backed by a file with a specific content type.static PartListCreates a URL-encoded form body from the given parts.static PartListformBodyOfPairs(String... pairs) Creates a URL-encoded form body from alternating name/value string pairs.static StreamBodystreamBody(InputStream stream) Creates a streaming body backed by anInputStream.static StreamBodystreamBody(InputStream stream, String contentType) Creates a streaming body backed by anInputStreamwith a specific content type.static StringBodystringBody(String content) Creates a UTF-8text/plainbody.static StringBodystringBody(String content, String contentType) Creates a string body with a specific content type.
-
Method Details
-
stringBody
Creates a UTF-8text/plainbody.- Parameters:
content- The string content. Must not benull .- Returns:
- A new body. Never
null .
-
stringBody
Creates a string body with a specific content type.- Parameters:
content- The string content. Must not benull .contentType- The MIME content type. May benull .- Returns:
- A new body. Never
null .
-
byteArrayBody
Creates a body backed by a byte array.- Parameters:
bytes- The byte content. Must not benull .- Returns:
- A new body. Never
null .
-
byteArrayBody
Creates a body backed by a byte array with a specific content type.- Parameters:
bytes- The byte content. Must not benull .contentType- The MIME content type. May benull .- Returns:
- A new body. Never
null .
-
fileBody
Creates a body backed by a file.- Parameters:
file- The file. Must not benull .- Returns:
- A new body. Never
null .
-
fileBody
Creates a body backed by a file with a specific content type.- Parameters:
file- The file. Must not benull .contentType- The MIME content type. May benull .- Returns:
- A new body. Never
null .
-
streamBody
Creates a streaming body backed by anInputStream.- Parameters:
stream- The input stream. Must not benull .- Returns:
- A new body. Never
null .
-
streamBody
Creates a streaming body backed by anInputStreamwith a specific content type.- Parameters:
stream- The input stream. Must not benull .contentType- The MIME content type. May benull .- Returns:
- A new body. Never
null .
-
formBody
Creates a URL-encoded form body from the given parts.- Parameters:
parts- The form parts. Must not benull .- Returns:
- A new body. Never
null .
-
formBodyOfPairs
Creates a URL-encoded form body from alternating name/value string pairs.- Parameters:
pairs- Alternating name/value strings. Must not benull . Length must be even.- Returns:
- A new body. Never
null .
-