This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change EnsureSuccessStatusCode to not dispose response content (#29795)
* Change EnsureSuccessStatusCode to not dispose response content Historically, this method has always disposed the response content if it was throwing an exception. The reason documented in the comment really doesn't make much sense, especially to just dispose the content but not the actual response object. The developer pattern we advise when getting an HttpResponseMessage is to wrap it in a 'using' statement or use an explicit .Dispose() call. And disposing the HttpResponseMessage would always dispose the inner .Content anyways. The use case of #26684 is that the response content should be available regardless if this method throws an exception or not. Developers normally don't expect an object to get disposed (partially in this case) as a side-affect of calling a method on the object. So, we're changing the behavior to be more consistent generally with other .NET objects. Fixes #26684 * Address PR feedback
- Loading branch information