diff --git a/Directory.Build.props b/Directory.Build.props
index e138ee7..f01ec3e 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,7 +6,7 @@
Copyright (c) 2020, nventive
Apache-2.0
HttpRecorder
- 8.0
+ 10.0
true
1701;1702;1998
diff --git a/HttpRecorder.Tests/Anonymizers/RulesInteractionAnonymizerTests.cs b/HttpRecorder.Tests/Anonymizers/RulesInteractionAnonymizerTests.cs
index dc7d36c..dd92e90 100644
--- a/HttpRecorder.Tests/Anonymizers/RulesInteractionAnonymizerTests.cs
+++ b/HttpRecorder.Tests/Anonymizers/RulesInteractionAnonymizerTests.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
@@ -34,8 +33,8 @@ public async Task ItShouldAnonymizeRequestQueryStringParameter()
.AnonymizeRequestQueryStringParameter("key");
var result = await anonymizer.Anonymize(interaction);
- result.Messages[0].Response.RequestMessage.RequestUri.ToString().Should().Be("http://first/");
- result.Messages[1].Response.RequestMessage.RequestUri.ToString().Should().Be($"https://second/?key={RulesInteractionAnonymizer.DefaultAnonymizerReplaceValue}&value=bar");
+ result.Messages[0].Response.RequestMessage!.RequestUri!.ToString().Should().Be("http://first/");
+ result.Messages[1].Response.RequestMessage!.RequestUri!.ToString().Should().Be($"https://second/?key={RulesInteractionAnonymizer.DefaultAnonymizerReplaceValue}&value=bar");
}
[Fact]
@@ -51,10 +50,10 @@ public async Task ItShouldAnonymizeRequestHeader()
.AnonymizeRequestHeader("X-RequestHeader");
var result = await anonymizer.Anonymize(interaction);
- result.Messages[0].Response.RequestMessage.Headers.GetValues("X-RequestHeader").First().Should().Be(RulesInteractionAnonymizer.DefaultAnonymizerReplaceValue);
+ result.Messages[0].Response.RequestMessage!.Headers.GetValues("X-RequestHeader").First().Should().Be(RulesInteractionAnonymizer.DefaultAnonymizerReplaceValue);
}
- private Interaction BuildInteraction(params HttpRequestMessage[] requests)
+ private static Interaction BuildInteraction(params HttpRequestMessage[] requests)
{
return new Interaction(
"test",
diff --git a/HttpRecorder.Tests/ContextTests.cs b/HttpRecorder.Tests/ContextTests.cs
index b2ebb0b..3721c87 100644
--- a/HttpRecorder.Tests/ContextTests.cs
+++ b/HttpRecorder.Tests/ContextTests.cs
@@ -32,8 +32,8 @@ public async Task ItShouldWorkWithHttpRecorderContext()
options.BaseAddress = _fixture.ServerUri;
});
- HttpResponseMessage passthroughResponse = null;
- using (var context = new HttpRecorderContext((sp, builder) => new HttpRecorderConfiguration
+ HttpResponseMessage passthroughResponse;
+ using (new HttpRecorderContext((_, _) => new HttpRecorderConfiguration
{
Mode = HttpRecorderMode.Record,
InteractionName = nameof(ItShouldWorkWithHttpRecorderContext),
@@ -44,7 +44,7 @@ public async Task ItShouldWorkWithHttpRecorderContext()
passthroughResponse.EnsureSuccessStatusCode();
}
- using (var context = new HttpRecorderContext((sp, builder) => new HttpRecorderConfiguration
+ using (new HttpRecorderContext((_, _) => new HttpRecorderConfiguration
{
Mode = HttpRecorderMode.Replay,
InteractionName = nameof(ItShouldWorkWithHttpRecorderContext),
@@ -70,8 +70,8 @@ public async Task ItShouldWorkWithHttpRecorderContextWhenNotRecording()
options.BaseAddress = _fixture.ServerUri;
});
- HttpResponseMessage passthroughResponse = null;
- using (var context = new HttpRecorderContext((sp, builder) => new HttpRecorderConfiguration
+ HttpResponseMessage passthroughResponse;
+ using (new HttpRecorderContext((_, _) => new HttpRecorderConfiguration
{
Enabled = false,
Mode = HttpRecorderMode.Record,
@@ -83,7 +83,7 @@ public async Task ItShouldWorkWithHttpRecorderContextWhenNotRecording()
passthroughResponse.EnsureSuccessStatusCode();
}
- using (var context = new HttpRecorderContext((sp, builder) => new HttpRecorderConfiguration
+ using (new HttpRecorderContext((_, _) => new HttpRecorderConfiguration
{
Mode = HttpRecorderMode.Replay,
InteractionName = nameof(ItShouldWorkWithHttpRecorderContextWhenNotRecording),
@@ -91,7 +91,7 @@ public async Task ItShouldWorkWithHttpRecorderContextWhenNotRecording()
{
var client = services.BuildServiceProvider().GetRequiredService().CreateClient("TheClient");
Func act = async () => await client.GetAsync(ApiController.JsonUri);
- act.Should().Throw();
+ await act.Should().ThrowAsync();
}
}
@@ -99,7 +99,7 @@ public async Task ItShouldWorkWithHttpRecorderContextWhenNotRecording()
public void ItShouldNotAllowMultipleContexts()
{
using var context = new HttpRecorderContext();
- Action act = () => { var ctx2 = new HttpRecorderContext(); };
+ Action act = () => { _ = new HttpRecorderContext(); };
act.Should().Throw().WithMessage("*multiple*");
}
}
diff --git a/HttpRecorder.Tests/HttpClientFactoryTests.cs b/HttpRecorder.Tests/HttpClientFactoryTests.cs
index 7f44cfe..e474d26 100644
--- a/HttpRecorder.Tests/HttpClientFactoryTests.cs
+++ b/HttpRecorder.Tests/HttpClientFactoryTests.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
+using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using HttpRecorder.Tests.Server;
diff --git a/HttpRecorder.Tests/HttpRecorder.Tests.csproj b/HttpRecorder.Tests/HttpRecorder.Tests.csproj
index 35b3764..014b3e5 100644
--- a/HttpRecorder.Tests/HttpRecorder.Tests.csproj
+++ b/HttpRecorder.Tests/HttpRecorder.Tests.csproj
@@ -1,18 +1,16 @@
- netcoreapp2.2
+ net6.0
false
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/HttpRecorder.Tests/HttpRecorderIntegrationTests.cs b/HttpRecorder.Tests/HttpRecorderIntegrationTests.cs
index 8e87117..353f3f1 100644
--- a/HttpRecorder.Tests/HttpRecorderIntegrationTests.cs
+++ b/HttpRecorder.Tests/HttpRecorderIntegrationTests.cs
@@ -1,7 +1,9 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
+using System.Net;
using System.Net.Http;
+using System.Net.Http.Json;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
@@ -38,13 +40,13 @@ await ExecuteModeIterations(async (client, mode) =>
{
var response = await client.GetAsync(ApiController.JsonUri);
- response.EnsureSuccessStatusCode();
+ response.Should().BeSuccessful();
response.Headers.Remove("Date");
if (mode == HttpRecorderMode.Passthrough)
{
passthroughResponse = response;
- var result = await response.Content.ReadAsAsync();
- result.Name.Should().Be(SampleModel.DefaultName);
+ var result = await response.Content.ReadFromJsonAsync();
+ result!.Name.Should().Be(SampleModel.DefaultName);
}
else
{
@@ -63,13 +65,13 @@ await ExecuteModeIterations(async (client, mode) =>
{
var response = await client.GetAsync($"{ApiController.JsonUri}?name={name}");
- response.EnsureSuccessStatusCode();
+ response.Should().BeSuccessful();
response.Headers.Remove("Date");
if (mode == HttpRecorderMode.Passthrough)
{
passthroughResponse = response;
- var result = await response.Content.ReadAsAsync();
- result.Name.Should().Be(name);
+ var result = await response.Content.ReadFromJsonAsync();
+ result!.Name.Should().Be(name);
}
else
{
@@ -88,14 +90,14 @@ await ExecuteModeIterations(async (client, mode) =>
{
var response = await client.PostAsJsonAsync(ApiController.JsonUri, sampleModel);
- response.EnsureSuccessStatusCode();
+ response.Should().BeSuccessful();
response.Headers.Remove("Date");
if (mode == HttpRecorderMode.Passthrough)
{
passthroughResponse = response;
- var result = await response.Content.ReadAsAsync();
- result.Name.Should().Be(sampleModel.Name);
+ var result = await response.Content.ReadFromJsonAsync();
+ result!.Name.Should().Be(sampleModel.Name);
}
else
{
@@ -119,13 +121,13 @@ await ExecuteModeIterations(async (client, mode) =>
var response = await client.PostAsync(ApiController.FormDataUri, formContent);
- response.EnsureSuccessStatusCode();
+ response.Should().BeSuccessful();
response.Headers.Remove("Date");
if (mode == HttpRecorderMode.Passthrough)
{
passthroughResponse = response;
- var result = await response.Content.ReadAsAsync();
- result.Name.Should().Be(sampleModel.Name);
+ var result = await response.Content.ReadFromJsonAsync();
+ result!.Name.Should().Be(sampleModel.Name);
}
else
{
@@ -161,9 +163,9 @@ await ExecuteModeIterations(async (client, mode) =>
for (var i = 0; i < Concurrency; i++)
{
var response = responses[i];
- response.EnsureSuccessStatusCode();
- var result = await response.Content.ReadAsAsync();
- result.Name.Should().Be($"{i}");
+ response.Should().BeSuccessful();
+ var result = await response.Content.ReadFromJsonAsync();
+ result!.Name.Should().Be($"{i}");
}
}
else
@@ -183,21 +185,17 @@ public async Task ItShouldExecuteMultipleRequestsInSequenceWithRecorderModeAuto(
File.Delete(recordedFileName);
}
- var client = CreateHttpClient(
- HttpRecorderMode.Auto,
- nameof(ItShouldExecuteMultipleRequestsInSequenceWithRecorderModeAuto));
+ var client = CreateHttpClient(HttpRecorderMode.Auto);
var response1 = await client.GetAsync($"{ApiController.JsonUri}?name=1");
var response2 = await client.GetAsync($"{ApiController.JsonUri}?name=2");
- var result1 = await response1.Content.ReadAsAsync();
- result1.Name.Should().Be("1");
+ var result1 = await response1.Content.ReadFromJsonAsync();
+ result1!.Name.Should().Be("1");
- var result2 = await response2.Content.ReadAsAsync();
- result2.Name.Should().Be("2");
+ var result2 = await response2.Content.ReadFromJsonAsync();
+ result2!.Name.Should().Be("2");
// We resolve to replay at this point.
- client = CreateHttpClient(
- HttpRecorderMode.Auto,
- nameof(ItShouldExecuteMultipleRequestsInSequenceWithRecorderModeAuto));
+ client = CreateHttpClient(HttpRecorderMode.Auto);
var response2_1 = await client.GetAsync($"{ApiController.JsonUri}?name=1");
var response2_2 = await client.GetAsync($"{ApiController.JsonUri}?name=2");
@@ -215,7 +213,7 @@ await ExecuteModeIterations(async (client, mode) =>
{
var response = await client.GetAsync(ApiController.BinaryUri);
- response.EnsureSuccessStatusCode();
+ response.Should().BeSuccessful();
response.Headers.Remove("Date");
if (mode == HttpRecorderMode.Passthrough)
@@ -239,7 +237,7 @@ public async Task ItShouldThrowIfDoesNotFindFile()
Func act = async () => await client.GetAsync(ApiController.JsonUri);
- act.Should().Throw()
+ await act.Should().ThrowAsync()
.WithMessage($"*{TestFile}*");
}
@@ -251,7 +249,7 @@ public async Task ItShouldThrowIfFileIsCorrupted()
Func act = async () => await client.GetAsync(ApiController.JsonUri);
- act.Should().Throw()
+ await act.Should().ThrowAsync()
.WithMessage($"*{file}*");
}
@@ -268,25 +266,25 @@ public async Task ItShouldThrowIfNoRequestCanBeMatched()
Func act = async () => await client.GetAsync(ApiController.JsonUri);
- act.Should().Throw()
+ await act.Should().ThrowAsync()
.WithMessage($"*{ApiController.JsonUri}*");
}
[Theory]
- [InlineData(202)]
- [InlineData(301)]
- [InlineData(303)]
- [InlineData(404)]
- [InlineData(500)]
- [InlineData(502)]
- public async Task ItShouldGetStatus(int statusCode)
+ [InlineData(HttpStatusCode.Accepted)]
+ [InlineData(HttpStatusCode.MovedPermanently)]
+ [InlineData(HttpStatusCode.RedirectMethod)]
+ [InlineData(HttpStatusCode.NotFound)]
+ [InlineData(HttpStatusCode.InternalServerError)]
+ [InlineData(HttpStatusCode.BadGateway)]
+ public async Task ItShouldGetStatus(HttpStatusCode statusCode)
{
HttpResponseMessage passthroughResponse = null;
await ExecuteModeIterations(async (client, mode) =>
{
- var response = await client.GetAsync($"{ApiController.StatusCodeUri}?statusCode={statusCode}");
- response.StatusCode.Should().Be(statusCode);
+ var response = await client.GetAsync($"{ApiController.StatusCodeUri}?statusCode={(int)statusCode}");
+ response.Should().HaveStatusCode(statusCode);
response.Headers.Remove("Date");
if (mode == HttpRecorderMode.Passthrough)
@@ -310,7 +308,7 @@ public async Task ItShouldOverrideModeWithEnvironmentVariable()
Func act = () => client.GetAsync(ApiController.JsonUri);
- act.Should().Throw();
+ await act.Should().ThrowAsync();
}
finally
{
@@ -326,8 +324,8 @@ public async Task ItShouldAnonymize()
HttpRecorderMode.Record,
repository: repositoryMock.Object,
anonymizer: RulesInteractionAnonymizer.Default.AnonymizeRequestQueryStringParameter("key"));
- Func act = async () => await client.GetAsync($"{ApiController.JsonUri}?key=foo");
- act.Should().Throw(); // Because we don't act on the stream in the repository. That's fine.
+
+ await client.GetAsync($"{ApiController.JsonUri}?key=foo");
repositoryMock.Verify(
x => x.StoreAsync(
diff --git a/HttpRecorder.Tests/Matchers/RulesMatcherUnitTests.cs b/HttpRecorder.Tests/Matchers/RulesMatcherUnitTests.cs
index 55f8326..ec1e442 100644
--- a/HttpRecorder.Tests/Matchers/RulesMatcherUnitTests.cs
+++ b/HttpRecorder.Tests/Matchers/RulesMatcherUnitTests.cs
@@ -22,12 +22,12 @@ public void ItShouldMatchOnce()
var result = matcher.Match(request, interaction);
- result.Response.RequestMessage.RequestUri.Should().BeEquivalentTo(new Uri("http://first"));
+ result.Response.RequestMessage!.RequestUri.Should().BeEquivalentTo(new Uri("http://first"));
result = matcher.Match(request, interaction);
result.Should().NotBeNull();
- result.Response.RequestMessage.RequestUri.Should().BeEquivalentTo(new Uri("http://second"));
+ result.Response.RequestMessage!.RequestUri.Should().BeEquivalentTo(new Uri("http://second"));
}
[Fact]
@@ -45,7 +45,7 @@ public void ItShouldMatchOnceByHttpMethod()
var result = matcher.Match(request, interaction);
result.Should().NotBeNull();
- result.Response.RequestMessage.Method.Should().BeEquivalentTo(HttpMethod.Head);
+ result.Response.RequestMessage!.Method.Should().BeEquivalentTo(HttpMethod.Head);
}
[Fact]
@@ -63,7 +63,7 @@ public void ItShouldMatchOnceByCompleteRequestUri()
var result = matcher.Match(request, interaction);
result.Should().NotBeNull();
- result.Response.RequestMessage.RequestUri.Should().BeEquivalentTo(new Uri("http://first?name=bar"));
+ result.Response.RequestMessage!.RequestUri.Should().BeEquivalentTo(new Uri("http://first?name=bar"));
}
[Fact]
@@ -81,7 +81,7 @@ public void ItShouldMatchOnceByPartialRequestUri()
var result = matcher.Match(request, interaction);
result.Should().NotBeNull();
- result.Response.RequestMessage.RequestUri.Should().BeEquivalentTo(new Uri("http://first?name=foo"));
+ result.Response.RequestMessage!.RequestUri.Should().BeEquivalentTo(new Uri("http://first?name=foo"));
}
[Fact]
@@ -102,7 +102,7 @@ public void ItShouldMatchOnceByHeader()
var result = matcher.Match(request, interaction);
result.Should().NotBeNull();
- result.Response.RequestMessage.Headers.IfNoneMatch.ToString().Should().Be("second");
+ result.Response.RequestMessage!.Headers.IfNoneMatch.ToString().Should().Be("second");
}
[Fact]
@@ -122,7 +122,7 @@ public void ItShouldMatchOnceByContentWithSameSize()
var result = matcher.Match(request, interaction);
result.Should().NotBeNull();
- result.Response.RequestMessage.Content.Should().BeEquivalentTo(secondContent);
+ result.Response.RequestMessage!.Content.Should().BeEquivalentTo(secondContent);
}
[Fact]
@@ -142,7 +142,7 @@ public void ItShouldMatchOnceByContentWithDifferentSizes()
var result = matcher.Match(request, interaction);
result.Should().NotBeNull();
- result.Response.RequestMessage.Content.Should().BeEquivalentTo(secondContent);
+ result.Response.RequestMessage!.Content.Should().BeEquivalentTo(secondContent);
}
[Fact]
@@ -165,7 +165,7 @@ public void ItShouldMatchOnceByJsonContent()
var result = matcher.Match(request, interaction);
result.Should().NotBeNull();
- result.Response.RequestMessage.Content.Should().BeEquivalentTo(secondContent);
+ result.Response.RequestMessage!.Content.Should().BeEquivalentTo(secondContent);
}
[Fact]
@@ -210,10 +210,10 @@ public void ItShouldMatchWithCombination()
.ByRequestUri();
var result = matcher.Match(request, interaction);
- result.Response.RequestMessage.RequestUri.Should().BeEquivalentTo(new Uri("http://second"));
+ result.Response.RequestMessage!.RequestUri.Should().BeEquivalentTo(new Uri("http://second"));
}
- private Interaction BuildInteraction(params HttpRequestMessage[] requests)
+ private static Interaction BuildInteraction(params HttpRequestMessage[] requests)
{
return new Interaction(
"test",
@@ -224,7 +224,7 @@ private Interaction BuildInteraction(params HttpRequestMessage[] requests)
private class Model
{
- public string Name { get; set; }
+ public string Name { get; init; }
public override bool Equals(object obj)
{
diff --git a/HttpRecorder.Tests/Server/Startup.cs b/HttpRecorder.Tests/Server/Startup.cs
index bf74a66..a61e482 100644
--- a/HttpRecorder.Tests/Server/Startup.cs
+++ b/HttpRecorder.Tests/Server/Startup.cs
@@ -9,7 +9,7 @@ public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
- services.AddMvc();
+ services.AddMvc(o => o.EnableEndpointRouting = false);
}
public void Configure(IApplicationBuilder app)
diff --git a/HttpRecorder.Tests/ServerFixture.cs b/HttpRecorder.Tests/ServerFixture.cs
index 57dd65d..6a7e491 100644
--- a/HttpRecorder.Tests/ServerFixture.cs
+++ b/HttpRecorder.Tests/ServerFixture.cs
@@ -30,7 +30,7 @@ public Uri ServerUri
get
{
var serverAddressesFeature = ServerWebHost.ServerFeatures.Get();
- return new Uri(serverAddressesFeature.Addresses.First());
+ return new Uri(serverAddressesFeature!.Addresses.First());
}
}
diff --git a/HttpRecorder/HttpClientBuilderExtensions.cs b/HttpRecorder/HttpClientBuilderExtensions.cs
index 2e6af04..f3ab1f9 100644
--- a/HttpRecorder/HttpClientBuilderExtensions.cs
+++ b/HttpRecorder/HttpClientBuilderExtensions.cs
@@ -51,7 +51,7 @@ public static IHttpClientBuilder AddHttpRecorder(
repository: repository,
anonymizer: anonymizer);
- return httpClientBuilder.AddHttpMessageHandler((sp) => recorder);
+ return httpClientBuilder.AddHttpMessageHandler(_ => recorder);
}
}
}
diff --git a/HttpRecorder/HttpRecorderDelegatingHandler.cs b/HttpRecorder/HttpRecorderDelegatingHandler.cs
index f6bb849..a9ec59d 100644
--- a/HttpRecorder/HttpRecorderDelegatingHandler.cs
+++ b/HttpRecorder/HttpRecorderDelegatingHandler.cs
@@ -1,6 +1,5 @@
using System;
using System.Diagnostics;
-using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading;
@@ -190,17 +189,12 @@ private async Task ResolveExecutionMode(CancellationToken cancellationToken)
/// The returned as convenience.
private async Task PostProcessResponse(HttpResponseMessage response)
{
- if (response.Content != null)
+ // Trick to make sure a fake ContentLength is not artificially added by the HttpClient if none was provided by the server.
+ // Indeed, the ContentLength is _set_ in the _getter_, but explicitly setting a value opts out of this (undocumented) behaviour.
+ // See https://github.com/dotnet/runtime/blob/ebdb045532190ffc664bba9a0a1e3f2ce35cf23f/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpContentHeaders.cs#L51
+ if (!response.Content.Headers.Contains("Content-Length"))
{
- var stream = await response.Content.ReadAsStreamAsync();
- if (stream.CanSeek)
- {
- // The HTTP Client is adding the content length header on HttpConnectionResponseContent even when the server does not have a header.
- response.Content.Headers.ContentLength = stream.Length;
-
- // We do reset the stream in case it needs to be re-read.
- stream.Seek(0, SeekOrigin.Begin);
- }
+ response.Content.Headers.ContentLength = null;
}
return response;
diff --git a/HttpRecorder/Matchers/RulesMatcher.cs b/HttpRecorder/Matchers/RulesMatcher.cs
index 0dc7e9e..557ff83 100644
--- a/HttpRecorder/Matchers/RulesMatcher.cs
+++ b/HttpRecorder/Matchers/RulesMatcher.cs
@@ -128,8 +128,8 @@ public RulesMatcher ByHeader(string headerName, StringComparison stringCompariso
public RulesMatcher ByContent()
=> By((request, message) =>
{
- var requestContent = request.Content?.ReadAsByteArrayAsync()?.ConfigureAwait(false).GetAwaiter().GetResult();
- var messageContent = message.Response.RequestMessage.Content?.ReadAsByteArrayAsync()?.ConfigureAwait(false).GetAwaiter().GetResult();
+ var requestContent = request.Content?.ReadAsByteArrayAsync().ConfigureAwait(false).GetAwaiter().GetResult();
+ var messageContent = message.Response.RequestMessage.Content?.ReadAsByteArrayAsync().ConfigureAwait(false).GetAwaiter().GetResult();
if (requestContent is null)
{
@@ -149,8 +149,8 @@ public RulesMatcher ByContent()
}
return StructuralComparisons.StructuralComparer.Compare(
- request.Content?.ReadAsByteArrayAsync()?.Result,
- message.Response.RequestMessage.Content?.ReadAsByteArrayAsync()?.Result) == 0;
+ request.Content?.ReadAsByteArrayAsync().Result,
+ message.Response.RequestMessage.Content?.ReadAsByteArrayAsync().Result) == 0;
});
///
@@ -165,10 +165,10 @@ public RulesMatcher ByJsonContent(
JsonSerializerOptions jsonSerializerOptions = null)
=> By((request, message) =>
{
- var requestContent = request.Content?.ReadAsStringAsync()?.Result;
+ var requestContent = request.Content?.ReadAsStringAsync().Result;
var requestJson = !string.IsNullOrEmpty(requestContent) ? JsonSerializer.Deserialize(requestContent, jsonSerializerOptions) : default(T);
- var interactionContent = message.Response.RequestMessage.Content?.ReadAsStringAsync()?.Result;
+ var interactionContent = message.Response.RequestMessage.Content?.ReadAsStringAsync().Result;
var interactionJson = !string.IsNullOrEmpty(interactionContent) ? JsonSerializer.Deserialize(interactionContent, jsonSerializerOptions) : default(T);
if (equalityComparer == null)
diff --git a/HttpRecorder/Repositories/HAR/Header.cs b/HttpRecorder/Repositories/HAR/Header.cs
index 8887282..b282eb0 100644
--- a/HttpRecorder/Repositories/HAR/Header.cs
+++ b/HttpRecorder/Repositories/HAR/Header.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using System.Net.Http.Headers;
namespace HttpRecorder.Repositories.HAR
{