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

Integrating the http/2 protocol into the plugin #138

Closed
kostasoft opened this issue Feb 18, 2022 · 4 comments · Fixed by #266
Closed

Integrating the http/2 protocol into the plugin #138

kostasoft opened this issue Feb 18, 2022 · 4 comments · Fixed by #266
Labels
enhancement New feature or request

Comments

@kostasoft
Copy link

Description
Could you add http/2 support to the plugin? I looked at your plugin source code and saw that you are using Dio. on the page of this plugin there is information about using this protocol.

Basic example

dependencies:
  dio: ^4.0.0
  dio_http2_adapter: ^2.0.0

import 'package:dio/dio.dart';
import 'package:dio_http2_adapter/dio_http2_adapter.dart';

  var dio = Dio()
    ..options.baseUrl = 'https://google.com'
    ..interceptors.add(LogInterceptor())
    ..httpClientAdapter = Http2Adapter(
      ConnectionManager(
        idleTimeout: 10000,
        // Ignore bad certificate
        onClientCreate: (_, config) => config.onBadCertificate = (_) => true,
      ),
    );
@brunoocasali brunoocasali added enhancement New feature or request question Further information is requested labels Feb 21, 2022
@brunoocasali
Copy link
Member

Hey, @kostasoft thanks for raising this concern with us!

We have this guide about how you could enable HTTP/2 in your meilisearch server https://docs.meilisearch.com/learn/cookbooks/http2_ssl.html.

I'm not sure about adding this adapter to the client will have the desired effect you want. Do you mean that this client will make the requests using HTTP/2 if we adopt this adapter right? (just a way to force these requests to be made with HTTP/2).

Can you help me understand better what you want/need?

@brunoocasali
Copy link
Member

I was looking more about the topic in the dio:

I found these two items regarding the fallback to HTTP/1 when HTTP/2 is not available: cfug/dio#972 and cfug/dio#1425

If the http2 adapter does not support the fallback by default, I cannot add that to the official SDK, because many users will be affected.

What could be done instead is, to add a way for the user to create their own client and inject that into the client here: https://github.com/meilisearch/meilisearch-dart/blob/main/lib/src/http_request_impl.dart#L8
Like we do here (and other SDK's): https://github.com/meilisearch/meilisearch-dotnet/blob/main/src/Meilisearch/MeilisearchClient.cs#L42

@kostasoft
Copy link
Author

Hello!
Thank you so much for your help.
Thanks to your tip I made changes to three files and was able to add http2 support to the client.
But I really wish I could reassign the default http client when initializing MeiliSearchClient, for example:

final customDio = Dio(BaseOptions(...));
_client = MeiliSearchClient(MEILISEARCH_URL, key, httpClient: customDio);

@brunoocasali
Copy link
Member

Yes, I think this is the way to do it, we need to create a different http2 client and then inject it to the MeiliSearchClient, btw we need to take care of the automatically added headers, I think is not a good idea to let it for the custom client handle.

Unfortunately, I don't have the time to work on it now, since we are upgrading our SDKs to support the next version of Meilisearch (v0.26).
If you came up with a solution, feel free to open a PR 🤘

@brunoocasali brunoocasali removed the question Further information is requested label Mar 22, 2022
@bors bors bot closed this as completed in 1205677 Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants