Skip to content

Commit

Permalink
Fixes dotnet#5105
Browse files Browse the repository at this point in the history
Add support for HttpRequestMessage objects containing StreamContent to
the AddStandardHedgingHandler() resilience API.

This change does not update any public API contracts. It updates
internal and private API contracts only.

This is a small commit that is part of a larger PR. See the PR and
its corresponding initial commit for the full set of changes.
  • Loading branch information
Adam Hammond committed Apr 16, 2024
1 parent 51c0c53 commit 4fb26f9
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Extensions.Http.Resilience.Internal;
using Microsoft.Extensions.ObjectPool;
using Xunit;

namespace Microsoft.Extensions.Http.Resilience.Test.Resilience;
Expand Down Expand Up @@ -108,6 +109,18 @@ public async Task CreateSnapshotAsync_OriginalMessageChanged_SnapshotReturnsOrig
#endif
}

[Fact]
public async Task CreateRequestMessageAsync_SnapshotIsReset_ThrowsException()
{
_requestMessage!.Method = HttpMethod.Get;
Assert.Null(_requestMessage.Content);
AddRequestHeaders(_requestMessage);
AddRequestOptions(_requestMessage);
using RequestMessageSnapshot snapshot = await RequestMessageSnapshot.CreateAsync(_requestMessage).ConfigureAwait(false);
((IResettable)snapshot).TryReset();
_ = await Assert.ThrowsAsync<InvalidOperationException>(snapshot.CreateRequestMessageAsync);
}

public void Dispose()
{
Dispose(true);
Expand Down

0 comments on commit 4fb26f9

Please sign in to comment.