Repository navigation
Fixes examples, issues 2058, 1761, 1889, and 2056 - #2061
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2061 +/- ##
==========================================
+ Coverage 82.00% 82.17% +0.16%
==========================================
Files 36 36
Lines 2657 2681 +24
Branches 419 424 +5
==========================================
+ Hits 2179 2203 +24
Misses 375 375
Partials 103 103 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| .ReadAsStreamAsync(cancellationToken) | ||
| .ConfigureAwait(false); | ||
| using var reader = new StreamReader(stream); | ||
| var json = await content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
This could potentially cause a regression for applications downloading and deserializing large payloads (>2GB because the backing char[] array is int indexed) using Refit today.
Users of Refit are generally calling another API, where one wouldn't expect such large payloads in response, so this could be OK. The safest fix might just be to use JsonTextReader over a char[] buffer (StreamReader) so that downloading from network stream is async and deserialization of bytes is sync.
|
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. |
What kind of change does this PR introduce?
update
What is the current behavior?
#2058
#1761
#1889
#2056
What is the new behavior?
closes #2058 (Newtonsoft async deserialization path)
Updated NewtonsoftJsonContentSerializer to use async-friendly content read behavior.
Added test coverage proving no sync-only stream requirement:
Refit.Tests/SerializedContentTests.cs
Test: StreamDeserialization_UsingNewtonsoftJsonContentSerializer_DoesNotUseSynchronousReads
closes #1761 (AuthorizationHeaderValueGetter with supplied HttpClient)
Implemented token application from AuthorizationHeaderValueGetter during request construction when using supplied HttpClient overloads.
Propagated method CancellationToken to the getter delegate.
Added tests:
Refit.Tests/AuthenticatedClientHandlerTests.cs
AuthorizationHeaderValueGetterIsUsedWhenSupplyingHttpClient
AuthorizationHeaderValueGetterDoesNotOverrideExplicitTokenWhenSupplyingHttpClient
Refit.Tests/RequestBuilder.cs
AuthorizationHeaderValueGetterReceivesMethodCancellationToken
closes #1889 (ignore query properties)
Added support to skip query properties marked with:
[IgnoreDataMember]
[System.Text.Json.Serialization.JsonIgnore]
[Newtonsoft.Json.JsonIgnore]
Added test:
Refit.Tests/RequestBuilder.cs
PostWithObjectQueryParameterSkipsIgnoredProperties
closes #2056 (customer header issue)
Added documentation warning and guidance about handler lifetimes + per-request state:
README.md (important guidance for IHttpClientFactory / delegating handler pooling)
Also added/updated example material demonstrating safer patterns.
Resolves issues with samples, refactored and extended, updated for current code base.
Please check if the PR fulfills these requirements
Other information: