public void Delegate() { srv.OnContext("/echo", _ => _.Finish(_.Uri.Query.Substring(1)) ); var wcl = new WebClient(); var str = wcl.DownloadString("http://127.0.0.1:8094/echo?x"); Assert.AreEqual("x", str); }
public void CanProxisePost() { var aconfig1 = new HostConfig(); aconfig1.AddQorpentBinding(98); var aconfig2 = new HostConfig(); aconfig2.AddQorpentBinding(99); aconfig2.Proxize["/call1"] = "appid=98"; var h1 = new HostServer(aconfig1); var h2 = new HostServer(aconfig2); h1.OnContext("/call1", _ => { if (_.Method == "POST") { _.Finish(new StreamReader(_.Request.Stream).ReadToEnd()); } else { _.Finish("hello!"); } }); var result = ""; var resultDirect = ""; try { h1.Start(); h2.Start(); Thread.Sleep(1000); resultDirect = new HttpClient().GetString("http://127.0.0.1:14980/call1", "hello2"); result = new HttpClient().GetString("http://127.0.0.1:14990/call1", "hello2"); } finally { h1.Stop(); h2.Stop(); } Console.WriteLine(result); Assert.AreEqual("hello2", resultDirect); Assert.AreEqual("hello2", result); }