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

[Bug]: Request streams get disposed and there is no option to avoid it #1648

Open
MikhailIvanou opened this issue Jan 31, 2024 · 0 comments
Open
Labels

Comments

@MikhailIvanou
Copy link

MikhailIvanou commented Jan 31, 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

  1. Provided that we have a interface like that

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);
}

  1. Then i gonna use it like that (it is pseudocode)

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

@MikhailIvanou 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant