public void CanUseCacheOnResolutionIntegration() { var xml = BSharpCompiler.Compile(ProductionCode)["tiles"].Compiled; var conf = new HostConfig(xml); var qh = new HostServer(conf); qh.Start(); try { var response = new HttpClient().Call("http://127.0.0.1:14990/map/8/173/76.png"); Assert.AreEqual(200, response.State); Assert.AreEqual("image/png; charset=utf-8", response.ContentType); var png = (Bitmap)Image.FromStream(new MemoryStream(response.Data)); Assert.AreEqual(ImageFormat.Png, png.RawFormat); var pixel = png.GetPixel(70, 40); Assert.AreEqual(174, pixel.R); Assert.AreEqual(209, pixel.G); Assert.AreEqual(160, pixel.B); response = new HttpClient().Call("http://127.0.0.1:14990/map/6/11/26.png"); Assert.AreEqual(200, response.State); Assert.AreEqual("image/png; charset=utf-8", response.ContentType); png = (Bitmap)Image.FromStream(new MemoryStream(response.Data)); Assert.AreEqual(ImageFormat.Png, png.RawFormat); pixel = png.GetPixel(54, 18); Assert.AreEqual(181, pixel.R); Assert.AreEqual(171, pixel.G); Assert.AreEqual(201, pixel.B); } finally { qh.Stop(); } }
public void CanProxiseByAppid() { 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.On("/call1", "hello!"); var result = ""; try { h1.Start(); h2.Start(); Thread.Sleep(100); result = new HttpClient().GetString("http://127.0.0.1:14990/call1"); } finally { h1.Stop(); h2.Stop(); } Assert.AreEqual("hello!", result); }
private static int Execute(ServerParameters arg) { var config = arg.BuildServerConfig(); EnsureRequiredApplications(arg,config); config.DllFolder = EnvironmentInfo.ResolvePath("@repos@/.build/bin/all"); var command = arg.Get("command", ""); if (string.IsNullOrWhiteSpace(command)) { Console.WriteLine("LOGLEVEL " + config.LogLevel); } var hostServer = new HostServer(config); hostServer.Initialize(); var consoleContext = new ConsoleContext { Container = hostServer.Container, Parameters = arg }; var listener = new ConsoleListener(consoleContext); if (!string.IsNullOrWhiteSpace(command)) { var task = listener.Call(command); task.Wait(); } else { LogHostInfo(arg, config); hostServer.Start(); Console.WriteLine("LOGLEVEL " + config.LogLevel); listener.Log = hostServer.Container.Get<ILoggyManager>().Get("console"); listener.Run(); hostServer.Stop(); } return 0; }
public void ZeroDataHttpClientFail_BUG_Q540() { var h = new HostServer(8091); h.Factory.Register("/test", new zero_data()); try { h.Start(); Assert.AreEqual("", new HttpClient().GetString("http://127.0.0.1:8091/test")); } finally { h.Stop(); } }
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); }
public void HttpCacheTest() { var conf = new HostConfig(); conf.AddQorpentBinding(99); conf.StaticContentMap["/files/"] = new StaticFolderDescriptor { Path = web }; var qh = new HostServer(conf); qh.Start(); try { Thread.Sleep(200); Assert.AreEqual("41", new HttpClient().GetString("http://127.0.0.1:14990/files/a.txt")); cache.Sources.Add(new FileCacheSource("http://127.0.0.1:14990/files/")); CheckFile("b/e/j.txt", 48); Assert.Null(cache.Resolve("b/e/k.txt")); //check that 404 doesn't cause error } finally { qh.Stop(); } }
public void Head_Method_Support_BUG_Q541() { var h = new HostServer(8091); h.Factory.Register("/test", new no_zero_data()); try { h.Start(); var req = new HttpRequest { Uri = new Uri("http://127.0.0.1:8091/test"), Method = "GET" }; Assert.AreEqual("It's not zero", new HttpClient().Call(req).StringData); req.Method = "HEAD"; Assert.AreEqual("", new HttpClient().Call(req).StringData); } finally { h.Stop(); } }
private static int Execute(ServerParameters arg) { var config = arg.BuildServerConfig(); EnsureRequiredApplications(arg, config); config.DllFolder = EnvironmentInfo.ResolvePath("@repos@/.build/bin/all"); var command = arg.Get("command", ""); if (string.IsNullOrWhiteSpace(command)) { Console.WriteLine("LOGLEVEL " + config.LogLevel); } var hostServer = new HostServer(config); hostServer.Initialize(); var consoleContext = new ConsoleContext { Container = hostServer.Container, Parameters = arg }; var listener = new ConsoleListener(consoleContext); if (!string.IsNullOrWhiteSpace(command)) { var task = listener.Call(command); task.Wait(); } else { LogHostInfo(arg, config); hostServer.Start(); Console.WriteLine("LOGLEVEL " + config.LogLevel); listener.Log = hostServer.Container.Get <ILoggyManager>().Get("console"); listener.Run(); hostServer.Stop(); } return(0); }
public void FixtureTearDown() { host.Stop(); }
public void TearDown() { host.Stop(); }