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

Really Buffered JsonContent when buffered is set #1115

Merged
merged 2 commits into from
Mar 19, 2021

Conversation

vbornand
Copy link
Contributor

@vbornand vbornand commented Mar 11, 2021

What kind of change does this PR introduce?

If fixes the bug #1099.

What is the current behavior?

When the body is serialized (with JsonContent), the data is not buffered because the JsonContent doesn't implement the TryComputeLength method (https://github.com/dotnet/runtime/blob/9c3fc566eb916434f8bfe6974e4ddc21ba6e7ff6/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs#L55)

The settings RefitSettings.Buffered is only used when the Body attribute is set without the property Buffered defined and has no effect when the Body attribute missing. The buffering is always disabled when the attribute is missing.

What is the new behavior?

The request content is buffered, if the buffering is active.

The RefitSettings.Buffered is by default equals to false, and have effect even if the Body property is missing.

What might this PR break?
The RefitSettings.Buffered have now false as default value, so the attribute Body is without buffering by default.
If RefitSettings.Buffered is explicitely set to true, all the body are buffered even if the Body attribute is missing.

Some users can belived they buffered and it was not the case, so with this fix the memory usage can increase.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features) => not done. Hard to find how to test it but all the current tests are not broken.
  • [ X] Docs have been added / updated (for bug fixes / features) => The doc was incorrect. "By default, Refit streams the body content without buffering it." It was not totally true.

Other information:
The use of PushStreamContent (

ret.Content = new PushStreamContent(
) when buffering is disabled is maybe useless when it is a JsonContent because it already streams the data. I didn't change this because I don't know Refit enough well to know the other implication.

Fix inconsistency with RefitSettings.Buffered setting.
@dnfadmin
Copy link

dnfadmin commented Mar 11, 2021

CLA assistant check
All CLA requirements met.

@vbornand vbornand changed the title Really Buffered JsonContent when buffered is active Really Buffered JsonContent when buffered is set Mar 11, 2021
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants