Fix unit tests on x-plat.
This commit is contained in:
parent
5576626d34
commit
c6477ad031
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
|
||||
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.Headers.ETag);
|
||||
Assert.NotNull(response.Headers.ETag.Tag);
|
||||
}
|
||||
|
|
@ -28,8 +28,8 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
|
||||
HttpResponseMessage response1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml");
|
||||
HttpResponseMessage response2 = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml");
|
||||
HttpResponseMessage response1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml");
|
||||
HttpResponseMessage response2 = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml");
|
||||
Assert.Equal(response2.Headers.ETag, response1.Headers.ETag);
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfMatchShouldReturn412WhenNotListed()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Extra.xml");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/extra.xml");
|
||||
req.Headers.Add("If-Match", "\"fake\"");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.PreconditionFailed, resp.StatusCode);
|
||||
|
|
@ -55,9 +55,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfMatchShouldBeServedWhenListed()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml");
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml");
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Extra.xml");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/extra.xml");
|
||||
req.Headers.Add("If-Match", original.Headers.ETag.ToString());
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -67,7 +67,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfMatchShouldBeServedForAstrisk()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Extra.xml");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/extra.xml");
|
||||
req.Headers.Add("If-Match", "*");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -91,14 +91,14 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfNoneMatchShouldReturn304ForMatchingOnGetAndHeadMethod()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage resp1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml");
|
||||
HttpResponseMessage resp1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml");
|
||||
|
||||
var req2 = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Extra.xml");
|
||||
var req2 = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/extra.xml");
|
||||
req2.Headers.Add("If-None-Match", resp1.Headers.ETag.ToString());
|
||||
HttpResponseMessage resp2 = await server.CreateClient().SendAsync(req2);
|
||||
Assert.Equal(HttpStatusCode.NotModified, resp2.StatusCode);
|
||||
|
||||
var req3 = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Extra.xml");
|
||||
var req3 = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/extra.xml");
|
||||
req3.Headers.Add("If-None-Match", resp1.Headers.ETag.ToString());
|
||||
HttpResponseMessage resp3 = await server.CreateClient().SendAsync(req3);
|
||||
Assert.Equal(HttpStatusCode.NotModified, resp3.StatusCode);
|
||||
|
|
@ -108,14 +108,14 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfNoneMatchShouldBeIgnoredForNonTwoHundredAnd304Responses()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage resp1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/Extra.xml");
|
||||
HttpResponseMessage resp1 = await server.CreateClient().GetAsync("http://localhost/SubFolder/extra.xml");
|
||||
|
||||
var req2 = new HttpRequestMessage(HttpMethod.Post, "http://localhost/SubFolder/Extra.xml");
|
||||
var req2 = new HttpRequestMessage(HttpMethod.Post, "http://localhost/SubFolder/extra.xml");
|
||||
req2.Headers.Add("If-None-Match", resp1.Headers.ETag.ToString());
|
||||
HttpResponseMessage resp2 = await server.CreateClient().SendAsync(req2);
|
||||
Assert.Equal(HttpStatusCode.NotFound, resp2.StatusCode);
|
||||
|
||||
var req3 = new HttpRequestMessage(HttpMethod.Put, "http://localhost/SubFolder/Extra.xml");
|
||||
var req3 = new HttpRequestMessage(HttpMethod.Put, "http://localhost/SubFolder/extra.xml");
|
||||
req3.Headers.Add("If-None-Match", resp1.Headers.ETag.ToString());
|
||||
HttpResponseMessage resp3 = await server.CreateClient().SendAsync(req3);
|
||||
Assert.Equal(HttpStatusCode.NotFound, resp3.StatusCode);
|
||||
|
|
@ -136,7 +136,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -154,11 +154,11 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage resp1 = await server
|
||||
.CreateRequest("/SubFolder/Extra.xml")
|
||||
.CreateRequest("/SubFolder/extra.xml")
|
||||
.GetAsync();
|
||||
|
||||
HttpResponseMessage resp2 = await server
|
||||
.CreateRequest("/SubFolder/Extra.xml")
|
||||
.CreateRequest("/SubFolder/extra.xml")
|
||||
.AddHeader("If-None-Match", resp1.Headers.ETag.ToString())
|
||||
.And(req => req.Headers.IfModifiedSince = resp1.Content.Headers.LastModified)
|
||||
.GetAsync();
|
||||
|
|
@ -171,7 +171,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage resp1 = await server
|
||||
.CreateRequest("/SubFolder/Extra.xml")
|
||||
.CreateRequest("/SubFolder/extra.xml")
|
||||
.GetAsync();
|
||||
|
||||
DateTimeOffset lastModified = resp1.Content.Headers.LastModified.Value;
|
||||
|
|
@ -179,19 +179,19 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
DateTimeOffset furtureDate = lastModified.AddHours(1);
|
||||
|
||||
HttpResponseMessage resp2 = await server
|
||||
.CreateRequest("/SubFolder/Extra.xml")
|
||||
.CreateRequest("/SubFolder/extra.xml")
|
||||
.AddHeader("If-None-Match", "\"fake\"")
|
||||
.And(req => req.Headers.IfModifiedSince = lastModified)
|
||||
.GetAsync();
|
||||
|
||||
HttpResponseMessage resp3 = await server
|
||||
.CreateRequest("/SubFolder/Extra.xml")
|
||||
.CreateRequest("/SubFolder/extra.xml")
|
||||
.AddHeader("If-None-Match", resp1.Headers.ETag.ToString())
|
||||
.And(req => req.Headers.IfModifiedSince = pastDate)
|
||||
.GetAsync();
|
||||
|
||||
HttpResponseMessage resp4 = await server
|
||||
.CreateRequest("/SubFolder/Extra.xml")
|
||||
.CreateRequest("/SubFolder/extra.xml")
|
||||
.AddHeader("If-None-Match", "\"fake\"")
|
||||
.And(req => req.Headers.IfModifiedSince = furtureDate)
|
||||
.GetAsync();
|
||||
|
|
@ -219,7 +219,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
|
||||
HttpResponseMessage res = await server
|
||||
.CreateRequest("/SubFolder/Extra.xml")
|
||||
.CreateRequest("/SubFolder/extra.xml")
|
||||
.AddHeader("If-Modified-Since", "bad-date")
|
||||
.GetAsync();
|
||||
|
||||
|
|
@ -239,11 +239,11 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
|
||||
HttpResponseMessage res1 = await server
|
||||
.CreateRequest("/SubFolder/Extra.xml")
|
||||
.CreateRequest("/SubFolder/extra.xml")
|
||||
.GetAsync();
|
||||
|
||||
HttpResponseMessage res2 = await server
|
||||
.CreateRequest("/SubFolder/Extra.xml")
|
||||
.CreateRequest("/SubFolder/extra.xml")
|
||||
.And(req => req.Headers.IfModifiedSince = res1.Content.Headers.LastModified)
|
||||
.GetAsync();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -32,7 +33,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("", @".", "/missing.dir/")]
|
||||
[InlineData("/subdir", @".", "/subdir/missing.dir")]
|
||||
[InlineData("/subdir", @".", "/subdir/missing.dir/")]
|
||||
[InlineData("", @".\", "/missing.dir")]
|
||||
[InlineData("", @"./", "/missing.dir")]
|
||||
public async Task NoMatch_PassesThrough(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app =>
|
||||
|
|
@ -52,8 +53,8 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
|
||||
[Theory]
|
||||
[InlineData("", @".", "/SubFolder/")]
|
||||
[InlineData("", @".\", "/SubFolder/")]
|
||||
[InlineData("", @".\SubFolder", "/")]
|
||||
[InlineData("", @"./", "/SubFolder/")]
|
||||
[InlineData("", @"./SubFolder", "/")]
|
||||
public async Task FoundDirectoryWithDefaultFile_PathModified(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app =>
|
||||
|
|
@ -73,8 +74,8 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
|
||||
[Theory]
|
||||
[InlineData("", @".", "/SubFolder", "")]
|
||||
[InlineData("", @".\", "/SubFolder", "")]
|
||||
[InlineData("", @".\", "/SubFolder", "?a=b")]
|
||||
[InlineData("", @"./", "/SubFolder", "")]
|
||||
[InlineData("", @"./", "/SubFolder", "?a=b")]
|
||||
public async Task NearMatch_RedirectAddSlash(string baseUrl, string baseDir, string requestUrl, string queryString)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseDefaultFiles(new DefaultFilesOptions()
|
||||
|
|
@ -85,15 +86,15 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
HttpResponseMessage response = await server.CreateRequest(requestUrl + queryString).GetAsync();
|
||||
|
||||
Assert.Equal(HttpStatusCode.Moved, response.StatusCode);
|
||||
Assert.Equal(requestUrl + "/" + queryString, response.Headers.Location.ToString());
|
||||
Assert.Equal(requestUrl + "/" + queryString, response.Headers.GetValues("Location").FirstOrDefault());
|
||||
Assert.Equal(0, (await response.Content.ReadAsByteArrayAsync()).Length);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/SubFolder", @".\", "/SubFolder/")]
|
||||
[InlineData("/SubFolder", @"./", "/SubFolder/")]
|
||||
[InlineData("/SubFolder", @".", "/somedir/")]
|
||||
[InlineData("", @".\SubFolder", "/")]
|
||||
[InlineData("", @".\SubFolder\", "/")]
|
||||
[InlineData("", @"./SubFolder", "/")]
|
||||
[InlineData("", @"./SubFolder/", "/")]
|
||||
public async Task PostDirectory_PassesThrough(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseDefaultFiles(new DefaultFilesOptions()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -43,7 +44,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("", @".", "/missing.dir/")]
|
||||
[InlineData("/subdir", @".", "/subdir/missing.dir")]
|
||||
[InlineData("/subdir", @".", "/subdir/missing.dir/")]
|
||||
[InlineData("", @".\", "/missing.dir")]
|
||||
[InlineData("", @"./", "/missing.dir")]
|
||||
public async Task NoMatch_PassesThrough(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(
|
||||
|
|
@ -61,8 +62,8 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("", @".", "/")]
|
||||
[InlineData("", @".", "/SubFolder/")]
|
||||
[InlineData("/somedir", @".", "/somedir/")]
|
||||
[InlineData("/somedir", @".\", "/somedir/")]
|
||||
[InlineData("/somedir", @".", "/somedir/subfolder/")]
|
||||
[InlineData("/somedir", @"./", "/somedir/")]
|
||||
[InlineData("/somedir", @".", "/somedir/SubFolder/")]
|
||||
public async Task FoundDirectory_Served(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(
|
||||
|
|
@ -83,10 +84,10 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[Theory]
|
||||
[InlineData("", @".", "/SubFolder", "")]
|
||||
[InlineData("/somedir", @".", "/somedir", "")]
|
||||
[InlineData("/somedir", @".", "/somedir/subfolder", "")]
|
||||
[InlineData("/somedir", @".", "/somedir/SubFolder", "")]
|
||||
[InlineData("", @".", "/SubFolder", "?a=b")]
|
||||
[InlineData("/somedir", @".", "/somedir", "?a=b")]
|
||||
[InlineData("/somedir", @".", "/somedir/subfolder", "?a=b")]
|
||||
[InlineData("/somedir", @".", "/somedir/SubFolder", "?a=b")]
|
||||
public async Task NearMatch_RedirectAddSlash(string baseUrl, string baseDir, string requestUrl, string queryString)
|
||||
{
|
||||
TestServer server = TestServer.Create(
|
||||
|
|
@ -100,7 +101,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
HttpResponseMessage response = await server.CreateRequest(requestUrl + queryString).GetAsync();
|
||||
|
||||
Assert.Equal(HttpStatusCode.Moved, response.StatusCode);
|
||||
Assert.Equal(requestUrl + "/" + queryString, response.Headers.Location.ToString());
|
||||
Assert.Equal(requestUrl + "/" + queryString, response.Headers.GetValues("Location").FirstOrDefault());
|
||||
Assert.Equal(0, (await response.Content.ReadAsByteArrayAsync()).Length);
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +109,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("", @".", "/")]
|
||||
[InlineData("", @".", "/SubFolder/")]
|
||||
[InlineData("/somedir", @".", "/somedir/")]
|
||||
[InlineData("/somedir", @".", "/somedir/subfolder/")]
|
||||
[InlineData("/somedir", @".", "/somedir/SubFolder/")]
|
||||
public async Task PostDirectory_PassesThrough(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(
|
||||
|
|
@ -127,7 +128,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[InlineData("", @".", "/")]
|
||||
[InlineData("", @".", "/SubFolder/")]
|
||||
[InlineData("/somedir", @".", "/somedir/")]
|
||||
[InlineData("/somedir", @".", "/somedir/subfolder/")]
|
||||
[InlineData("/somedir", @".", "/somedir/SubFolder/")]
|
||||
public async Task HeadDirectory_HeadersButNotBodyServed(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfRangeWithCurrentEtagShouldServePartialContent()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt");
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt");
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Headers.ETag.ToString());
|
||||
req.Headers.Add("Range", "bytes=0-10");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
|
|
@ -40,9 +40,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task HEADIfRangeWithCurrentEtagShouldReturn200Ok()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt");
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt");
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Headers.ETag.ToString());
|
||||
req.Headers.Add("Range", "bytes=0-10");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
|
|
@ -60,9 +60,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfRangeWithCurrentDateShouldServePartialContent()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt");
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt");
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r"));
|
||||
req.Headers.Add("Range", "bytes=0-10");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
|
|
@ -79,9 +79,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task HEADIfRangeWithCurrentDateShouldReturn200Ok()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt");
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt");
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r"));
|
||||
req.Headers.Add("Range", "bytes=0-10");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfRangeWithOldEtagShouldServeFullContent()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", "\"OldEtag\"");
|
||||
req.Headers.Add("Range", "bytes=0-10");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
|
|
@ -115,7 +115,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task HEADIfRangeWithOldEtagShouldServeFullContent()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", "\"OldEtag\"");
|
||||
req.Headers.Add("Range", "bytes=0-10");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
|
|
@ -131,9 +131,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfRangeWithOldDateShouldServeFullContent()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt");
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt");
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.Subtract(TimeSpan.FromDays(1)).ToString("r"));
|
||||
req.Headers.Add("Range", "bytes=0-10");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
|
|
@ -149,9 +149,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task HEADIfRangeWithOldDateShouldServeFullContent()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt");
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt");
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.Subtract(TimeSpan.FromDays(1)).ToString("r"));
|
||||
req.Headers.Add("Range", "bytes=0-10");
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
|
|
@ -168,9 +168,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task IfRangeWithoutRangeShouldServeFullContent()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt");
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt");
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Headers.ETag.ToString());
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -178,7 +178,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
Assert.Equal(62, resp.Content.Headers.ContentLength);
|
||||
Assert.Equal("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", await resp.Content.ReadAsStringAsync());
|
||||
|
||||
req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r"));
|
||||
resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -194,9 +194,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task HEADIfRangeWithoutRangeShouldServeFullContent()
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/Ranges.txt");
|
||||
HttpResponseMessage original = await server.CreateClient().GetAsync("http://localhost/SubFolder/ranges.txt");
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Headers.ETag.ToString());
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -204,7 +204,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
Assert.Equal(62, resp.Content.Headers.ContentLength);
|
||||
Assert.Equal(string.Empty, await resp.Content.ReadAsStringAsync());
|
||||
|
||||
req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r"));
|
||||
resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -226,7 +226,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task SingleValidRangeShouldServePartialContent(string range, string expectedRange, int length, string expectedData)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("Range", "bytes=" + range);
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.PartialContent, resp.StatusCode);
|
||||
|
|
@ -243,7 +243,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task HEADSingleValidRangeShouldReturnOk(string range)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("Range", "bytes=" + range);
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -260,7 +260,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task SingleNotSatisfiableRange(string range)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.TryAddWithoutValidation("Range", "bytes=" + range);
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.RequestedRangeNotSatisfiable, resp.StatusCode);
|
||||
|
|
@ -274,7 +274,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task HEADSingleNotSatisfiableRangeReturnsOk(string range)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.TryAddWithoutValidation("Range", "bytes=" + range);
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -290,7 +290,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task SingleInvalidRangeIgnored(string range)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.TryAddWithoutValidation("Range", "bytes=" + range);
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -308,7 +308,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task HEADSingleInvalidRangeIgnored(string range)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.TryAddWithoutValidation("Range", "bytes=" + range);
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -328,7 +328,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task MultipleValidRangesShouldServeFullContent(string ranges)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("Range", "bytes=" + ranges);
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
@ -347,7 +347,7 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
public async Task HEADMultipleValidRangesShouldServeFullContent(string range)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseFileServer());
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/Ranges.txt");
|
||||
var req = new HttpRequestMessage(HttpMethod.Head, "http://localhost/SubFolder/ranges.txt");
|
||||
req.Headers.Add("Range", "bytes=" + range);
|
||||
HttpResponseMessage resp = await server.CreateClient().SendAsync(req);
|
||||
Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[Theory]
|
||||
[InlineData("", @".", "/missing.file")]
|
||||
[InlineData("/subdir", @".", "/subdir/missing.file")]
|
||||
[InlineData("/missing.file", @".\", "/missing.file")]
|
||||
[InlineData("", @".\", "/xunit.xml")]
|
||||
[InlineData("/missing.file", @"./", "/missing.file")]
|
||||
[InlineData("", @"./", "/xunit.xml")]
|
||||
public async Task NoMatch_PassesThrough(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseStaticFiles(new StaticFileOptions()
|
||||
|
|
@ -48,11 +48,10 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
|
||||
[Theory]
|
||||
[InlineData("", @".", "/TestDocument.txt")]
|
||||
[InlineData("", @".", "/testDocument.Txt")]
|
||||
[InlineData("/somedir", @".", "/somedir/Testdocument.TXT")]
|
||||
[InlineData("/SomeDir", @".", "/soMediR/testdocument.txT")]
|
||||
[InlineData("/somedir", @".", "/somedir/TestDocument.txt")]
|
||||
[InlineData("/SomeDir", @".", "/soMediR/TestDocument.txt")]
|
||||
[InlineData("", @"SubFolder", "/ranges.txt")]
|
||||
[InlineData("/somedir", @"SubFolder", "/somedir/Ranges.tXt")]
|
||||
[InlineData("/somedir", @"SubFolder", "/somedir/ranges.txt")]
|
||||
public async Task FoundFile_Served(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseStaticFiles(new StaticFileOptions()
|
||||
|
|
@ -70,11 +69,10 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
|
||||
[Theory]
|
||||
[InlineData("", @".", "/TestDocument.txt")]
|
||||
[InlineData("", @".", "/testDocument.Txt")]
|
||||
[InlineData("/somedir", @".", "/somedir/Testdocument.TXT")]
|
||||
[InlineData("/SomeDir", @".", "/soMediR/testdocument.txT")]
|
||||
[InlineData("/somedir", @".", "/somedir/TestDocument.txt")]
|
||||
[InlineData("/SomeDir", @".", "/soMediR/TestDocument.txt")]
|
||||
[InlineData("", @"SubFolder", "/ranges.txt")]
|
||||
[InlineData("/somedir", @"SubFolder", "/somedir/Ranges.tXt")]
|
||||
[InlineData("/somedir", @"SubFolder", "/somedir/ranges.txt")]
|
||||
public async Task PostFile_PassesThrough(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseStaticFiles(new StaticFileOptions()
|
||||
|
|
@ -88,11 +86,10 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
|
||||
[Theory]
|
||||
[InlineData("", @".", "/TestDocument.txt")]
|
||||
[InlineData("", @".", "/testDocument.Txt")]
|
||||
[InlineData("/somedir", @".", "/somedir/Testdocument.TXT")]
|
||||
[InlineData("/SomeDir", @".", "/soMediR/testdocument.txT")]
|
||||
[InlineData("/somedir", @".", "/somedir/TestDocument.txt")]
|
||||
[InlineData("/SomeDir", @".", "/soMediR/TestDocument.txt")]
|
||||
[InlineData("", @"SubFolder", "/ranges.txt")]
|
||||
[InlineData("/somedir", @"SubFolder", "/somedir/Ranges.tXt")]
|
||||
[InlineData("/somedir", @"SubFolder", "/somedir/ranges.txt")]
|
||||
public async Task HeadFile_HeadersButNotBodyServed(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
TestServer server = TestServer.Create(app => app.UseStaticFiles(new StaticFileOptions()
|
||||
|
|
|
|||
Loading…
Reference in New Issue