Skip to main content
Module

x/range_request_middleware/mod.ts>BytesRange

HTTP range request middleware
Latest
class BytesRange
implements Range
import { BytesRange } from "https://deno.land/x/range_request_middleware@1.3.0/mod.ts";

Range implementation for bytes range unit. It support single and multiple range request.

Examples

Example 1

import {
  BytesRange,
  type IntRange,
  type SuffixRange,
} from "https://deno.land/x/range_request_middleware@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

const bytesRange = new BytesRange();
const rangeUnit = "bytes";
declare const initResponse: Response;
declare const rangeSet: [IntRange, SuffixRange];

const response = await bytesRange.respond(initResponse, {
  rangeUnit,
  rangeSet,
});

assertEquals(bytesRange.rangeUnit, rangeUnit);
assertEquals(response.status, 206);
assertEquals(
  response.headers.get("content-type"),
  "multipart/byteranges; boundary=<BOUNDARY>",
);

Constructors

new
BytesRange(options?: Partial<BytesContext>)

Properties

rangeUnit

Methods

respond(response: Response, context: RangesSpecifier): Response | Promise<Response>