Class ResourceHttpContent

java.lang.Object
org.eclipse.jetty.http.content.ResourceHttpContent
All Implemented Interfaces:
HttpContent

public class ResourceHttpContent extends Object implements HttpContent
HttpContent created from a Resource.

The HttpContent is used to server static content that is not cached. So fields and values are only generated as need be an not kept for reuse

  • Constructor Details

  • Method Details

    • getContentType

      public HttpField getContentType()
      Description copied from interface: HttpContent
      Get the HttpHeader.CONTENT_TYPE of this HTTP content.
      Specified by:
      getContentType in interface HttpContent
      Returns:
      the content type field, or null if the type of this content is not known.
    • getContentEncoding

      public HttpField getContentEncoding()
      Description copied from interface: HttpContent
      Get the HttpHeader.CONTENT_ENCODING of this HTTP content.
      Specified by:
      getContentEncoding in interface HttpContent
      Returns:
      the content encoding field, or null if the encoding of this content is not known.
    • getCharacterEncoding

      public String getCharacterEncoding()
      Description copied from interface: HttpContent
      Get the character encoding of this HTTP content.
      Specified by:
      getCharacterEncoding in interface HttpContent
      Returns:
      the character encoding, or null if the character encoding of this content is not known.
    • getMimeType

      public MimeTypes.Type getMimeType()
      Description copied from interface: HttpContent
      Get the Mime type of this HTTP content.
      Specified by:
      getMimeType in interface HttpContent
      Returns:
      the mime type, or null if the mime type of this content is not known.
    • getLastModifiedInstant

      public Instant getLastModifiedInstant()
      Description copied from interface: HttpContent
      Get the last modified instant of this resource. Always return the most up-to-date value.
      Specified by:
      getLastModifiedInstant in interface HttpContent
      Returns:
      the last modified instant, or null if that instant of this content is not known.
      See Also:
    • getLastModified

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

      public HttpField getETag()
      Description copied from interface: HttpContent
      Get the HttpHeader.ETAG of this HTTP content.
      Specified by:
      getETag in interface HttpContent
      Returns:
      the ETag, or null if this content has no ETag.
    • getContentLength

      public HttpField getContentLength()
      Description copied from interface: HttpContent
      Get the HttpHeader.CONTENT_LENGTH of this HTTP content. The value of the returned field must always match the value returned by HttpContent.getContentLengthValue().
      Specified by:
      getContentLength in interface HttpContent
      Returns:
      the content length field, or null if the length of this content is not known.
    • getContentLengthValue

      public long getContentLengthValue()
      Description copied from interface: HttpContent
      Get the content length of this resource.
      Specified by:
      getContentLengthValue in interface HttpContent
      Returns:
      the content length of this resource, or -1 if it is not known.
      See Also:
    • getResource

      public Resource getResource()
      Description copied from interface: HttpContent
      Get the Resource backing this HTTP content.
      Specified by:
      getResource in interface HttpContent
      Returns:
      the backing resource.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeTo

      public void writeTo(Content.Sink sink, long offset, long length, Callback callback)
      Description copied from interface: HttpContent
      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.
      Specified by:
      writeTo in interface HttpContent
      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. If the length is longer than the available content, the write is truncated to the available length.
      callback - the callback to notify when writing is done.
    • getPreCompressedContentFormats

      public Set<CompressedContentFormat> getPreCompressedContentFormats()
      Description copied from interface: HttpContent
      Get available pre-compressed formats for this content.
      Specified by:
      getPreCompressedContentFormats in interface HttpContent
      Returns:
      Set of available pre-compressed formats for this content, or null if this has not been checked.