dio_http2_adapter 2.5.3 copy "dio_http2_adapter: ^2.5.3" to clipboard
dio_http2_adapter: ^2.5.3 copied to clipboard

An adapter that combines HTTP/2 and dio. Supports reusing connections, header compression, etc.

dio_http2_adapter #

Pub

An adapter that combines HTTP/2 and dio. Supports reusing connections, header compression, etc.

Getting Started #

Install #

Add the dio_http2_adapter package to your pubspec dependencies.

Usage #

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

void main() async {
  final dio = Dio()
    ..options.baseUrl = 'https://pub.dev'
    ..interceptors.add(LogInterceptor())
    ..httpClientAdapter = Http2Adapter(
      ConnectionManager(idleTimeout: Duration(seconds: 10)),
    );

  Response<String> response;
  response = await dio.get('/?xx=6');
  for (final e in response.redirects) {
    print('redirect: ${e.statusCode} ${e.location}');
  }
  print(response.data);
}

Ignoring a bad certificate #

void main() async {
  final dio = Dio()
    ..options.baseUrl = 'https://pub.dev'
    ..interceptors.add(LogInterceptor())
    ..httpClientAdapter = Http2Adapter(
      ConnectionManager(
        idleTimeout: Duration(seconds: 10),
        onClientCreate: (_, config) => config.onBadCertificate = (_) => true,
      ),
    );
}

Configuring the proxy #

void main() async {
  final dio = Dio()
    ..options.baseUrl = 'https://pub.dev'
    ..interceptors.add(LogInterceptor())
    ..httpClientAdapter = Http2Adapter(
      ConnectionManager(
        idleTimeout: Duration(seconds: 10),
        onClientCreate: (_, config) =>
            config.proxy = Uri.parse('http://login:password@192.168.0.1:8888'),
      ),
    );
}
41
likes
140
points
242k
downloads

Publisher

verified publisherflutter.cn

Weekly Downloads

An adapter that combines HTTP/2 and dio. Supports reusing connections, header compression, etc.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#dio #http2 #native #network

Documentation

API reference

License

MIT (license)

Dependencies

dio, http2, meta

More

Packages that depend on dio_http2_adapter