public void Should_support_site_root_without_trailing_slash() { // Given var uri = new Uri("http://host/"); // When string result = uri.MakeAppLocalPath(new Uri("http://host")); // Then result.ShouldEqual("/"); }
public void Should_support_extended_site_root() { // Given var uri = new Uri("http://host/"); // When string result = uri.MakeAppLocalPath(new Uri("http://host/rel/file")); // Then result.ShouldEqual("/rel/file"); }
public void Should_return_path_with_same_casing_as_full_uri() { // Given var uri = new Uri("http://host/base/"); // When string result = uri.MakeAppLocalPath(new Uri("http://host/base/ReL")); // Then result.ShouldEqual("/ReL"); }
public void Should_return_root_path_without_trailing_slash_as_slash() { // Given var uri = new Uri("http://host/base/"); // When string result = uri.MakeAppLocalPath(new Uri("http://host/base")); // Then result.ShouldEqual("/"); }
public void Should_return_path_as_local_path() { // Given var uri = new Uri("http://host/base/"); // When string result = uri.MakeAppLocalPath(new Uri("http://host/base/rel")); // Then result.ShouldEqual("/rel"); }
private Request ConvertRequest(Uri baseUri, HttpListenerRequest httpRequest) { var expectedRequestLength = GetExpectedRequestLength(ConvertToDictionary(httpRequest.Headers)); var url = new Url { Scheme = httpRequest.Url.Scheme, HostName = httpRequest.Url.Host, Port = httpRequest.Url.IsDefaultPort ? null : (int?)httpRequest.Url.Port, BasePath = baseUri.AbsolutePath.TrimEnd('/'), Path = baseUri.MakeAppLocalPath(httpRequest.Url), Query = httpRequest.Url.Query, }; var fieldCount = httpRequest.ProtocolVersion.Major == 2 ? 1 : 2; var protocolVersion = string.Format("HTTP/{0}", httpRequest.ProtocolVersion.ToString(fieldCount)); byte[] certificate = null; if (httpRequest.IsSecureConnection) { var x509Certificate = httpRequest.GetClientCertificate(); if (x509Certificate != null) { certificate = x509Certificate.RawData; } } return new Request( httpRequest.HttpMethod, url, RequestStream.FromStream(httpRequest.InputStream, expectedRequestLength, false), ConvertToDictionary(httpRequest.Headers), (httpRequest.RemoteEndPoint != null) ? httpRequest.RemoteEndPoint.Address.ToString() : null, protocolVersion, certificate); }
public void Should_return_path_with_case_insensitive_base_uri_comparison() { // Given var uri = new Uri("http://host/base/"); // When string result = uri.MakeAppLocalPath(new Uri("http://host/Base/rel")); // Then result.ShouldEqual("/rel"); }