RangeRequestsPlugin.d.ts 1.0 KB

1234567891011121314151617181920212223242526
  1. import { WorkboxPlugin } from 'workbox-core/types.js';
  2. import './_version.js';
  3. /**
  4. * The range request plugin makes it easy for a request with a 'Range' header to
  5. * be fulfilled by a cached response.
  6. *
  7. * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback
  8. * and returning the appropriate subset of the cached response body.
  9. *
  10. * @memberof module:workbox-range-requests
  11. */
  12. declare class RangeRequestsPlugin implements WorkboxPlugin {
  13. /**
  14. * @param {Object} options
  15. * @param {Request} options.request The original request, which may or may not
  16. * contain a Range: header.
  17. * @param {Response} options.cachedResponse The complete cached response.
  18. * @return {Promise<Response>} If request contains a 'Range' header, then a
  19. * new response with status 206 whose body is a subset of `cachedResponse` is
  20. * returned. Otherwise, `cachedResponse` is returned as-is.
  21. *
  22. * @private
  23. */
  24. cachedResponseWillBeUsed: WorkboxPlugin['cachedResponseWillBeUsed'];
  25. }
  26. export { RangeRequestsPlugin };