platform-common-utilities/packages/range_header
2024-05-21 23:08:07 +08:00
..
example Migrated to Dart 3 2023-03-26 09:47:42 +08:00
lib Migrated to Dart 3 2023-03-26 09:47:42 +08:00
test Updated range_header 2021-09-12 09:44:28 +08:00
analysis_options.yaml Added range_header, user_agent and body_parser 2021-09-12 09:23:12 +08:00
AUTHORS.md Added range_header, user_agent and body_parser 2021-09-12 09:23:12 +08:00
CHANGELOG.md Updated to min dart sdk 3.3 2024-05-21 23:08:07 +08:00
LICENSE Added range_header, user_agent and body_parser 2021-09-12 09:23:12 +08:00
melos_belatuk_range_header.iml Upgraded to support sdk 2.17 2022-07-06 22:04:09 +08:00
pubspec.yaml Updated to min dart sdk 3.3 2024-05-21 23:08:07 +08:00
README.md Updated to use lints 3.0.0 2023-12-12 10:10:10 +08:00

Belatuk Range Header

Pub Version (including pre-releases) Null Safety License

Replacement of package:range_header with breaking changes to support NNBD.

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

Installation

In your pubspec.yaml:

dependencies:
  belatuk_range_header: ^6.2.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);
}