Package org.apache.tapestry5.internal.services

# Interface ResourceStreamer

All Known Implementing Classes:
  `ResourceStreamerImpl`

public interface ResourceStreamer
Responsible for streaming the contents of a resource to the client. This is sometimes a simple `Resource` (often from the `ModuleDispatcher`, or more frequently an asset represented as a `StreamableResource` (via `AssetDispatcher`, `AssetRequestHandler`, and `StreamableResourceSource`). As of 5.4, the ResourceStreamer handles ETag support, as well as validation of the checksum (provided in the URL).

Since:
  5.1.0.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static enum`
  `ResourceStreamer.Options`
  Used to customize the behavior of `streamResource(org.apache.tapestry5.commons.Resource, java.lang.String, java.util.Set)`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Set<ResourceStreamer.Options>`
  `DEFAULT_OPTIONS`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `streamResource(Resource resource, String providedChecksum, Set<ResourceStreamer.Options> options)`
  Streams the content of the resource to the client (or sends an alternative response such as `HttpServletResponse.SC_NOT_MODIFIED`).
  `boolean`
  `streamResource(StreamableResource resource, String providedChecksum, Set<ResourceStreamer.Options> options)`
  Streams a resource that has been assembled elsewhere.

- ## Field Details

  - ### DEFAULT_OPTIONS

    static final Set<ResourceStreamer.Options> DEFAULT_OPTIONS

- ## Method Details

  - ### streamResource

    boolean streamResource(Resource resource, String providedChecksum, Set<ResourceStreamer.Options> options) throws IOException
    Streams the content of the resource to the client (or sends an alternative response such as `HttpServletResponse.SC_NOT_MODIFIED`). Encapsulates logic for compression and for caching.
    Parameters:
      `resource` - to stream
      `providedChecksum` - checksum from URL (or null/blank to not validate against checksum, which is normal for modules)
      `options` - enable or disable certain features
    Throws:
      `IOException`
    See Also:
      - `StreamableResourceSource`

  - ### streamResource

    boolean streamResource(StreamableResource resource, String providedChecksum, Set<ResourceStreamer.Options> options) throws IOException
    Streams a resource that has been assembled elsewhere. The StreamableResource may reflect either a normal or a compressed stream, depending on the type of resource and the capabilities of the client.
    Parameters:
      `resource` - content to stream
      `providedChecksum` - checksum provided (in the URL) to validate against the StreamableResource.getChecksum() actual checksum} for the resource, may be null/blank to not validate against the checksum
      `options` - enable or disable certain features
    Returns:
      true if the request was handled (even if sending a `HttpServletResponse.SC_NOT_MODIFIED` response), or false if the request was not handled (because the provided checksum did not match the actual checksum).
    Throws:
      `IOException`
    Since:
      5.4