platform/packages/range_header
2021-09-12 20:17:05 +08:00
..
example Updated range_header 2021-05-18 19:58:51 +08:00
lib Updated range_header 2021-05-18 19:58:51 +08:00
test Updated range_header 2021-05-18 19:58:51 +08:00
analysis_options.yaml Updated range_header 2021-05-18 19:58:51 +08:00
AUTHORS.md Updated authors and license 2021-05-15 16:48:20 +08:00
CHANGELOG.md Deprecated range_header 2021-09-12 20:17:05 +08:00
LICENSE Updated license 2021-06-14 11:52:58 +08:00
pubspec.yaml Deprecated range_header 2021-09-12 20:17:05 +08:00
README.md Deprecated range_header 2021-09-12 20:17:05 +08:00

Angel3 Range Header

version Null Safety Gitter

License

DEPRECATED: Replaced by belatuk_range_header package

Range header parser for Angel3. Can be used by any dart backend.

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);
}