Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

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

Minimalist web framework for Deno ported from ExpressJS.
Latest
method WrappedRequest.prototype.range
import { WrappedRequest } from "https://deno.land/x/opine@2.3.4/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