diff --git a/src/Middleware/ResponseCaching/src/Interfaces/IResponseCache.cs b/src/Middleware/ResponseCaching/src/Interfaces/IResponseCache.cs
index 4ca2c6e8d1..6b6f95fab3 100644
--- a/src/Middleware/ResponseCaching/src/Interfaces/IResponseCache.cs
+++ b/src/Middleware/ResponseCaching/src/Interfaces/IResponseCache.cs
@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@@ -16,14 +16,6 @@ namespace Microsoft.AspNetCore.ResponseCaching
/// The response cache entry if it exists; otherwise null.
IResponseCacheEntry Get(string key);
- ///
- /// Gets the cached response for the given key, if it exists.
- /// If no cached response exists for the given key, null is returned.
- ///
- /// The cache key to look up.
- /// The response cache entry if it exists; otherwise null.
- Task GetAsync(string key);
-
///
/// Stores the given response in the response cache.
///
@@ -31,14 +23,5 @@ namespace Microsoft.AspNetCore.ResponseCaching
/// The response cache entry to store.
/// The amount of time the entry will be kept in the cache before expiring, relative to now.
void Set(string key, IResponseCacheEntry entry, TimeSpan validFor);
-
- ///
- /// Stores the given response in the response cache.
- ///
- /// The cache key to store the response under.
- /// The response cache entry to store.
- /// The amount of time the entry will be kept in the cache before expiring, relative to now.
- /// No result is returned.
- Task SetAsync(string key, IResponseCacheEntry entry, TimeSpan validFor);
}
}
diff --git a/src/Middleware/ResponseCaching/src/MemoryResponseCache.cs b/src/Middleware/ResponseCaching/src/MemoryResponseCache.cs
index 554ab361d8..b3fee366f7 100644
--- a/src/Middleware/ResponseCaching/src/MemoryResponseCache.cs
+++ b/src/Middleware/ResponseCaching/src/MemoryResponseCache.cs
@@ -36,11 +36,6 @@ namespace Microsoft.AspNetCore.ResponseCaching
}
}
- public Task GetAsync(string key)
- {
- return Task.FromResult(Get(key));
- }
-
public void Set(string key, IResponseCacheEntry entry, TimeSpan validFor)
{
if (entry is CachedResponse cachedResponse)
@@ -76,11 +71,5 @@ namespace Microsoft.AspNetCore.ResponseCaching
});
}
}
-
- public Task SetAsync(string key, IResponseCacheEntry entry, TimeSpan validFor)
- {
- Set(key, entry, validFor);
- return Task.CompletedTask;
- }
}
}
diff --git a/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs b/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs
index d679559da7..9bce6b921d 100644
--- a/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs
+++ b/src/Middleware/ResponseCaching/src/ResponseCachingMiddleware.cs
@@ -113,10 +113,10 @@ namespace Microsoft.AspNetCore.ResponseCaching
await _next(httpContext);
// If there was no response body, check the response headers now. We can cache things like redirects.
- await StartResponseAsync(context);
+ StartResponse(context);
// Finalize the cache entry
- await FinalizeCacheBodyAsync(context);
+ FinalizeCacheBody(context);
}
finally
{
@@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
internal async Task TryServeFromCacheAsync(ResponseCachingContext context)
{
context.BaseKey = _keyProvider.CreateBaseKey(context);
- var cacheEntry = await _cache.GetAsync(context.BaseKey);
+ var cacheEntry = _cache.Get(context.BaseKey);
if (cacheEntry is CachedVaryByRules cachedVaryByRules)
{
@@ -220,7 +220,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
foreach (var varyKey in _keyProvider.CreateLookupVaryByKeys(context))
{
- if (await TryServeCachedResponseAsync(context, await _cache.GetAsync(varyKey)))
+ if (await TryServeCachedResponseAsync(context, _cache.Get(varyKey)))
{
return true;
}
@@ -339,16 +339,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
}
}
- internal Task FinalizeCacheHeadersAsync(ResponseCachingContext context)
- {
- if (OnFinalizeCacheHeaders(context))
- {
- return _cache.SetAsync(context.BaseKey, context.CachedVaryByRules, context.CachedResponseValidFor);
- }
- return Task.CompletedTask;
- }
-
- internal async Task FinalizeCacheBodyAsync(ResponseCachingContext context)
+ internal void FinalizeCacheBody(ResponseCachingContext context)
{
if (context.ShouldCacheResponse && context.ResponseCachingStream.BufferingEnabled)
{
@@ -365,7 +356,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
context.CachedResponse.Body = bufferStream;
_logger.ResponseCached();
- await _cache.SetAsync(context.StorageVaryKey ?? context.BaseKey, context.CachedResponse, context.CachedResponseValidFor);
+ _cache.Set(context.StorageVaryKey ?? context.BaseKey, context.CachedResponse, context.CachedResponseValidFor);
}
else
{
@@ -403,15 +394,6 @@ namespace Microsoft.AspNetCore.ResponseCaching
}
}
- internal Task StartResponseAsync(ResponseCachingContext context)
- {
- if (OnStartResponse(context))
- {
- return FinalizeCacheHeadersAsync(context);
- }
- return Task.CompletedTask;
- }
-
internal static void AddResponseCachingFeature(HttpContext context)
{
if (context.Features.Get() != null)
@@ -429,8 +411,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
context.OriginalResponseStream,
_options.MaximumBodySize,
StreamUtilities.BodySegmentSize,
- () => StartResponse(context),
- () => StartResponseAsync(context));
+ () => StartResponse(context));
context.HttpContext.Response.Body = context.ResponseCachingStream;
// Add IResponseCachingFeature
diff --git a/src/Middleware/ResponseCaching/src/Streams/ResponseCachingStream.cs b/src/Middleware/ResponseCaching/src/Streams/ResponseCachingStream.cs
index a788778e94..f6d705e1f1 100644
--- a/src/Middleware/ResponseCaching/src/Streams/ResponseCachingStream.cs
+++ b/src/Middleware/ResponseCaching/src/Streams/ResponseCachingStream.cs
@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@@ -15,15 +15,13 @@ namespace Microsoft.AspNetCore.ResponseCaching
private readonly int _segmentSize;
private readonly SegmentWriteStream _segmentWriteStream;
private readonly Action _startResponseCallback;
- private readonly Func _startResponseCallbackAsync;
- internal ResponseCachingStream(Stream innerStream, long maxBufferSize, int segmentSize, Action startResponseCallback, Func startResponseCallbackAsync)
+ internal ResponseCachingStream(Stream innerStream, long maxBufferSize, int segmentSize, Action startResponseCallback)
{
_innerStream = innerStream;
_maxBufferSize = maxBufferSize;
_segmentSize = segmentSize;
_startResponseCallback = startResponseCallback;
- _startResponseCallbackAsync = startResponseCallbackAsync;
_segmentWriteStream = new SegmentWriteStream(_segmentSize);
}
@@ -92,7 +90,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
{
try
{
- await _startResponseCallbackAsync();
+ _startResponseCallback();
await _innerStream.FlushAsync();
}
catch
@@ -136,7 +134,7 @@ namespace Microsoft.AspNetCore.ResponseCaching
{
try
{
- await _startResponseCallbackAsync();
+ _startResponseCallback();
await _innerStream.WriteAsync(buffer, offset, count, cancellationToken);
}
catch
diff --git a/src/Middleware/ResponseCaching/test/ResponseCachingMiddlewareTests.cs b/src/Middleware/ResponseCaching/test/ResponseCachingMiddlewareTests.cs
index 43970711ea..a0332fb83b 100644
--- a/src/Middleware/ResponseCaching/test/ResponseCachingMiddlewareTests.cs
+++ b/src/Middleware/ResponseCaching/test/ResponseCachingMiddlewareTests.cs
@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
var middleware = TestUtils.CreateTestMiddleware(testSink: sink, cache: cache, keyProvider: new TestResponseCachingKeyProvider("BaseKey"));
var context = TestUtils.CreateTestContext();
- await cache.SetAsync(
+ cache.Set(
"BaseKey",
new CachedResponse()
{
@@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
var context = TestUtils.CreateTestContext();
context.HttpContext.Response.Headers["MyHeader"] = "OldValue";
- await cache.SetAsync(
+ cache.Set(
"BaseKey",
new CachedResponse()
{
@@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
var middleware = TestUtils.CreateTestMiddleware(testSink: sink, cache: cache, keyProvider: new TestResponseCachingKeyProvider("BaseKey", "VaryKey"));
var context = TestUtils.CreateTestContext();
- await cache.SetAsync(
+ cache.Set(
"BaseKey",
new CachedVaryByRules(),
TimeSpan.Zero);
@@ -131,11 +131,11 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
var middleware = TestUtils.CreateTestMiddleware(testSink: sink, cache: cache, keyProvider: new TestResponseCachingKeyProvider("BaseKey", new[] { "VaryKey", "VaryKey2" }));
var context = TestUtils.CreateTestContext();
- await cache.SetAsync(
+ cache.Set(
"BaseKey",
new CachedVaryByRules(),
TimeSpan.Zero);
- await cache.SetAsync(
+ cache.Set(
"BaseKeyVaryKey2",
new CachedResponse()
{
@@ -160,7 +160,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
var context = TestUtils.CreateTestContext();
context.HttpContext.Request.Headers[HeaderNames.IfNoneMatch] = "*";
- await cache.SetAsync(
+ cache.Set(
"BaseKey",
new CachedResponse()
{
@@ -358,7 +358,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
}
[Fact]
- public async Task StartResponsegAsync_IfAllowResponseCaptureIsTrue_SetsResponseTime()
+ public void StartResponsegAsync_IfAllowResponseCaptureIsTrue_SetsResponseTime()
{
var clock = new TestClock
{
@@ -371,13 +371,13 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
var context = TestUtils.CreateTestContext();
context.ResponseTime = null;
- await middleware.StartResponseAsync(context);
+ middleware.StartResponse(context);
Assert.Equal(clock.UtcNow, context.ResponseTime);
}
[Fact]
- public async Task StartResponseAsync_IfAllowResponseCaptureIsTrue_SetsResponseTimeOnlyOnce()
+ public void StartResponseAsync_IfAllowResponseCaptureIsTrue_SetsResponseTimeOnlyOnce()
{
var clock = new TestClock
{
@@ -391,18 +391,18 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
var initialTime = clock.UtcNow;
context.ResponseTime = null;
- await middleware.StartResponseAsync(context);
+ middleware.StartResponse(context);
Assert.Equal(initialTime, context.ResponseTime);
clock.UtcNow += TimeSpan.FromSeconds(10);
- await middleware.StartResponseAsync(context);
+ middleware.StartResponse(context);
Assert.NotEqual(clock.UtcNow, context.ResponseTime);
Assert.Equal(initialTime, context.ResponseTime);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_UpdateShouldCacheResponse_IfResponseCacheable()
+ public void FinalizeCacheHeadersAsync_UpdateShouldCacheResponse_IfResponseCacheable()
{
var sink = new TestSink();
var middleware = TestUtils.CreateTestMiddleware(testSink: sink, policyProvider: new ResponseCachingPolicyProvider());
@@ -415,14 +415,14 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
Assert.False(context.ShouldCacheResponse);
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.True(context.ShouldCacheResponse);
Assert.Empty(sink.Writes);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_DoNotUpdateShouldCacheResponse_IfResponseIsNotCacheable()
+ public void FinalizeCacheHeadersAsync_DoNotUpdateShouldCacheResponse_IfResponseIsNotCacheable()
{
var sink = new TestSink();
var middleware = TestUtils.CreateTestMiddleware(testSink: sink, policyProvider: new ResponseCachingPolicyProvider());
@@ -430,27 +430,27 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
middleware.ShimResponseStream(context);
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.False(context.ShouldCacheResponse);
Assert.Empty(sink.Writes);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_DefaultResponseValidity_Is10Seconds()
+ public void FinalizeCacheHeadersAsync_DefaultResponseValidity_Is10Seconds()
{
var sink = new TestSink();
var middleware = TestUtils.CreateTestMiddleware(testSink: sink);
var context = TestUtils.CreateTestContext();
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.Equal(TimeSpan.FromSeconds(10), context.CachedResponseValidFor);
Assert.Empty(sink.Writes);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_ResponseValidity_UseExpiryIfAvailable()
+ public void FinalizeCacheHeadersAsync_ResponseValidity_UseExpiryIfAvailable()
{
var clock = new TestClock
{
@@ -466,14 +466,14 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
context.ResponseTime = clock.UtcNow;
context.HttpContext.Response.Headers[HeaderNames.Expires] = HeaderUtilities.FormatDate(clock.UtcNow + TimeSpan.FromSeconds(11));
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.Equal(TimeSpan.FromSeconds(11), context.CachedResponseValidFor);
Assert.Empty(sink.Writes);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_ResponseValidity_UseMaxAgeIfAvailable()
+ public void FinalizeCacheHeadersAsync_ResponseValidity_UseMaxAgeIfAvailable()
{
var clock = new TestClock
{
@@ -494,14 +494,14 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
context.HttpContext.Response.Headers[HeaderNames.Expires] = HeaderUtilities.FormatDate(clock.UtcNow + TimeSpan.FromSeconds(11));
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.Equal(TimeSpan.FromSeconds(12), context.CachedResponseValidFor);
Assert.Empty(sink.Writes);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_ResponseValidity_UseSharedMaxAgeIfAvailable()
+ public void FinalizeCacheHeadersAsync_ResponseValidity_UseSharedMaxAgeIfAvailable()
{
var clock = new TestClock
{
@@ -522,14 +522,14 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
}.ToString();
context.HttpContext.Response.Headers[HeaderNames.Expires] = HeaderUtilities.FormatDate(clock.UtcNow + TimeSpan.FromSeconds(11));
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.Equal(TimeSpan.FromSeconds(13), context.CachedResponseValidFor);
Assert.Empty(sink.Writes);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_UpdateCachedVaryByRules_IfNotEquivalentToPrevious()
+ public void FinalizeCacheHeadersAsync_UpdateCachedVaryByRules_IfNotEquivalentToPrevious()
{
var cache = new TestResponseCache();
var sink = new TestSink();
@@ -548,7 +548,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
};
context.CachedVaryByRules = cachedVaryByRules;
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.Equal(1, cache.SetCount);
Assert.NotSame(cachedVaryByRules, context.CachedVaryByRules);
@@ -558,7 +558,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_UpdateCachedVaryByRules_IfEquivalentToPrevious()
+ public void FinalizeCacheHeadersAsync_UpdateCachedVaryByRules_IfEquivalentToPrevious()
{
var cache = new TestResponseCache();
var sink = new TestSink();
@@ -578,7 +578,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
};
context.CachedVaryByRules = cachedVaryByRules;
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
// An update to the cache is always made but the entry should be the same
Assert.Equal(1, cache.SetCount);
@@ -608,7 +608,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
[Theory]
[MemberData(nameof(NullOrEmptyVaryRules))]
- public async Task FinalizeCacheHeadersAsync_UpdateCachedVaryByRules_NullOrEmptyRules(StringValues vary)
+ public void FinalizeCacheHeadersAsync_UpdateCachedVaryByRules_NullOrEmptyRules(StringValues vary)
{
var cache = new TestResponseCache();
var sink = new TestSink();
@@ -621,7 +621,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
VaryByQueryKeys = vary
});
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
// Vary rules should not be updated
Assert.Equal(0, cache.SetCount);
@@ -629,7 +629,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_AddsDate_IfNoneSpecified()
+ public void FinalizeCacheHeadersAsync_AddsDate_IfNoneSpecified()
{
var utcNow = DateTimeOffset.UtcNow;
var sink = new TestSink();
@@ -640,14 +640,14 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
Assert.True(StringValues.IsNullOrEmpty(context.HttpContext.Response.Headers[HeaderNames.Date]));
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.Equal(HeaderUtilities.FormatDate(utcNow), context.HttpContext.Response.Headers[HeaderNames.Date]);
Assert.Empty(sink.Writes);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_DoNotAddDate_IfSpecified()
+ public void FinalizeCacheHeadersAsync_DoNotAddDate_IfSpecified()
{
var utcNow = DateTimeOffset.MinValue;
var sink = new TestSink();
@@ -659,14 +659,14 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
Assert.Equal(HeaderUtilities.FormatDate(utcNow), context.HttpContext.Response.Headers[HeaderNames.Date]);
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.Equal(HeaderUtilities.FormatDate(utcNow), context.HttpContext.Response.Headers[HeaderNames.Date]);
Assert.Empty(sink.Writes);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_StoresCachedResponse_InState()
+ public void FinalizeCacheHeadersAsync_StoresCachedResponse_InState()
{
var sink = new TestSink();
var middleware = TestUtils.CreateTestMiddleware(testSink: sink);
@@ -674,14 +674,14 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
Assert.Null(context.CachedResponse);
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.NotNull(context.CachedResponse);
Assert.Empty(sink.Writes);
}
[Fact]
- public async Task FinalizeCacheHeadersAsync_SplitsVaryHeaderByCommas()
+ public void FinalizeCacheHeadersAsync_SplitsVaryHeaderByCommas()
{
var sink = new TestSink();
var middleware = TestUtils.CreateTestMiddleware(testSink: sink);
@@ -689,7 +689,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
context.HttpContext.Response.Headers[HeaderNames.Vary] = "HeaderB, heaDera";
- await middleware.FinalizeCacheHeadersAsync(context);
+ middleware.FinalizeCacheHeaders(context);
Assert.Equal(new StringValues(new[] { "HEADERA", "HEADERB" }), context.CachedVaryByRules.Headers);
TestUtils.AssertLoggedMessages(
@@ -715,7 +715,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
context.BaseKey = "BaseKey";
context.CachedResponseValidFor = TimeSpan.FromSeconds(10);
- await middleware.FinalizeCacheBodyAsync(context);
+ middleware.FinalizeCacheBody(context);
Assert.Equal(1, cache.SetCount);
TestUtils.AssertLoggedMessages(
@@ -741,7 +741,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
context.BaseKey = "BaseKey";
context.CachedResponseValidFor = TimeSpan.FromSeconds(10);
- await middleware.FinalizeCacheBodyAsync(context);
+ middleware.FinalizeCacheBody(context);
Assert.Equal(0, cache.SetCount);
TestUtils.AssertLoggedMessages(
@@ -769,7 +769,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
context.BaseKey = "BaseKey";
context.CachedResponseValidFor = TimeSpan.FromSeconds(10);
- await middleware.FinalizeCacheBodyAsync(context);
+ middleware.FinalizeCacheBody(context);
Assert.Equal(1, cache.SetCount);
TestUtils.AssertLoggedMessages(
@@ -789,7 +789,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
await context.HttpContext.Response.WriteAsync(new string('0', 10));
context.ShouldCacheResponse = false;
- await middleware.FinalizeCacheBodyAsync(context);
+ middleware.FinalizeCacheBody(context);
Assert.Equal(0, cache.SetCount);
TestUtils.AssertLoggedMessages(
@@ -811,7 +811,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
context.ResponseCachingStream.DisableBuffering();
- await middleware.FinalizeCacheBodyAsync(context);
+ middleware.FinalizeCacheBody(context);
Assert.Equal(0, cache.SetCount);
TestUtils.AssertLoggedMessages(
@@ -840,7 +840,7 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
context.CachedResponse = new CachedResponse() { Headers = new HeaderDictionary() };
context.CachedResponseValidFor = TimeSpan.FromSeconds(10);
- await middleware.FinalizeCacheBodyAsync(context);
+ middleware.FinalizeCacheBody(context);
// The response cached message will be logged but the adding of the entry will no-op
TestUtils.AssertLoggedMessages(
diff --git a/src/Middleware/ResponseCaching/test/TestUtils.cs b/src/Middleware/ResponseCaching/test/TestUtils.cs
index 00e2308b05..de54e95da6 100644
--- a/src/Middleware/ResponseCaching/test/TestUtils.cs
+++ b/src/Middleware/ResponseCaching/test/TestUtils.cs
@@ -385,22 +385,11 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
}
}
- public Task GetAsync(string key)
- {
- return Task.FromResult(Get(key));
- }
-
public void Set(string key, IResponseCacheEntry entry, TimeSpan validFor)
{
SetCount++;
_storage[key] = entry;
}
-
- public Task SetAsync(string key, IResponseCacheEntry entry, TimeSpan validFor)
- {
- Set(key, entry, validFor);
- return Task.CompletedTask;
- }
}
internal class TestClock : ISystemClock