Skip to content

Fixes examples, issues 2058, 1761, 1889, and 2056 - #2061

Merged
ChrisPulman merged 2 commits into
mainfrom
FixesExamples
Mar 20, 2026
Merged

ChrisPulman merged 2 commits into
mainfrom
FixesExamples

Conversation

@ChrisPulman

Copy link
Copy Markdown
Member

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

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:

@codecov

codecov Bot commented Mar 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.17%. Comparing base (0155eeb) to head (82ada74).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChrisPulman ChrisPulman changed the title Fixes examples Fixes examples, issues 2058, 1761, 1889, and 2056 Mar 20, 2026
@ChrisPulman
ChrisPulman merged commit cfe6862 into main Mar 20, 2026
6 checks passed
@ChrisPulman
ChrisPulman deleted the FixesExamples branch March 20, 2026 08:51
.ReadAsStreamAsync(cancellationToken)
.ConfigureAwait(false);
using var reader = new StreamReader(stream);
var json = await content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

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 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

3 participants