You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A HttpRequestMessage gets disposed after each usage of a refit client, that causes all disposable request content items get disposed as well (like streams). In my case it is not desirable behaviour, i would like to keep my streams open for some longer time.
MikhailIvanou
changed the title
[Bug]: A request streams get disposed and there is no option to avoid it
[Bug]: Request streams get disposed and there is no option to avoid it
Feb 1, 2024
Describe the bug 🐞
Hi everyone, the problem is:
A HttpRequestMessage gets disposed after each usage of a refit client, that causes all disposable request content items get disposed as well (like streams). In my case it is not desirable behaviour, i would like to keep my streams open for some longer time.
As far as I can see, there is no option to disable this behaviour
Step to reproduce
public interface IAwesomeHttpClient
{
[Multipart]
[Post("/Test/Test1")]
Task<Stream> Method1(StreamPart file, CancellationToken cancellation);
[Multipart]
[Post("/Test/Test2")]
Task<Stream> Method2(StreamPart file, CancellationToken cancellation);
}
Stream str = await _azureBlob.OpenReadAsync();
var respStr1 = await _awesomeHttpClient.Method1(new StreamPart(str));
str.Position = 0;
// FAILED!, because 'str' has already been disposed
var respStr12= await _awesomeHttpClient.Method2(new StreamPart(str));
Reproduction repository
https://github.com/reactiveui/refit/blob/867efbdcff936b0f217889f87f684bc01df3bd1d/Refit/RequestBuilderImplementation.cs#L410C21-L410C23
Expected behavior
It would be nice to add a flag (to RefitSettings or an attrybute) determining whether HttpRequestMessage gonna be disposed.
Screenshots 🖼️
No response
IDE
No response
Operating system
No response
Version
No response
Device
No response
Refit Version
7.0.0
Additional information ℹ️
No response
The text was updated successfully, but these errors were encountered: