Skip to content

xinthink/dio_custom_http_adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dio_http_adapter

Pub Check Status BSD

A customized dio HttpClientAdapter based on the dart:io package, to work around the "Hostname mismatch" issue when accessing URIs with an IP address (DNS over HTTP for example).

Usage

Get an IP address of the 'pub.dev' site:

ping pub.dev
PING pub.dev (216.239.38.21) 56(84) bytes of data.
64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=1 ttl=112 time=88.7 ms

Or using a dart package like dns

Access it using dio:

final dio = Dio(BaseOptions(
  baseUrl: 'https://216.239.38.21', // uses an IP address
  headers: <String, dynamic>{
    'host': 'pub.dev', // specifies the host name
  },
))..httpClientAdapter = IoHttpClientAdapter(); // uses the customized adapter

final resp = await dio.head('/');

About

A customized dio HttpClientAdapter, to workaround the Host verification issue during SSL handshake.

Topics

Resources

License

Stars

Watchers

Forks