Skip to content

Commit

Permalink
Merge pull request #237 from filipw/dev
Browse files Browse the repository at this point in the history
Sync master with latest dev #2
  • Loading branch information
filipw authored Apr 3, 2018
2 parents 4a8f908 + ebaf1fc commit 5d47acb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Build.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
%systemroot%\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe /m build.proj /t:%*
"c:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/msbuild.exe" /m build.proj /t:%*
11 changes: 10 additions & 1 deletion src/WebApi.OutputCache.V2/CacheOutputAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,16 @@ public override void OnActionExecuting(HttpActionContext actionContext)
if (val == null) return;

var contenttype = _webApiCache.Get<MediaTypeHeaderValue>(cachekey + Constants.ContentTypeKey) ?? responseMediaType;
var contentGenerationTimestamp = DateTimeOffset.Parse(_webApiCache.Get<string>(cachekey + Constants.GenerationTimestampKey));
var contentGeneration = _webApiCache.Get<string>(cachekey + Constants.GenerationTimestampKey);

DateTimeOffset? contentGenerationTimestamp = null;
if (contentGeneration != null)
{
if (DateTimeOffset.TryParse(contentGeneration, out DateTimeOffset parsedContentGenerationTimestamp))
{
contentGenerationTimestamp = parsedContentGenerationTimestamp;
}
};

actionContext.Response = actionContext.Request.CreateResponse();
actionContext.Response.Content = new ByteArrayContent(val);
Expand Down
2 changes: 1 addition & 1 deletion test/WebApi.OutputCache.V2.Tests/ClientSideTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void maxage_mustrevalidate_headers_correct_with_cacheuntil()
{
var client = new HttpClient(_server);
var result = client.GetAsync(_url + "Get_until25012015_1700").Result;
var clientTimeSpanSeconds = new SpecificTime(2017, 01, 25, 17, 0, 0).Execute(DateTime.Now).ClientTimeSpan.TotalSeconds;
var clientTimeSpanSeconds = new SpecificTime(2019, 01, 25, 17, 0, 0).Execute(DateTime.Now).ClientTimeSpan.TotalSeconds;
var resultCacheControlSeconds = ((TimeSpan) result.Headers.CacheControl.MaxAge).TotalSeconds;
Assert.IsTrue(Math.Round(clientTimeSpanSeconds - resultCacheControlSeconds) == 0);
Assert.IsFalse(result.Headers.CacheControl.MustRevalidate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public string Get_s50_exclude_true(int id)
return "test" + id;
}

[CacheOutputUntil(2017,01,25,17,00)]
[CacheOutputUntil(2019,01,25,17,00)]
public string Get_until25012015_1700()
{
return "test";
Expand Down

0 comments on commit 5d47acb

Please sign in to comment.