belatuk_range_header 4.0.1
belatuk_range_header: ^4.0.1 copied to clipboard

Range header parser for Dart. Beyond parsing, a stream transformer is included.

Belatuk Range Header #

version 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: ^4.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);
}
0
likes
120
pub points
26%
popularity

Publisher

dukefirehawk.com

Range header parser for Dart. Beyond parsing, a stream transformer is included.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

async, charcode, quiver, source_span, string_scanner

More

Packages that depend on belatuk_range_header