Skip to main content

@std/http@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)

Provides functions for dealing with and matching ETags, including calculate to calculate an etag for a given entity, ifMatch for validating if an ETag matches against a If-Match header and ifNoneMatch for validating an Etag against an If-None-Match header.

See further information on the ETag header on MDN.

Functions

f
calculate(
entity: Entity,
options?: ETagOptions
): Promise<string | undefined>

Calculate an ETag for an entity. When the entity is a specific set of data it will be fingerprinted as a "strong" tag, otherwise if it is just file information, it will be calculated as a weak tag.

f
ifMatch(
value: string | null,
etag: string | undefined
): boolean

A helper function that takes the value from the If-Match header and a calculated etag for the target. By using strong comparison, return true if the values match, otherwise false.

f
ifNoneMatch(
value: string | null,
etag: string | undefined
): boolean

A helper function that takes the value from the If-None-Match header and a calculated etag for the target entity and returns false if the etag for the entity matches the supplied value, otherwise true.

Interfaces

I

Options for calculate.

  • algorithm: AlgorithmIdentifier

    A digest algorithm to use to calculate the etag.

  • weak: boolean

    Override the default behavior of calculating the ETag, either forcing a tag to be labelled weak or not.

I

Just the part of Deno.FileInfo that is required to calculate an ETag, so partial or user generated file information can be passed.

  • mtime: Date | null

    The last modification time of the file. This corresponds to the mtime field from stat on Linux/Mac OS and ftLastWriteTime on Windows. This may not be available on all platforms.

  • size: number

    The size of the file, in bytes.

Type Aliases

T
Entity = string | Uint8Array | FileInfo

Represents an entity that can be used for generating an ETag.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/http

Import symbol

import * as mod from "@std/http/etag";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/http/etag";