range_header 2.0.2+2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 58

range_header #

Pub build status

Range header parser for Dart.

Installation #

In your pubspec.yaml:

dependencies:
  range_header: ^2.0.0

Usage #

handleRequest(HttpRequest request) async {
  // Parse the header
  var header = new RangeHeader.parse(request.headers.value(HttpHeaders.rangeHeader));

  // Optimize/canonicalize it
  var items = RangeHeader.foldItems(header.items);
  header = new RangeHeader(items);

  // Get info
  header.items;
  header.rangeUnit;
  print(header.items[0].toContentRange(fileSize));

  // Serve the file
  var transformer = new RangeHeaderTransformer(header);
  await file.openRead().transform(transformer).pipe(request.response);
}

2.0.2 #

  • Fix bug in toContentRange that printed invalid indices.
  • Fold header items by default.

2.0.1 #

  • Adjust RangeHeaderTransformer to properly print the content range of each item, when multiple are present.

2.0.0 #

  • Dart 2 update.
  • Add RangeHeaderTransformer.
  • Overall restructuring/refactoring.

example/main.dart

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

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

handleRequest(HttpRequest request) async {
  // Parse the header
  var header =
      new RangeHeader.parse(request.headers.value(HttpHeaders.rangeHeader));

  // Optimize/canonicalize it
  var items = RangeHeader.foldItems(header.items);
  header = new RangeHeader(items);

  // Get info
  header.items;
  header.rangeUnit;
  header.items.forEach((item) => item.toContentRange(400));

  // Serve the file
  var transformer =
      new RangeHeaderTransformer(header, 'video/mp4', await file.length());
  await file.openRead().transform(transformer).pipe(request.response);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  range_header: ^2.0.2+2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:range_header/range_header.dart';
  
Version Uploaded Documentation Archive
2.0.2+2 Jan 28, 2019 Go to the documentation of range_header 2.0.2+2 Download range_header 2.0.2+2 archive
2.0.2+1 Jan 28, 2019 Go to the documentation of range_header 2.0.2+1 Download range_header 2.0.2+1 archive
2.0.2 Jan 28, 2019 Go to the documentation of range_header 2.0.2 Download range_header 2.0.2 archive
2.0.1 Nov 14, 2018 Go to the documentation of range_header 2.0.1 Download range_header 2.0.1 archive
2.0.0 Nov 14, 2018 Go to the documentation of range_header 2.0.0 Download range_header 2.0.0 archive
1.0.0 Jun 11, 2017 Go to the documentation of range_header 1.0.0 Download range_header 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
17
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

We analyzed this package on Apr 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, other

Primary library: package:range_header/range_header.dart with components: io.

Health suggestions

Fix lib/src/converter.dart. (-1.49 points)

Analysis of lib/src/converter.dart reported 3 hints:

line 144 col 7: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 153 col 16: Use = to separate a named parameter from its default value.

line 154 col 22: Use = to separate a named parameter from its default value.

Fix lib/src/range_header.dart. (-1 points)

Analysis of lib/src/range_header.dart reported 2 hints:

line 41 col 53: Use = to separate a named parameter from its default value.

line 58 col 58: Use = to separate a named parameter from its default value.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
async ^2.0.0 2.2.0
charcode ^1.0.0 1.1.2
quiver_hashcode ^2.0.0 2.0.0
source_span ^1.0.0 1.5.5
string_scanner ^1.0.0 1.0.4
Transitive dependencies
collection 1.14.11
meta 1.1.7
path 1.6.2
term_glyph 1.1.0
Dev dependencies
angel_framework any
angel_static ^2.0.0
file any
http_parser ^3.0.0
logging ^0.11.0
test ^1.0.0