-
-
Notifications
You must be signed in to change notification settings - Fork 379
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
When you want to keep HTTPClient alive FlurlClient keeps disposing him #66
Comments
I'd like to understand your use case a little better. Keeping the lifespan of the HttpClient bound to that of the FlurlClient was an intentional design decision; I think it makes it more clear and intuitive to the user. See here for details on patterns for re-using FlurlClient, thus re-using the underlying HttpClient, and let me know if this suits your needs. |
I'm working on a multithreaded application, where I want to reuse the HttpClient for things like cookies. Different FlurlClients will guarantee thread issues, I think. My solution would be an easy fix, but only needed when FlurlClient isn't 100% thread safe. |
I see. FlurlClient does hold a reference to a URL, so you're right, you can't safely call different URLs on different threads using the same FlurlClient instance. I'll give some thought to a better solution to that, but in the mean time I will pull your change. Look for a Flurl.Http 0.8.1 soon. |
OK, good luck with searching for a better solution. THanks for looking at the request, and thanks for Flurl solution itself. |
Ok, I believe I have a solution that solves this issue in a different way. Before I package it for NuGet, let me know if you think this will work. The
If you follow this pattern, you should get shared cookies etc, thread-safe URLs, and no unexpected disposal of HttpClient. Let me know you think this will work. I'd be happy to create a prerelease NuGet package if you want to try it out. |
These 2 new tests demonstrate the new functionality: |
…ew FlurlClient instance with shared internals for better thread-safe multi-URL use (#66)
Flurl.Http 0.9.0-pre is released. I will probably need to put this into full release soon because others are waiting on a bug fix affecting .NET 4.6.1, so if you have feedback please get back to me as soon as you can. |
Flurl 0.9.0 is released. |
Good solution, this should work! |
When creating a custom HttpClientFactory that manages a HttpClient the FlurlClient instances keep disposing the used HTTPClient when collected by the GC.
I already made a solution for it, virtual dispose
#65
The text was updated successfully, but these errors were encountered: