http2_client 1.0.0

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

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:

dependencies:
  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('https://example.com');
  print(response.body);
}

1.0.0 #

  • First version.

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 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 repl.run()) {
    if (url == 'quit') break;
    var response = await client.get(url, headers: {
      'accept': '*/*',
      'accept-encoding': 'gzip, deflate',
      'user-agent':
          '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);
  }

  client.close();
}

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

Use this package as a library

1. Depend on it

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


dependencies:
  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';
  
Version Uploaded Documentation Archive
1.0.0 Jan 10, 2019 Go to the documentation of http2_client 1.0.0 Download http2_client 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
35
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

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

  • Dart: 2.3.2
  • pana: 0.12.18

Platforms

Detected platforms: Flutter, other

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

Dependencies

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.2
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
matcher 0.12.5
meta 1.1.7
path 1.6.2
quiver 2.0.3
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.4
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.7.0
test ^1.0.0