platform/common/range_header
2024-12-14 20:56:05 -07:00
..
example refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07:00
lib refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07:00
test refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07:00
analysis_options.yaml refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07:00
AUTHORS.md refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07:00
CHANGELOG.md refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07:00
LICENSE refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07:00
pubspec.lock refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07:00
pubspec.yaml refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07:00
README.md refactor: refactoring common utils, routes > routing, db drivers 2024-12-14 20:56:05 -07: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:
  platform_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);
}