angel3_range_header 3.0.2 copy "angel3_range_header: ^3.0.2" to clipboard
angel3_range_header: ^3.0.2 copied to clipboard

discontinuedreplaced by: belatuk_range_header
outdated

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

example/main.dart

import 'dart:io';
import 'package:angel3_range_header/angel3_range_header.dart';

var file = File('some_video.mp4');

void 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;
  header.items.forEach((item) => item.toContentRange(400));

  // Serve the file
  var transformer =
      RangeHeaderTransformer(header, 'video/mp4', await file.length());
  await file
      .openRead()
      .cast<List<int>>()
      .transform(transformer)
      .pipe(request.response);
}
0
likes
130
pub points
0%
popularity

Publisher

verified publisherdukefirehawk.com

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

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

async, charcode, quiver, source_span, string_scanner

More

Packages that depend on angel3_range_header