Generalize BasePath logic.

This commit is contained in:
Chris Ross 2014-12-18 15:30:43 -08:00
parent 4ad0f41eea
commit 4333003df0
3 changed files with 7 additions and 6 deletions

View File

@ -38,6 +38,12 @@ namespace Microsoft.AspNet.TestHost
}
_next = next;
// PathString.StartsWithSegments that we use below requires the base path to not end in a slash.
if (pathBase.HasValue && pathBase.Value.EndsWith("/"))
{
pathBase = new PathString(pathBase.Value.Substring(0, pathBase.Value.Length - 1));
}
_pathBase = pathBase;
}

View File

@ -62,11 +62,6 @@ namespace Microsoft.AspNet.TestHost
public HttpMessageHandler CreateHandler()
{
var pathBase = BaseAddress == null ? PathString.Empty : PathString.FromUriComponent(BaseAddress);
if (pathBase.Equals(new PathString("/")))
{
// When we just have http://host/ the trailing slash is really part of the Path, not the PathBase.
pathBase = PathString.Empty;
}
return new ClientHandler(Invoke, pathBase);
}

View File

@ -40,7 +40,7 @@ namespace Microsoft.AspNet.TestHost
Assert.Equal("example.com", context.Request.Host.Value);
return Task.FromResult(0);
}, new PathString("/A/Path"));
}, new PathString("/A/Path/"));
var httpClient = new HttpClient(handler);
return httpClient.GetAsync("https://example.com/A/Path/and/file.txt?and=query");
}