Flurl icon indicating copy to clipboard operation
Flurl copied to clipboard

HTTP/2 support?

Open CreatedAutomated opened this issue 3 years ago • 3 comments

Please describe the feature/enhancement in as much detail as possible. Is it possible to make it easily use http/2? I have tried the custom httpclient factory and I am still getting the same issues with only http/1.0 and http/1.1 being supported.

It would be amazing if you could set via the client object the version to use

CreatedAutomated avatar Jul 08 '21 12:07 CreatedAutomated

I've got it working when I inherit winhttphandler in the custom factory.

However, to use cookies, we must use a cookiecontainer and flurl uses cookiejar. Any other options?

CreatedAutomated avatar Jul 08 '21 16:07 CreatedAutomated

It's not a bad feature request - HttpRequestMessage has a Version property but Flurl doesn't provide a way (directly or via any sort of hook) to set it. I'll add this to the backlog but it sounds like you're close to a work-around for now.

For cookies, are you saying you want to use Flurl's CookieJar? You're right that overriding CreateMessageHandler in your factory can break that, but all you should need to do is disable the handler's cookie handling. I've never tried this with WinHttpHandler but I'm guessing if you set CookieUsePolicy to IgnoreCookies in your handler, that should do the trick.

tmenier avatar Jul 09 '21 15:07 tmenier

Thank u bro. I just updated to .NET 6 and it seems to work without winhttphandler. But, with .NET Framework the default httpclienthandler does not seem to support http/2. Winhttphandler does though, but then its more problematic with flurl. So ill just do what everyone else is doing and move away from .NET Framework

On Friday, July 9, 2021, Todd Menier @.***> wrote:

It's not a bad feature request - HttpRequestMessage has a Version property https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage.version but Flurl doesn't provide a way (directly or via any sort of hook) to set it. I'll add this to the backlog but it sounds like you're close to a work-around for now.

For cookies, are you saying you want to use Flurl's CookieJar? You're right that overriding CreateMessageHandler in your factory can break that, but all you should need to do is disable the handler's cookie handling. I've never tried this with WinHttpHandler but I'm guessing if you set CookieUsePolicy https://docs.microsoft.com/en-us/dotnet/api/system.net.http.winhttphandler.cookieusepolicy to IgnoreCookies in your handler, that should do the trick.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tmenier/Flurl/issues/639#issuecomment-877286141, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKIZM2NPZF624SXU7D7WQZTTW4LX5ANCNFSM5AAWE4XA .

CreatedAutomated avatar Jul 10 '21 11:07 CreatedAutomated

Curious if there is any progress on this? I'm using PostJsonAsync() but getting back System.AggregateException: The response ended prematurely. A cursory stackoverflow search suggested using HTTP2.

Mgamerz avatar Feb 06 '23 04:02 Mgamerz

Good news: direct support for HTTP version will make the 4.0 cut. I think it's a good fit for Flurl's configuration pattern so it can be available at the request, client, or global level. Here's how you'll be able to set it on the client:

flurlClient.Settings.HttpVersion = "2.0";

tmenier avatar Sep 14 '23 18:09 tmenier