Interface HttpContent

All Known Subinterfaces:
CachingHttpContentFactory.CachingHttpContent
All Known Implementing Classes:
CachingHttpContentFactory.CachedHttpContent, CachingHttpContentFactory.NotFoundHttpContent, HttpContent.Wrapper, PreCompressedHttpContent, ResourceHttpContent, ValidatingCachingHttpContentFactory.ValidatingCachedContent, ValidatingCachingHttpContentFactory.ValidatingNotFoundContent

public interface HttpContent

The HttpContent interface represents all the information about a static Resource that is needed to evaluate conditional headers and to eventually serve the actual content. It can be implemented either transiently (values and fields generated on demand) or persistently (values and fields pre-generated in anticipation of reuse in from a cache).

  • Method Details

    • getContentType

      HttpField getContentType()
      Get the HttpHeader.CONTENT_TYPE of this HTTP content.
      Returns:
      the content type field, or null if the type of this content is not known.
    • getContentEncoding

      HttpField getContentEncoding()
      Get the HttpHeader.CONTENT_ENCODING of this HTTP content.
      Returns:
      the content encoding field, or null if the encoding of this content is not known.
    • getContentLength

      HttpField getContentLength()
      Get the HttpHeader.CONTENT_LENGTH of this HTTP content. The value of the returned field must always match the value returned by getContentLengthValue().
      Returns:
      the content length field, or null if the length of this content is not known.
    • getLastModified

      HttpField getLastModified()
      Get the HttpHeader.LAST_MODIFIED of this HTTP content. The value of the returned field must always match the value returned by getLastModifiedInstant().
      Returns:
      the last modified field, or null if the last modification time of this content is not known.
    • getETag

      HttpField getETag()
      Get the HttpHeader.ETAG of this HTTP content.
      Returns:
      the ETag, or null if this content has no ETag.
    • getCharacterEncoding

      String getCharacterEncoding()
      Get the character encoding of this HTTP content.
      Returns:
      the character encoding, or null if the character encoding of this content is not known.
    • getMimeType

      MimeTypes.Type getMimeType()
      Get the Mime type of this HTTP content.
      Returns:
      the mime type, or null if the mime type of this content is not known.
    • getLastModifiedInstant

      Instant getLastModifiedInstant()
      Get the last modified instant of this resource.
      Returns:
      the last modified instant, or null if that instant of this content is not known.
      See Also:
    • getContentLengthValue

      long getContentLengthValue()
      Get the content length of this resource.
      Returns:
      the content length of this resource, or -1 if it is not known.
      See Also:
    • getResource

      Resource getResource()
      Get the Resource backing this HTTP content.
      Returns:
      the backing resource.
    • writeTo

      void writeTo(Content.Sink sink, long offset, long length, Callback callback)
      Asynchronously write a subset of this HTTP content to a Content.Sink. Calling this method does not consume the content, so it can be used repeatedly.
      Parameters:
      sink - the sink to write to.
      offset - the offset byte of the resource to start from.
      length - the length of the resource's contents to copy, -1 for the full length.
      callback - the callback to notify when writing is done.
    • getPreCompressedContentFormats

      Set<CompressedContentFormat> getPreCompressedContentFormats()
      Get available pre-compressed formats for this content.
      Returns:
      Set of available pre-compressed formats for this content, or null if this has not been checked.
    • getContentTypeValue

      default String getContentTypeValue()
    • getContentEncodingValue

      default String getContentEncodingValue()
    • getETagValue

      default String getETagValue()