Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit c00a684

Browse files
committed
More feedback
1 parent a00d0d8 commit c00a684

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ internal string CreateCacheKey(CachedVaryBy varyBy)
195195
if (varyBy.Params.Count == 1 && string.Equals(varyBy.Params[0], "*"))
196196
{
197197
// Vary by all available query params
198-
foreach (var query in _httpContext.Request.Query.OrderBy(q => q.Key))
198+
foreach (var query in _httpContext.Request.Query.OrderBy(q => q.Key, StringComparer.OrdinalIgnoreCase))
199199
{
200200
builder.Append(KeyDelimiter)
201201
.Append(query.Key.ToUpperInvariant())
@@ -503,7 +503,7 @@ internal void FinalizeCachingHeaders()
503503
// Create the cache entry now
504504
var response = _httpContext.Response;
505505
var varyHeaderValue = response.Headers[HeaderNames.Vary];
506-
var varyParamsValue = _httpContext.GetResponseCachingOptions().Params;
506+
var varyParamsValue = _httpContext.GetResponseCachingFeature().VaryByParams;
507507
_cachedResponseValidFor = ResponseCacheControl.SharedMaxAge
508508
?? ResponseCacheControl.MaxAge
509509
?? (ResponseHeaders.Expires - _responseTime)
@@ -596,7 +596,7 @@ internal void ShimResponseStream()
596596
}
597597

598598
// TODO: Move this temporary interface with endpoint to HttpAbstractions
599-
_httpContext.AddResponseCachingOptions();
599+
_httpContext.AddResponseCachingFeature();
600600
}
601601

602602
internal void UnshimResponseStream()
@@ -608,7 +608,7 @@ internal void UnshimResponseStream()
608608
_httpContext.Features.Set(OriginalSendFileFeature);
609609

610610
// TODO: Move this temporary interface with endpoint to HttpAbstractions
611-
_httpContext.RemoveResponseCachingOptions();
611+
_httpContext.RemoveResponseCachingFeature();
612612
}
613613

614614
private enum ResponseType

src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using Microsoft.AspNetCore.ResponseCaching;
6-
using Microsoft.Extensions.Options;
76

87
namespace Microsoft.AspNetCore.Builder
98
{

src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingFeature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ namespace Microsoft.AspNetCore.ResponseCaching
88
// TODO: Temporary interface for endpoints to specify options for response caching
99
public class ResponseCachingFeature
1010
{
11-
public StringValues Params { get; set; }
11+
public StringValues VaryByParams { get; set; }
1212
}
1313
}

src/Microsoft.AspNetCore.ResponseCaching/ResponseCachingHttpContextExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ namespace Microsoft.AspNetCore.ResponseCaching
88
// TODO: Temporary interface for endpoints to specify options for response caching
99
public static class ResponseCachingHttpContextExtensions
1010
{
11-
public static void AddResponseCachingOptions(this HttpContext httpContext)
11+
public static void AddResponseCachingFeature(this HttpContext httpContext)
1212
{
1313
httpContext.Features.Set(new ResponseCachingFeature());
1414
}
1515

16-
public static void RemoveResponseCachingOptions(this HttpContext httpContext)
16+
public static void RemoveResponseCachingFeature(this HttpContext httpContext)
1717
{
1818
httpContext.Features.Set<ResponseCachingFeature>(null);
1919
}
2020

21-
public static ResponseCachingFeature GetResponseCachingOptions(this HttpContext httpContext)
21+
public static ResponseCachingFeature GetResponseCachingFeature(this HttpContext httpContext)
2222
{
2323
return httpContext.Features.Get<ResponseCachingFeature>() ?? new ResponseCachingFeature();
2424
}

test/Microsoft.AspNetCore.ResponseCaching.Tests/ResponseCachingTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public async void ServesCachedContent_IfVaryByParams_Matches()
145145
};
146146
headers.Date = DateTimeOffset.UtcNow;
147147
headers.Headers["X-Value"] = uniqueId;
148-
context.GetResponseCachingOptions().Params = "param";
148+
context.GetResponseCachingFeature().VaryByParams = "param";
149149
await context.Response.WriteAsync(uniqueId);
150150
});
151151

