Use UTC
This commit is contained in:
parent
5165163c2c
commit
e05469a989
|
|
@ -140,7 +140,7 @@ namespace Microsoft.AspNet.StaticFiles
|
||||||
|
|
||||||
DateTimeOffset last = _fileInfo.LastModified;
|
DateTimeOffset last = _fileInfo.LastModified;
|
||||||
// Truncate to the second.
|
// Truncate to the second.
|
||||||
_lastModified = new DateTimeOffset(last.Year, last.Month, last.Day, last.Hour, last.Minute, last.Second, last.Offset);
|
_lastModified = new DateTimeOffset(last.Year, last.Month, last.Day, last.Hour, last.Minute, last.Second, last.Offset).ToUniversalTime();
|
||||||
|
|
||||||
long etagHash = _lastModified.ToFileTime() ^ _length;
|
long etagHash = _lastModified.ToFileTime() ^ _length;
|
||||||
_etag = new EntityTagHeaderValue('\"' + Convert.ToString(etagHash, 16) + '\"');
|
_etag = new EntityTagHeaderValue('\"' + Convert.ToString(etagHash, 16) + '\"');
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,8 @@ namespace Microsoft.AspNet.StaticFiles
|
||||||
|
|
||||||
HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml");
|
HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml");
|
||||||
Assert.NotNull(response.Content.Headers.LastModified);
|
Assert.NotNull(response.Content.Headers.LastModified);
|
||||||
|
// Verify that DateTimeOffset is UTC
|
||||||
|
Assert.Equal(response.Content.Headers.LastModified.Value.Offset, TimeSpan.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 13.3.4
|
// 13.3.4
|
||||||
|
|
@ -234,7 +236,7 @@ namespace Microsoft.AspNet.StaticFiles
|
||||||
// Modified) response.
|
// Modified) response.
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task IfModifiedSinceDateEqualsLastModifiedShouldReturn304()
|
public async Task IfModifiedSinceDateGreaterThanLastModifiedShouldReturn304()
|
||||||
{
|
{
|
||||||
TestServer server = StaticFilesTestServer.Create(app => app.UseFileServer());
|
TestServer server = StaticFilesTestServer.Create(app => app.UseFileServer());
|
||||||
|
|
||||||
|
|
@ -244,10 +246,27 @@ namespace Microsoft.AspNet.StaticFiles
|
||||||
|
|
||||||
HttpResponseMessage res2 = await server
|
HttpResponseMessage res2 = await server
|
||||||
.CreateRequest("/SubFolder/extra.xml")
|
.CreateRequest("/SubFolder/extra.xml")
|
||||||
.And(req => req.Headers.IfModifiedSince = res1.Content.Headers.LastModified)
|
.And(req => req.Headers.IfModifiedSince = DateTimeOffset.Now)
|
||||||
.GetAsync();
|
.GetAsync();
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.NotModified, res2.StatusCode);
|
Assert.Equal(HttpStatusCode.NotModified, res2.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task IfModifiedSinceDateLessThanLastModifiedShouldReturn200()
|
||||||
|
{
|
||||||
|
TestServer server = StaticFilesTestServer.Create(app => app.UseFileServer());
|
||||||
|
|
||||||
|
HttpResponseMessage res1 = await server
|
||||||
|
.CreateRequest("/SubFolder/extra.xml")
|
||||||
|
.GetAsync();
|
||||||
|
|
||||||
|
HttpResponseMessage res2 = await server
|
||||||
|
.CreateRequest("/SubFolder/extra.xml")
|
||||||
|
.And(req => req.Headers.IfModifiedSince = DateTimeOffset.MinValue)
|
||||||
|
.GetAsync();
|
||||||
|
|
||||||
|
Assert.Equal(HttpStatusCode.OK, res2.StatusCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue