Skip to content

Enable Form content matching on ReadOnlyMemoryContent - #1141

Merged
hwoodiwiss merged 2 commits into
mainfrom
improve-form-content-matching
Jul 28, 2026
Merged

Enable Form content matching on ReadOnlyMemoryContent#1141
hwoodiwiss merged 2 commits into
mainfrom
improve-form-content-matching

Conversation

@hwoodiwiss

Copy link
Copy Markdown
Member

No description provided.

@hwoodiwiss
hwoodiwiss requested a review from a team as a code owner July 28, 2026 12:44
Copilot AI review requested due to automatic review settings July 28, 2026 12:44
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.33%. Comparing base (55eb924) to head (e687e91).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1141   +/-   ##
=======================================
  Coverage   99.33%   99.33%           
=======================================
  Files          15       15           
  Lines         896      896           
  Branches      205      205           
=======================================
  Hits          890      890           
  Misses          4        4           
  Partials        2        2           
Flag Coverage Δ
linux 99.33% <100.00%> (ø)
macos 99.33% <100.00%> (ø)
windows 99.33% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends form-url-encoded body matching in HttpRequestInterceptionBuilderExtensions.ForFormContent(...) to support ReadOnlyMemoryContent when targeting .NET 8+ (guarded by NET8_0_OR_GREATER), and updates the repository’s pinned .NET SDK patch version.

Changes:

  • Allow ForFormContent(...) matching when request HttpContent is ReadOnlyMemoryContent on .NET 8+.
  • Keep existing behavior for pre-.NET 8 builds (only ByteArrayContent-based bodies are eligible for matching).
  • Bump global.json SDK from 10.0.301 to 10.0.302.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/HttpClientInterception/HttpRequestInterceptionBuilderExtensions.cs Adds a .NET 8+ conditional to treat ReadOnlyMemoryContent as eligible for form-body matching.
global.json Updates pinned .NET SDK patch version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +395 to +406
#if NET8_0_OR_GREATER
// FormUrlEncodedContent derives from ByteArrayContent so use the
// least specific type for more flexibility (e.g. also StringContent).
// ReadOnlyMemoryContent is also supported as the underlying content is a ReadOnlyMemory<byte>
// which can be copied to a MemoryStream for parsing.
// Other content types are not supported as they may be iterating over
// a stream which might not support arbitrary seeking if the request
// is not a match and needs to be sent to the URL originally specified.
if (content is not ByteArrayContent && content is not ReadOnlyMemoryContent)
{
return false;
}
@hwoodiwiss
hwoodiwiss force-pushed the improve-form-content-matching branch from ec29576 to e687e91 Compare July 28, 2026 14:56
@hwoodiwiss
hwoodiwiss merged commit 1e77d2e into main Jul 28, 2026
15 checks passed
@hwoodiwiss
hwoodiwiss deleted the improve-form-content-matching branch July 28, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants