Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 1.74 KB

README.md

File metadata and controls

49 lines (37 loc) · 1.74 KB

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('/');