public void Test_MultipleConnections() { HttpListener listener = HttpListener2Test.CreateAndStartListener("http://127.0.0.1:9000/multiple/"); // First one NetworkStream ns = HttpListener2Test.CreateNS(9000); HttpListener2Test.Send(ns, "POST /multiple/ HTTP/1.0\r\nHost: 127.0.0.1\r\nContent-Length: 3\r\n\r\n123"); HttpListenerContext ctx = listener.GetContext(); HttpListener2Test.Send(ctx.Response.OutputStream, "%%%OK%%%"); ctx.Response.OutputStream.Close(); string response = HttpListener2Test.Receive(ns, 1024); ns.Close(); // Second one ns = HttpListener2Test.CreateNS(9000); HttpListener2Test.Send(ns, "POST /multiple/ HTTP/1.0\r\nHost: 127.0.0.1\r\nContent-Length: 3\r\n\r\n123"); ctx = listener.GetContext(); HttpListener2Test.Send(ctx.Response.OutputStream, "%%%OK%%%"); ctx.Response.OutputStream.Close(); response = HttpListener2Test.Receive(ns, 1024); ns.Close(); listener.Close(); }
public void HttpBasicAuthScheme() { HttpListener listener = HttpListener2Test.CreateAndStartListener("http://*:9000/authTest/", AuthenticationSchemes.Basic); //dummy-wait for context listener.BeginGetContext(null, listener); NetworkStream ns = HttpListener2Test.CreateNS(9000); HttpListener2Test.Send(ns, "GET /authTest/ HTTP/1.0\r\n\r\n"); String response = HttpListener2Test.Receive(ns, 512); Assert.IsTrue(response.Contains("WWW-Authenticate: Basic realm"), "#A"); ns.Close(); listener.Close(); }