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

Closed
wants to merge 6 commits into from

Conversation

techouse
Copy link
Contributor

@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
Contributor 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
Contributor 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 馃檲

Copy link
Member

@aallam aallam left a comment

Choose a reason for hiding this comment

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

Nice! we already have interceptors, and I see no issue of adding HttpClientAdapter too.

@shortcuts
Copy link
Member

All CTS should fail because of e2e, I'll open a PR with your commits and merge them into main

@shortcuts
Copy link
Member

ah nvm there's no e2e for dart, all good then

@shortcuts
Copy link
Member

superseded by #3326 thanks a lot @techouse for the contribution!!

@shortcuts shortcuts closed this Jul 8, 2024
@shortcuts
Copy link
Member

(i'll co author you obviously)

@techouse
Copy link
Contributor Author

techouse commented Jul 8, 2024

Roger that 馃

@techouse techouse deleted the feat/dio-http-client-adapter branch July 8, 2024 11:16
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

3 participants