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

Exception when using IOCompatibleClient inside http/io_client IOClient #47

Open
Cyrix126 opened this issue Dec 23, 2024 · 0 comments
Open

Comments

@Cyrix126
Copy link
Contributor

IOCompatibleClient implements dart:io:HttpClient.

I have a use case where I want to access a method present only in HttpClient, then another one in RhttpClient and then wants to provide an http.Client from the crate http to a method/function.

I thought I could do like this:

// create an httpClient compatible client
final innerClient = await IoCompatibleClient.create();
// use a method only available in httpClient
// there is no callback equivalent in RhttpCompatibleClient to get the cert of a response.
innerClient.badCertificateCallback = (X509Certificate cert, String url, int port) {
     // do something with the cert then return bool
     return false;
    };
// convert client to http.Client
final client = IOClient(innerclient);
// transfer it in a function that takes a http.Client and call client.post(url:..., headers:..., body:...)
MethodUsingPackageHttp(client);
client.post(url).

The exception is:
Error: [RhttpUnknownException] hyper_util::client::legacy::Error(SendRequest, hyper::Error(IncompleteMessage))

Indeed, when analyzing the request sent this way, there is no header nor body even if attached to the IOClient(innerclient).

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

No branches or pull requests

1 participant