Package org.apache.juneau.http
Class HttpResources
java.lang.Object
org.apache.juneau.http.HttpResources
Standard predefined HTTP resources.
Resources are simply HttpEntity
objects with arbitrary additional headers.
See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final ByteArrayResource
byteArrayResource
(byte[] content) Creates a newByteArrayResource
builder.static final ByteArrayResource
byteArrayResource
(byte[] content, ContentType contentType) Creates a newByteArrayResource
builder.static final ByteArrayResource
byteArrayResource
(Supplier<byte[]> content) Creates a newByteArrayResource
builder.static final ByteArrayResource
byteArrayResource
(Supplier<byte[]> content, ContentType contentType) Creates a newByteArrayResource
builder.static final FileResource
fileResource
(File content) Creates a newFileResource
builder.static final FileResource
fileResource
(File content, ContentType contentType) Creates a newFileResource
builder.static final ReaderResource
readerResource
(Reader content) Creates a newReaderResource
builder.static final ReaderResource
readerResource
(Reader content, ContentType contentType) Creates a newReaderResource
builder.static final StreamResource
streamResource
(InputStream content) Creates a newStreamResource
builder.static final StreamResource
streamResource
(InputStream content, long length, ContentType contentType) Creates a newStreamResource
builder.static final StringResource
stringResource
(String content) Creates a new builder for aStringResource
builder.static final StringResource
stringResource
(String content, ContentType contentType) Creates a new builder for aStringResource
builder.static final StringResource
stringResource
(Supplier<String> content) Creates a new builder for aStringResource
builder.static final StringResource
stringResource
(Supplier<String> content, ContentType contentType) Creates a new builder for aStringResource
builder.
-
Constructor Details
-
HttpResources
public HttpResources()
-
-
Method Details
-
byteArrayResource
Creates a newByteArrayResource
builder.Assumes no content type.
- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
ByteArrayResource
builder.
-
byteArrayResource
Creates a newByteArrayResource
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
ByteArrayResource
builder.
-
byteArrayResource
Creates a newByteArrayResource
builder.Assumes no content type.
- Parameters:
content
- The entity content supplier. Can benull .- Returns:
- A new
ByteArrayResource
builder.
-
byteArrayResource
public static final ByteArrayResource byteArrayResource(Supplier<byte[]> content, ContentType contentType) Creates a newByteArrayResource
builder.- Parameters:
content
- The entity content supplier. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
ByteArrayResource
builder.
-
fileResource
Creates a newFileResource
builder.Assumes no content type.
- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
FileResource
builder.
-
fileResource
Creates a newFileResource
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
FileResource
builder.
-
readerResource
Creates a newReaderResource
builder.- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
ReaderResource
builder.
-
readerResource
Creates a newReaderResource
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
ReaderResource
builder.
-
streamResource
Creates a newStreamResource
builder.Assumes no content type.
- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
StreamResource
builder.
-
streamResource
public static final StreamResource streamResource(InputStream content, long length, ContentType contentType) Creates a newStreamResource
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
StreamResource
builder.
-
stringResource
Creates a new builder for aStringResource
builder.- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
StringResource
builder.
-
stringResource
Creates a new builder for aStringResource
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
StringResource
builder.
-
stringResource
Creates a new builder for aStringResource
builder.- Parameters:
content
- The entity content. Can benull .- Returns:
- A new
StringResource
builder.
-
stringResource
public static final StringResource stringResource(Supplier<String> content, ContentType contentType) Creates a new builder for aStringResource
builder.- Parameters:
content
- The entity content. Can benull .contentType
- The entity content type, ornull if not specified.- Returns:
- A new
StringResource
builder.
-