Package org.apache.juneau.http.resource
Class StreamResource
java.lang.Object
org.apache.juneau.http.resource.BasicResource
org.apache.juneau.http.resource.StreamResource
- All Implemented Interfaces:
HttpEntity,HttpResource
A streamed, non-repeatable resource that obtains its content from an
InputStream.
See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor.StreamResource(ContentType contentType, InputStream contents) Constructor.protectedStreamResource(StreamResource copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionAppends the specified header to the end of the headers in this builder.addHeaders(Header... values) Appends the specified headers to the end of the headers in this builder.copy()Creates a builder for this class initialized with the contents of this bean.Specifies that the contents of this resource should be cached into an internal byte array so that it can be read multiple times.Sets the 'chunked' flag value totrue .setChunked(boolean value) Sets the 'chunked' flag value.setContent(Object value) Sets the content on this entity bean.setContent(Supplier<?> value) Sets the content on this entity bean from a supplier.setContentEncoding(String value) Sets the content encoding header on this entity bean.Sets the content encoding header on this entity bean.setContentLength(long value) Sets the content length on this entity bean.setContentType(String value) Sets the content type on this entity bean.setContentType(ContentType value) Sets the content type on this entity bean.Sets the specified header in this builder.setHeaders(Header... values) Sets the specified headers in this builder.setHeaders(HeaderList value) Sets the specified headers in this builder.Specifies whether this bean should be unmodifiable.Methods inherited from class org.apache.juneau.http.resource.BasicResource
asBytes, assertBytes, assertModifiable, assertString, asString, consumeContent, copyFrom, getContent, getContentEncoding, getContentLength, getContentType, getEntity, getHeaders, isChunked, isRepeatable, isStreaming, isUnmodifiable, writeTo
-
Constructor Details
-
StreamResource
public StreamResource()Constructor. -
StreamResource
Constructor.- Parameters:
contentType- The entity content type.contents- The entity contents.
-
StreamResource
Copy constructor.- Parameters:
copyFrom- The bean being copied.
-
-
Method Details
-
addHeader
Description copied from class:BasicResourceAppends the specified header to the end of the headers in this builder.This is a no-op if either the name or value is
null .- Overrides:
addHeaderin classBasicResource- Parameters:
name- The header name.value- The header value.- Returns:
- This object.
-
addHeaders
Description copied from class:BasicResourceAppends the specified headers to the end of the headers in this builder.- Overrides:
addHeadersin classBasicResource- Parameters:
values- The headers to set.null headers and headers withnull names or values are ignored.- Returns:
- This object.
-
copy
Description copied from class:BasicResourceCreates a builder for this class initialized with the contents of this bean.Allows you to create a modifiable copy of this bean.
- Overrides:
copyin classBasicResource- Returns:
- A new builder bean.
-
setCached
Description copied from class:BasicResourceSpecifies that the contents of this resource should be cached into an internal byte array so that it can be read multiple times.- Overrides:
setCachedin classBasicResource- Returns:
- This object.
- Throws:
IOException- If entity could not be read into memory.
-
setChunked
Description copied from class:BasicResourceSets the 'chunked' flag value totrue .Notes:
- If the
HttpEntity.getContentLength()method returns a negative value, the HttpClient code will always use chunked encoding.
- Overrides:
setChunkedin classBasicResource- Returns:
- This object.
- If the
-
setChunked
Description copied from class:BasicResourceSets the 'chunked' flag value.Notes:
- If the
HttpEntity.getContentLength()method returns a negative value, the HttpClient code will always use chunked encoding.
- Overrides:
setChunkedin classBasicResource- Parameters:
value- The new value for this flag.- Returns:
- This object.
- If the
-
setContent
Description copied from class:BasicResourceSets the content on this entity bean.- Overrides:
setContentin classBasicResource- Parameters:
value- The entity content, can benull .- Returns:
- This object.
-
setContent
Description copied from class:BasicResourceSets the content on this entity bean from a supplier.Repeatable entities such as
StringEntityuse this to allow the entity content to be resolved at serialization time.- Overrides:
setContentin classBasicResource- Parameters:
value- The entity content, can benull .- Returns:
- This object.
-
setContentEncoding
Description copied from class:BasicResourceSets the content encoding header on this entity bean.- Overrides:
setContentEncodingin classBasicResource- Parameters:
value- The newContent-Encoding header, ornull to unset.- Returns:
- This object.
-
setContentEncoding
Description copied from class:BasicResourceSets the content encoding header on this entity bean.- Overrides:
setContentEncodingin classBasicResource- Parameters:
value- The newContent-Encoding header, ornull to unset.- Returns:
- This object.
-
setContentLength
Description copied from class:BasicResourceSets the content length on this entity bean.- Overrides:
setContentLengthin classBasicResource- Parameters:
value- The newContent-Length header value, or-1 to unset.- Returns:
- This object.
-
setContentType
Description copied from class:BasicResourceSets the content type on this entity bean.- Overrides:
setContentTypein classBasicResource- Parameters:
value- The newContent-Type header, ornull to unset.- Returns:
- This object.
-
setContentType
Description copied from class:BasicResourceSets the content type on this entity bean.- Overrides:
setContentTypein classBasicResource- Parameters:
value- The newContent-Type header, ornull to unset.- Returns:
- This object.
-
setHeader
Description copied from class:BasicResourceSets the specified header in this builder.This is a no-op if either the name or value is
null .- Overrides:
setHeaderin classBasicResource- Parameters:
name- The header name.value- The header value.- Returns:
- This object.
-
setHeaders
Description copied from class:BasicResourceSets the specified headers in this builder.- Overrides:
setHeadersin classBasicResource- Parameters:
values- The headers to add.null values are ignored.- Returns:
- This object.
-
setHeaders
Description copied from class:BasicResourceSets the specified headers in this builder.- Overrides:
setHeadersin classBasicResource- Parameters:
value- The new value.- Returns:
- This object.
-
setUnmodifiable
Description copied from class:BasicResourceSpecifies whether this bean should be unmodifiable.When enabled, attempting to set any properties on this bean will cause an
UnsupportedOperationException.- Overrides:
setUnmodifiablein classBasicResource- Returns:
- This object.
-