Generalize BasePath logic.
This commit is contained in:
parent
4ad0f41eea
commit
4333003df0
|
|
@ -38,6 +38,12 @@ namespace Microsoft.AspNet.TestHost
|
||||||
}
|
}
|
||||||
|
|
||||||
_next = next;
|
_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;
|
_pathBase = pathBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,11 +62,6 @@ namespace Microsoft.AspNet.TestHost
|
||||||
public HttpMessageHandler CreateHandler()
|
public HttpMessageHandler CreateHandler()
|
||||||
{
|
{
|
||||||
var pathBase = BaseAddress == null ? PathString.Empty : PathString.FromUriComponent(BaseAddress);
|
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);
|
return new ClientHandler(Invoke, pathBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.TestHost
|
||||||
Assert.Equal("example.com", context.Request.Host.Value);
|
Assert.Equal("example.com", context.Request.Host.Value);
|
||||||
|
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}, new PathString("/A/Path"));
|
}, new PathString("/A/Path/"));
|
||||||
var httpClient = new HttpClient(handler);
|
var httpClient = new HttpClient(handler);
|
||||||
return httpClient.GetAsync("https://example.com/A/Path/and/file.txt?and=query");
|
return httpClient.GetAsync("https://example.com/A/Path/and/file.txt?and=query");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue