Exemplo n.º 1
0
        private static void HttpTest()
        {
            var httpServer = NetTool.CreateHttpSever();

            httpServer.hOnReceived = new HttpOnReceived((payload) =>
            {
                Log.L(payload.Header.Option);
                Log.L(payload.Header.RelativeUri);

                if (payload.Header.Option == HttpOption.GET)
                {
                    HttpGet get = new HttpGet(payload.Header);
                    var rsp     = get.Response(DateTime.Now.ToString());

                    httpServer.Send(payload.Token, Encoding.UTF8.GetBytes(rsp));
                    httpServer.Disconnect(payload.Token);
                }
            });
            bool isOk = httpServer.Start();

            if (isOk)
            {
                Log.L("listening on:" + httpServer.Port);
            }
        }