Exemplo n.º 1
0
        private OwinHttpListener CreateServer(AppFunc app, string[] addressParts)
        {
            var wrapper = new OwinHttpListener();

            wrapper.Start(wrapper.Listener, app, CreateAddress(addressParts), null, null);
            return(wrapper);
        }
Exemplo n.º 2
0
        public async Task PathAndPathBase_CorrectlySeperated(string clientString, string serverBasePath,
                                                             string expectedBasePath, string expectedPath, string expectedQuery)
        {
            var fallbackAddress = new string[4];

            HttpServerAddress.CopyTo(fallbackAddress, 0);
            fallbackAddress[3] = "/";
            var serverAddress = new string[4];

            HttpServerAddress.CopyTo(serverAddress, 0);
            serverAddress[3] = serverBasePath;
            clientString     = "http://localhost:8080" + clientString;

            using (var wrapper = new OwinHttpListener())
            {
                wrapper.Start(wrapper.Listener, env =>
                {
                    Assert.Equal(expectedBasePath, (string)env["owin.RequestPathBase"]);
                    Assert.Equal(expectedPath, (string)env["owin.RequestPath"]);
                    Assert.Equal(expectedQuery, (string)env["owin.RequestQueryString"]);
                    return(TaskHelpers.Completed());
                }, CreateAddresses(fallbackAddress, serverAddress), null, null);

                using (var client = new HttpClient())
                {
                    HttpResponseMessage result = await client.GetAsync(clientString);

                    Assert.Equal(HttpStatusCode.OK, result.StatusCode);
                }
            }
        }
 private OwinHttpListener CreateServer(Func<IDictionary<string, object>, Task> app, string[] addressParts)
 {
     var wrapper = new OwinHttpListener();
     wrapper.Start(wrapper.Listener, app, CreateAddress(addressParts), null);
     return wrapper;
 }
Exemplo n.º 4
0
 private OwinHttpListener CreateServer(AppFunc app, string[] addressParts)
 {
     var wrapper = new OwinHttpListener();
     wrapper.Start(wrapper.Listener, app, CreateAddress(addressParts), null, null);
     return wrapper;
 }
        public async Task PathAndPathBase_CorrectlySeperated(string clientString, string serverBasePath,
            string expectedBasePath, string expectedPath, string expectedQuery)
        {
            var fallbackAddress = new string[4];
            HttpServerAddress.CopyTo(fallbackAddress, 0);
            fallbackAddress[3] = "/";
            var serverAddress = new string[4];
            HttpServerAddress.CopyTo(serverAddress, 0);
            serverAddress[3] = serverBasePath;
            clientString = "http://localhost:8080" + clientString;

            using (var wrapper = new OwinHttpListener())
            {
                wrapper.Start(wrapper.Listener, env =>
                {
                    Assert.Equal(expectedBasePath, (string)env["owin.RequestPathBase"]);
                    Assert.Equal(expectedPath, (string)env["owin.RequestPath"]);
                    Assert.Equal(expectedQuery, (string)env["owin.RequestQueryString"]);
                    return TaskHelpers.Completed();
                }, CreateAddresses(fallbackAddress, serverAddress), null);

                using (var client = new HttpClient())
                {
                    HttpResponseMessage result = await client.GetAsync(clientString);
                    Assert.Equal(HttpStatusCode.OK, result.StatusCode);
                }
            }
        }