@@ -182,7 +182,7 @@ public async void ServesCachedContent_IfVaryByParamsExplicit_Matches_ParamNameCa
182182
};
183183
headers.Date = DateTimeOffset.UtcNow;
184184
headers.Headers["X-Value"] = uniqueId;
185-
context.GetResponseCachingOptions().Params = new[] { "ParamA", "paramb" };
185+
context.GetResponseCachingFeature().VaryByParams = new[] { "ParamA", "paramb" };
186186
await context.Response.WriteAsync(uniqueId);
187187
});
188188

@@ -219,7 +219,7 @@ public async void ServesCachedContent_IfVaryByParamsStar_Matches_ParamNameCaseIn
219219
};
220220
headers.Date = DateTimeOffset.UtcNow;
221221
headers.Headers["X-Value"] = uniqueId;
222-
context.GetResponseCachingOptions().Params = new[] { "*" };
222+
context.GetResponseCachingFeature().VaryByParams = new[] { "*" };
223223
await context.Response.WriteAsync(uniqueId);
224224
});
225225

@@ -247,7 +247,7 @@ public async void ServesCachedContent_IfVaryByParamsExplicit_Matches_OrderInsens
247247
};
248248
headers.Date = DateTimeOffset.UtcNow;
249249
headers.Headers["X-Value"] = uniqueId;
250-
context.GetResponseCachingOptions().Params = new[] { "ParamB", "ParamA" };
250+
context.GetResponseCachingFeature().VaryByParams = new[] { "ParamB", "ParamA" };
251251
await context.Response.WriteAsync(uniqueId);
252252
});
253253

@@ -275,7 +275,7 @@ public async void ServesCachedContent_IfVaryByParamsStar_Matches_OrderInsensitiv
275275
};
276276
headers.Date = DateTimeOffset.UtcNow;
277277
headers.Headers["X-Value"] = uniqueId;
278-
context.GetResponseCachingOptions().Params = new[] { "*" };
278+
context.GetResponseCachingFeature().VaryByParams = new[] { "*" };
279279
await context.Response.WriteAsync(uniqueId);
280280
});
281281

@@ -303,7 +303,7 @@ public async void ServesFreshContent_IfVaryByParams_Mismatches()
303303
};
304304
headers.Date = DateTimeOffset.UtcNow;
305305
headers.Headers["X-Value"] = uniqueId;
306-
context.GetResponseCachingOptions().Params = "param";
306+
context.GetResponseCachingFeature().VaryByParams = "param";
307307
await context.Response.WriteAsync(uniqueId);
308308
});
309309

@@ -331,7 +331,7 @@ public async void ServesFreshContent_IfVaryByParamsExplicit_Mismatch_ParamValueC
331331
};
332332
headers.Date = DateTimeOffset.UtcNow;
333333
headers.Headers["X-Value"] = uniqueId;
334-
context.GetResponseCachingOptions().Params = new[] { "ParamA", "ParamB" };
334+
context.GetResponseCachingFeature().VaryByParams = new[] { "ParamA", "ParamB" };
335335
await context.Response.WriteAsync(uniqueId);
336336
});
337337

@@ -359,7 +359,7 @@ public async void ServesFreshContent_IfVaryByParamsStar_Mismatch_ParamValueCaseS
359359
};
360360
headers.Date = DateTimeOffset.UtcNow;
361361
headers.Headers["X-Value"] = uniqueId;
362-
context.GetResponseCachingOptions().Params = new[] { "*" };
362+
context.GetResponseCachingFeature().VaryByParams = new[] { "*" };
363363
await context.Response.WriteAsync(uniqueId);
364364
});
365365

0 commit comments

Comments
 (0)