Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Dio HttpClientAdapter to ClientOptions #13

Closed
wants to merge 2 commits into from

Conversation

techouse
Copy link

@techouse techouse commented Jun 29, 2024

This PR gives the user the ability to optionally provide a custom Dio HttpClientAdapter, i.e.

final SearchClient client = SearchClient(
  appId: 'latency',
  apiKey: '6be0576ff61c053d5f9a3225e2a90f76',
  defaultHosts: () => const [
    Host(url: 'latency-dsn.algolia.net'),
    Host(url: 'latency-1.algolianet.com'),
  ],
  options: ClientOptions(
    httpClientAdapter: NativeAdapter(), // <-- from https://pub.dev/packages/native_dio_adapter
  ),
);

Via this option users can configure Dio to use native_dio_adapter which uses cupertino_http on iOS and cronet_http on Android to delegate HTTP requests to the native platform instead of the dart:io platforms.

The advantages of using cronet_http are:

  • It automatically supports Android platform features such as HTTP proxies.
  • It supports configurable caching.
  • It supports more HTTP features such as HTTP/3.

The advantages of using cupertino_http are:

  • It automatically supports iOS/macOS platform features such VPNs and HTTP proxies.
  • It supports many more configuration options such as only allowing access through WiFi and blocking cookies.
  • It supports more HTTP features such as HTTP/3 and custom redirect handling.

Addresses #12

@techouse techouse changed the title feat: Dio httpClientAdapter feat: Add Dio HttpClientAdapter to ClientOptions Jun 29, 2024
@techouse
Copy link
Author

techouse commented Jul 1, 2024

Superseded by algolia/api-clients-automation#3290

@techouse techouse closed this Jul 1, 2024
@techouse techouse deleted the feat/http-client-adapter branch July 1, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant