Enable Form content matching on ReadOnlyMemoryContent - #1141
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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 requestHttpContentisReadOnlyMemoryContenton .NET 8+. - Keep existing behavior for pre-.NET 8 builds (only
ByteArrayContent-based bodies are eligible for matching). - Bump
global.jsonSDK from10.0.301to10.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.
| #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; | ||
| } |
ec29576 to
e687e91
Compare
No description provided.