Skip to content
Branch: master
Find file History
Latest commit e5c0343 Sep 18, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
example update to 3.0 Sep 18, 2019
lib update to 3.0 Sep 18, 2019
test update doc Sep 17, 2019
.gitignore 1. Support Flutter Web Sep 17, 2019
.metadata 1. Support Flutter Web Sep 17, 2019
CHANGELOG.md update to 3.0 Sep 18, 2019
LICENSE 1. Support Flutter Web Sep 17, 2019
README.md update to 3.0 Sep 18, 2019
pubspec.yaml update to 3.0 Sep 18, 2019

README.md

Http2Adapter Pub

A Dio HttpClientAdapter which implements Http/2.0 .

Getting Started

Install

dependencies:
  dio_http2_adapter: x.x.x  #latest version

Usage

import 'package:dio/dio.dart';
import 'package:dio_http2_adapter/http2.dart'; 

main() async {
  var dio = Dio()
    ..options.baseUrl = "https://www.ustc.edu.cn/"
    ..httpClientAdapter = Http2Adapter();

  Response<String> response;
  response = await dio.get("/?xx=6");
  print(response.data);
  response = await dio.get("2062/list.htm");
  print(response.data);
}

ConnectionManager

ConnectionManager is used to manager the connections that should be reusable. The main responsibility of ConnectionManager is to implement a connection reuse strategy for http2.

dio.httpClientAdapter = Http2Adapter(
  ConnectionManager(
    idleTimeout: 10000,
    /// Ignore bad certificate
    onClientCreate: (_, clientSetting) => clientSetting.onBadCertificate = (_) => true,
  ),
);
  • idleTimeout: Sets the idle timeout(milliseconds) of non-active persistent connections. For the sake of socket reuse feature with http/2, the value should not be less than 1000 (1s).
  • onClientCreate:Callback when socket created. We can set trusted certificates and handler for unverifiable certificates.

You can also custom a connection manager with a specific connection reuse strategy by implementing the ConnectionManager.

You can’t perform that action at this time.