platform/packages/range_header
thomashii@dukefirehawk.com 3b2fc97da1 Migrated range_header
2021-05-01 11:39:09 +08:00
..
example Migrated range_header 2021-05-01 11:39:09 +08:00
lib Migrated range_header 2021-05-01 11:39:09 +08:00
test Migrated range_header 2021-05-01 11:39:09 +08:00
analysis_options.yaml Added and migrated html_builder 2021-05-01 10:48:36 +08:00
CHANGELOG.md Added and migrated html_builder 2021-05-01 10:48:36 +08:00
LICENSE Added and migrated html_builder 2021-05-01 10:48:36 +08:00
pubspec.yaml Migrated range_header 2021-05-01 11:39:09 +08:00
README.md Added and migrated html_builder 2021-05-01 10:48:36 +08:00

range_header

Pub build status

Range header parser for Dart.

Installation

In your pubspec.yaml:

dependencies:
  range_header: ^2.0.0

Usage

handleRequest(HttpRequest request) async {
  // Parse the header
  var header = new RangeHeader.parse(request.headers.value(HttpHeaders.rangeHeader));

  // Optimize/canonicalize it
  var items = RangeHeader.foldItems(header.items);
  header = new RangeHeader(items);

  // Get info
  header.items;
  header.rangeUnit;
  print(header.items[0].toContentRange(fileSize));

  // Serve the file
  var transformer = new RangeHeaderTransformer(header);
  await file.openRead().transform(transformer).pipe(request.response);
}