public class BasicHttpResource extends BasicHttpEntity implements HttpResource
HttpEntity
with support for arbitrary headers.
Provides the following features:
Suppliers
.
chunked, contentEncoding, contentType, OUTPUT_BUFFER_SIZE
Constructor and Description |
---|
BasicHttpResource(Object content)
Constructor.
|
BasicHttpResource(Object content,
ContentType contentType,
ContentEncoding contentEncoding)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
BasicHttpResource |
cache()
Specifies that the contents of this resource should be cached into an internal byte array so that it can
be read multiple times.
|
BasicHttpResource |
cache(boolean value)
Specifies that the contents of this resource should be cached into an internal byte array so that it can
be read multiple times.
|
BasicHttpResource |
chunked()
Shortcut for calling
AbstractHttpEntity.setChunked(boolean) with |
BasicHttpResource |
chunked(boolean value)
Shortcut for calling
AbstractHttpEntity.setChunked(boolean) . |
BasicHttpResource |
contentEncoding(Header value)
Shortcut for calling
AbstractHttpEntity.setContentEncoding(Header) . |
BasicHttpResource |
contentEncoding(String value)
Shortcut for calling
AbstractHttpEntity.setContentEncoding(String) . |
BasicHttpResource |
contentLength(long value)
Shortcut for calling
BasicHttpEntity.setContentLength(long) . |
BasicHttpResource |
contentType(Header value)
Shortcut for calling
AbstractHttpEntity.setContentType(Header) . |
BasicHttpResource |
contentType(String value)
Shortcut for calling
AbstractHttpEntity.setContentType(String) . |
Header |
getFirstHeader(String name)
Returns the first header with the specified name as a string.
|
List<Header> |
getHeaders()
Returns the list of headers associated with this resource.
|
Header |
getLastHeader(String name)
Returns the last header with the specified name as a string.
|
String |
getStringHeader(String name)
Returns the first header with the specified name as a string.
|
BasicHttpResource |
header(Header value)
Adds an arbitrary header to this resource.
|
BasicHttpResource |
header(String name,
Object val)
Adds an arbitrary header to this resource.
|
BasicHttpResource |
headers(Header... headers)
Adds an arbitrary collection of headers to this resource.
|
BasicHttpResource |
headers(List<Header> headers)
Adds an arbitrary collection of headers to this resource.
|
static BasicHttpResource |
of(Object content)
Creator.
|
static BasicHttpResource |
of(Supplier<?> content)
Creator.
|
asBytes, assertBytes, assertString, asString, getContent, getContentLength, getRawContent, isCacheable, isRepeatable, isStreaming, readBytes, unwrap, writeTo
setContent, setContentLength
consumeContent, getContentEncoding, getContentType, isChunked, setChunked, setContentEncoding, setContentEncoding, setContentType, setContentType, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
consumeContent, getContent, getContentEncoding, getContentLength, getContentType, isChunked, isRepeatable, isStreaming, writeTo
public BasicHttpResource(Object content)
content
- The content.
Supplier
of anything on this list.
public BasicHttpResource(Object content, ContentType contentType, ContentEncoding contentEncoding)
content
- The content.
Supplier
of anything on this list.
contentType
- The content type of the contents.
contentEncoding
- The content encoding of the contents.
public static BasicHttpResource of(Object content)
content
- The content.
Supplier
of anything on this list.
BasicHttpResource
object.public static BasicHttpResource of(Supplier<?> content)
content
- The content.
Supplier
of anything on this list.
BasicHttpResource
object.public BasicHttpResource header(String name, Object val)
Header is not added if name or value is null.
name
- The header name.val
- The header value.public BasicHttpResource header(Header value)
value
- The header.public BasicHttpResource headers(List<Header> headers)
headers
- The headers to add to this resource.public BasicHttpResource headers(Header... headers)
headers
- The headers to add to this resource.public String getStringHeader(String name)
name
- The header name.public Header getFirstHeader(String name)
name
- The header name.public Header getLastHeader(String name)
name
- The header name.public List<Header> getHeaders()
HttpResource
getHeaders
in interface HttpResource
public BasicHttpResource cache()
BasicHttpEntity
cache
in class BasicHttpEntity
public BasicHttpResource cache(boolean value)
BasicHttpEntity
cache
in class BasicHttpEntity
value
- The new value for this flag.public BasicHttpResource chunked()
BasicHttpEntity
AbstractHttpEntity.setChunked(boolean)
with BasicHttpEntity.getContentLength()
method returns a negative value, the HttpClient code will always
use chunked encoding.
chunked
in class BasicHttpEntity
public BasicHttpResource chunked(boolean value)
BasicHttpEntity
AbstractHttpEntity.setChunked(boolean)
.
BasicHttpEntity.getContentLength()
method returns a negative value, the HttpClient code will always
use chunked encoding.
chunked
in class BasicHttpEntity
value
- The new value for this flag.public BasicHttpResource contentEncoding(String value)
BasicHttpEntity
AbstractHttpEntity.setContentEncoding(String)
.contentEncoding
in class BasicHttpEntity
value
- The new public BasicHttpResource contentEncoding(Header value)
BasicHttpEntity
AbstractHttpEntity.setContentEncoding(Header)
.contentEncoding
in class BasicHttpEntity
value
- The new public BasicHttpResource contentLength(long value)
BasicHttpEntity
BasicHttpEntity.setContentLength(long)
.contentLength
in class BasicHttpEntity
value
- The new public BasicHttpResource contentType(String value)
BasicHttpEntity
AbstractHttpEntity.setContentType(String)
.contentType
in class BasicHttpEntity
value
- The new public BasicHttpResource contentType(Header value)
BasicHttpEntity
AbstractHttpEntity.setContentType(Header)
.contentType
in class BasicHttpEntity
value
- The new Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.