@otterhttp/etag
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

@otterhttp/etag

npm (scoped) npm

A rewrite of etag module.

This module generates HTTP ETags (as defined in RFC 7232) for use in HTTP responses.

Install

pnpm i @otterhttp/etag

API

import { eTag } from '@otterhttp/etag'

eTag(entity, [options])

Generate a strong ETag for the given entity. This should be the complete body of the entity. Strings, Buffers, and fs.Stats are accepted. By default, a strong ETag is generated except for fs.Stats, which will generate a weak ETag (this can be overwritten by options.weak).

res.setHeader('ETag', eTag(body))

Options

eTag accepts these properties in the options object.

weak

Specifies if the generated ETag will include the weak validator mark (that is, the leading W/). The actual entity tag is the same. The default value is false, unless the entity is fs.Stats, in which case it is true.

Package Sidebar

Install

npm i @otterhttp/etag

Weekly Downloads

34

Version

3.0.0

License

LGPL-3.0-or-later

Unpacked Size

3.94 kB

Total Files

6

Last publish

Collaborators

  • lordfirespeed