platform/packages/range_header
2021-05-15 19:58:09 +08:00
..
example Publish range_header 2021-05-15 19:58:09 +08:00
lib Publish range_header 2021-05-15 19:58:09 +08:00
test Publish range_header 2021-05-15 19:58:09 +08:00
.gitignore Updated authors and license 2021-05-15 16:48:20 +08:00
analysis_options.yaml Added and migrated html_builder 2021-05-01 10:48:36 +08:00
AUTHORS.md Updated authors and license 2021-05-15 16:48:20 +08:00
CHANGELOG.md Added AUTHORS.md 2021-05-02 12:12:43 +08:00
LICENSE Updated authors and license 2021-05-15 16:48:20 +08:00
pubspec.yaml Publish range_header 2021-05-15 19:58:09 +08:00
README.md Publish range_header 2021-05-15 19:58:09 +08:00

angel3_range_header

version Null Safety Gitter

License

Range header parser for Dart.

Installation

In your pubspec.yaml:

dependencies:
  angel3_range_header: ^3.0.0

Usage

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

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

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

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