http2_client 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 78

http2_client #

pub package Build Status

A package:http BaseClient that speaks HTTP/2, and can maintain connections between requests.

This can be dropped into any API that uses a BaseClient, so you can seamlessly start working with HTTP/2 right away.

It also can fallback to HTTP/1.1 automatically.

Installation #

In your pubspec.yaml:

  http2_client: ^1.0.0

Example #

Also see example/main.dart.

import 'dart:io';
import 'package:cli_repl/cli_repl.dart';
import 'package:http/http.dart';
import 'package:http2_client/http2_client.dart';

main() async {
  var client = Http2Client(maxOpenConnections: Platform.numberOfProcessors);
  var response = await client.get('');

1.0.0 #

  • First version.


import 'dart:io';
import 'package:cli_repl/cli_repl.dart';
import 'package:http/http.dart';
import 'package:http2_client/http2_client.dart';

main() async {
  var client = Http2Client(maxOpenConnections: Platform.numberOfProcessors);
  var repl = Repl(prompt: 'Enter a URL, or "quit": ');

  client.onPush.listen((tuple) async {
    print('PUSH FROM ${tuple.item1}');
    dumpResponse(tuple.item1, await Response.fromStream(tuple.item2));

  for (var url in {
    if (url == 'quit') break;
    var response = await client.get(url, headers: {
      'accept': '*/*',
      'accept-encoding': 'gzip, deflate',
          'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
    dumpResponse(url, response);


void dumpResponse(url, Response response) {
  print('Response from $url: ${response.statusCode} ${response.reasonPhrase}');
  response.headers.forEach((k, v) {
    print('$k: $v');

Use this package as a library

1. Depend on it

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

  http2_client: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:http2_client/http2_client.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms: Flutter, other

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


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.0+2
http2 ^1.0.0 1.0.0
http_parser ^3.0.0 3.1.3
tuple ^1.0.0 1.0.3
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
matcher 0.12.6
meta 1.1.8
path 1.6.4
quiver 2.1.2+1
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
angel_framework ^2.0.0-alpha
cli_repl any
pedantic ^1.0.0 1.8.0+1
test ^1.0.0