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 Setup() { host = new HostServer(14910); host.Initialize(); host.Container.Get <IMvcFactory>().Register(typeof(ApiExecuteAction)); host.Container.Register(host.Container.NewComponent <IApi, Api>(Lifestyle.Pooled)); host.Factory.Register("/apir/execute", new ApiRequestHandler()); host.Start(); Thread.Sleep(100); cli = new HttpClient(); }
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 FixtureSetup() { var hostConfig = new HostConfig(); hostConfig.Bindings.Add(new HostBinding { Port = 50651, Schema = HostSchema.Http, Interface = "127.0.0.1" }); hostConfig.Bindings.Add(new HostBinding { Port = 50652, Schema = HostSchema.Https, Interface = "127.0.0.1" }); host = new HostServer(hostConfig); host.On("/x.html", _html, "text/hmtl"); host.On("/x2.html", _html2, "text/hmtl"); host.Start(); httpend = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 50651); httpsend = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 50652); }
public void Setup() { this.host = new HostServer(14990); host.OnBeforeInitializeServices += c => { c.Register(c.NewComponent<IHostLogon,TestHostLogon>()); }; host.Initialize(); auth = host.Auth as DefaultHostAuthenticationProvider; Assert.NotNull(auth); Assert.NotNull(auth.HostLogonProvider); lp = auth.HostLogonProvider as DefaultHostLogonProvider; ls = auth.LoginSourceProvider as DefaultLoginSourceProvider; ls.Sources = new[] {new TestLoginSource()}; Assert.True(lp.HostLogons.OfType<TestHostLogon>().Any()); //this code is just tests that Auth uses logons from IoC lp.HostLogons = new[] {new TestHostLogon()}; //we require just one logon extension this.cl = new HttpClient(); host.Start(); Thread.Sleep(200); }
public void Setup() { this.host = new HostServer(14990); host.OnBeforeInitializeServices += c => { c.Register(c.NewComponent <IHostLogon, TestHostLogon>()); }; host.Initialize(); auth = host.Auth as DefaultHostAuthenticationProvider; Assert.NotNull(auth); Assert.NotNull(auth.HostLogonProvider); lp = auth.HostLogonProvider as DefaultHostLogonProvider; ls = auth.LoginSourceProvider as DefaultLoginSourceProvider; ls.Sources = new[] { new TestLoginSource() }; Assert.True(lp.HostLogons.OfType <TestHostLogon>().Any()); //this code is just tests that Auth uses logons from IoC lp.HostLogons = new[] { new TestHostLogon() }; //we require just one logon extension this.cl = new HttpClient(); host.Start(); Thread.Sleep(200); }
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 static void Start() { RuntimeTypeModel.Default.Add(typeof(Msg), false).SetSurrogate(typeof(MsgSurrogate)); Application.EnableVisualStyles(); noti_Init(); log = new Log(); host = new HostServer(log); host.OnClient += (even, client_id, msg_id) => { switch (even) { case MsgConnectEvent.MESSAGE_BINARY: //Msg m = msg.Get(msg_id); break; } }; log.OnChange += (system, type, text) => fm_log.ShowLog(system, type, text); ////////////////////////////////////////////// icon_tray = new SystemTray("Host"); fm_noti = new FormNotification(); fm_log = new FormLogger(); //fm_demo = new FormDemo(host); host.Start(); fm_log.Show(); //fm_demo.Show(); log.Write(LogSystem.HOST_SYSTEM, LogType.NONE, string.Format("Host port public: {0}", host.Port)); log.Write(LogSystem.HOST_SYSTEM, LogType.NONE, string.Format("Host port HTTP: {0}", host.PortHTTP)); log.Write(LogSystem.HOST_SYSTEM, LogType.NONE, string.Format("Host port Websocket: {0}", host.PortWebSocket)); Application.Run(icon_tray); }
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 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(); } }
public void FixtureSetUp() { this.srv = new HostServer(8094); srv.Start(); }