Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Fixes a bug with CloneAsync extension method. #175

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

andrueastman
Copy link
Member

The CloneAsync extension method for HttpRequestMessage calls ReadAsStreamAsync to get the stream contents of a request when cloning the request which will simply return the same underlying stream object of the request message.
This therefore means that disposing or seeking the content of the original object will also affect the content of the cloned object as well.

This PR therefore fixes the implementation to use CopyToAsync so that a new copy is created to avoid unintended consequences when working with the clone or the original. Tests have been added to validate this as well.

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@andrueastman andrueastman marked this pull request as ready for review November 27, 2023 16:18
@andrueastman andrueastman merged commit 23d5535 into main Nov 27, 2023
10 checks passed
@andrueastman andrueastman deleted the andrueastman/fixCloneAsync branch November 27, 2023 16:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants