Package org.apache.juneau.http
Class HttpEntities
java.lang.Object
org.apache.juneau.http.HttpEntities
Standard predefined HTTP entities.
See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final ByteArrayEntity
byteArrayEntity
(byte[] content) Creates a newByteArrayEntity
builder.static final ByteArrayEntity
byteArrayEntity
(byte[] content, ContentType contentType) Creates a newByteArrayEntity
builder.static final ByteArrayEntity
byteArrayEntity
(Supplier<byte[]> content) Creates a newByteArrayEntity
builder.static final ByteArrayEntity
byteArrayEntity
(Supplier<byte[]> content, ContentType contentType) Creates a newByteArrayEntity
builder.static final FileEntity
fileEntity
(File content) Creates a newFileEntity
builder.static final FileEntity
fileEntity
(File content, ContentType contentType) Creates a newFileEntity
builder.static final ReaderEntity
readerEntity
(Reader content) Creates a newReaderEntity
builder.static final ReaderEntity
readerEntity
(Reader content, ContentType contentType) Creates a newReaderEntity
builder.static final SerializedEntity
serializedEntity
(Object content, Serializer serializer) Creates a newSerializedEntity
object.static final SerializedEntity
serializedEntity
(Object content, Serializer serializer, HttpPartSchema schema) Creates a newSerializedEntity
object.static final SerializedEntity
serializedEntity
(Supplier<?> content, Serializer serializer) Creates a newSerializedEntity
object.static final SerializedEntity
serializedEntity
(Supplier<?> content, Serializer serializer, HttpPartSchema schema) Creates a newSerializedEntity
object.static final StreamEntity
streamEntity
(InputStream content) Creates a newStreamEntity
builder.static final StreamEntity
streamEntity
(InputStream content, long length, ContentType contentType) Creates a newStreamEntity
builder.static final StringEntity
stringEntity
(String content) Creates a new builder for aStringEntity
builder.static final StringEntity
stringEntity
(String content, ContentType contentType) Creates a new builder for aStringEntity
builder.static final StringEntity
stringEntity
(Supplier<String> content) Creates a new builder for aStringEntity
builder.static final StringEntity
stringEntity
(Supplier<String> content, ContentType contentType) Creates a new builder for aStringEntity
builder.
-
Constructor Details
-
HttpEntities
public HttpEntities()
-
-
Method Details
-
byteArrayEntity
Creates a newByteArrayEntity
builder.Assumes no content type.
- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
ByteArrayEntity
builder.
-
byteArrayEntity
Creates a newByteArrayEntity
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
ByteArrayEntity
builder.
-
byteArrayEntity
Creates a newByteArrayEntity
builder.Assumes no content type.
- Parameters:
content
- The entity content supplier. Can benull .- Returns:
- A new
ByteArrayEntity
builder.
-
byteArrayEntity
public static final ByteArrayEntity byteArrayEntity(Supplier<byte[]> content, ContentType contentType) Creates a newByteArrayEntity
builder.- Parameters:
content
- The entity content supplier. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
ByteArrayEntity
builder.
-
fileEntity
Creates a newFileEntity
builder.Assumes no content type.
- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
FileEntity
builder.
-
fileEntity
Creates a newFileEntity
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
FileEntity
builder.
-
readerEntity
Creates a newReaderEntity
builder.- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
ReaderEntity
builder.
-
readerEntity
Creates a newReaderEntity
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
ReaderEntity
builder.
-
serializedEntity
Creates a newSerializedEntity
object.- Parameters:
content
- The Java POJO representing the content.
Can benull .serializer
- The serializer to use to serialize the POJO.
Ifnull , POJO will be converted to a string usingObject.toString()
.- Returns:
- A new
SerializedEntity
object.
-
serializedEntity
Creates a newSerializedEntity
object.- Parameters:
content
- The supplier of a Java POJO representing the content.
Can benull .serializer
- The serializer to use to serialize the POJO.
Ifnull , POJO will be converted to a string usingObject.toString()
.- Returns:
- A new
SerializedEntity
object.
-
serializedEntity
public static final SerializedEntity serializedEntity(Object content, Serializer serializer, HttpPartSchema schema) Creates a newSerializedEntity
object.- Parameters:
content
- The Java POJO representing the content.
Can benull .serializer
- The serializer to use to serialize the POJO.
Ifnull , POJO will be converted to a string usingObject.toString()
.schema
- Optional HTTP-part schema for providing instructionst to the serializer on the format of the entity.- Returns:
- A new
SerializedEntity
object.
-
serializedEntity
public static final SerializedEntity serializedEntity(Supplier<?> content, Serializer serializer, HttpPartSchema schema) Creates a newSerializedEntity
object.- Parameters:
content
- The supplier of a Java POJO representing the content.
Can benull .serializer
- The serializer to use to serialize the POJO.
Ifnull , POJO will be converted to a string usingObject.toString()
.schema
- Optional HTTP-part schema for providing instructionst to the serializer on the format of the entity.- Returns:
- A new
SerializedEntity
object.
-
streamEntity
Creates a newStreamEntity
builder.Assumes no content type.
- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
StreamEntity
builder.
-
streamEntity
public static final StreamEntity streamEntity(InputStream content, long length, ContentType contentType) Creates a newStreamEntity
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.length
- The content length, or-1 if not known.- Returns:
- A new
StreamEntity
builder.
-
stringEntity
Creates a new builder for aStringEntity
builder.- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
StringEntity
builder.
-
stringEntity
Creates a new builder for aStringEntity
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
StringEntity
builder.
-
stringEntity
Creates a new builder for aStringEntity
builder.- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
StringEntity
builder.
-
stringEntity
Creates a new builder for aStringEntity
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
StringEntity
builder.
-