-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
ModernHttpClient support? #24
Comments
Sure. Looks like ModernHttpClient is implemented via a custom HttpMessageHandler, which is simple to wire into all Flurl.Http calls via a custom factory like this: using Flurl.Http.Configuration;
public class ModernHttpClientFactory : DefaultHttpClientFactory
{
public override HttpMessageHandler CreateMessageHandler() {
return new ModernHttpClient.NativeMessageHandler();
}
} Then on app startup, register it with Flurl thusly: FlurlHttp.Configure(c => {
c.HttpClientFactory = new ModernHttpClientFactory();
}); Let me know if this works for you. |
Closing this issue. If for some reason it did not work, feel free to re-open or just comment. |
Just confirming - this does seem to work and is exactly what I was looking for. I suggest you add this example to your docs under /extensibility. |
Great. Yeah I was just reminded in another issue that CreateMessageHandler needs to be documented. Nice to see Flurl getting some traction with Xamarin users, would love to figure out how to get the word out more broadly. |
What if we do not want to make a global Flurl configuration, but decide on a per request which httpclient is to be used? In our case we want to selectively ignore certificate validation. |
@galmok No problem - the same global settings object is available per var client = new FlurlClient();
client.Settings.HttpClientFactory = new MyCustomFactory();
var result = await "http://api.com".WithClient(client).GetAsync(); The docs need to be updated in this area. |
Hey, is there a way to use the ModernHttpClient instead of HttpClient?
The text was updated successfully, but these errors were encountered: