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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dart): add Dio HttpClientAdapter to ClientOptions #3290

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

techouse
Copy link

@techouse techouse commented Jul 1, 2024

馃Л What and Why

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

final SearchClient client = SearchClient(
  appId: 'foo',
  apiKey: 'bar',
  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.

Changes included:

  • add HttpClientAdapter? to ClientOptions

Supersedes algolia/algoliasearch-client-dart#13
Addresses algolia/algoliasearch-client-dart#12

@techouse techouse requested a review from a team as a code owner July 1, 2024 07:19
@techouse techouse requested review from Fluf22 and shortcuts July 1, 2024 07:19
@techouse techouse changed the title feat(dart): Add Dio HttpClientAdapter to ClientOptions feat(dart): add Dio HttpClientAdapter to ClientOptions Jul 1, 2024
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks awesome, thanks a lot for the contribution

@aallam wdyt?

@techouse
Copy link
Author

techouse commented Jul 1, 2024

Not sure why the codegen job fails 馃槄

@shortcuts
Copy link
Member

shortcuts commented Jul 1, 2024

Not sure why the codegen job fails 馃槄

ah we provide a ref to the checkout action which might not work with forks D:

@techouse
Copy link
Author

techouse commented Jul 1, 2024

Not sure why the codegen job fails 馃槄

ah we provide a ref to the checkout action which might not work with forks D:

Ah, makes sense. Bots and their permissions 馃檲

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

2 participants