Interface HttpResource

All Superinterfaces:
All Known Implementing Classes:
BasicResource, ByteArrayResource, FileResource, ReaderResource, StreamResource, StringResource

public interface HttpResource extends HttpEntity
An extension of an HttpEntity that also includes arbitrary headers.

While HttpEntity beans support Content-Type, Content-Encoding, and Content-Length headers, this interface allows you to add any number of arbitrary headers to an entity.

For example, you might want to be able to create an entity with a Cache-Control header.

import static org.apache.juneau.http.HttpResources.*; // Create a resource with dynamic content and a no-cache header. HttpResource myResource = stringResource(()->getMyContent(), ContentType.TEXT_PLAIN) .header("Cache-Control", "no-cache") .build();

See Also:
  • Method Details

    • getHeaders

      Returns the list of headers associated with this resource.

      Note that this typically does NOT include headers associated with HttpEntity (e.g. Content-Type, Content-Encoding, and Content-Length).

      The list of headers associated with this resource.