Module

x/opine/src/request.ts>WrappedRequest#range

Fast, minimalist web framework for Deno ported from ExpressJS.
Go to Latest
method WrappedRequest.prototype.range
import { WrappedRequest } from "https://dotland.deno.dev/x/opine@2.2.0/src/request.ts";

Parse Range header field, capping to the given size.

Unspecified ranges such as "0-" require knowledge of your resource length. In the case of a byte range this is of course the total number of bytes. If the Range header field is not given undefined is returned, -1 when unsatisfiable, and -2 when syntactically invalid.

When ranges are returned, the array has a "type" property which is the type of range that is required (most commonly, "bytes"). Each array element is an object with a "start" and "end" property for the portion of the range.

The "combine" option can be set to true and overlapping & adjacent ranges will be combined into a single range.

NOTE: remember that ranges are inclusive, so for example "Range: users=0-3" should respond with 4 users when available, not 3.

Parameters

size: number
optional
options: RangeParserOptions