示例#1
0
        private void ConnectionThreadStart()
        {
            try
            {
                while (this._running)
                {
                    HttpListenerContext context = _httpListener.GetContext();

                    string body = string.Empty;
                    if (context.Request.HasEntityBody)
                    {
                        MemoryStream ms = new MemoryStream();
                        context.Request.InputStream.CopyTo(ms);
                        byte[] data = ms.ToArray();

                        body = Ionic.Zlib.ZlibStream.UncompressString(data);
                    }

                    RequestData requestData = new RequestData()
                    {
                        Context = context,
                        Client  = Server.GetClient(context.Request.Cookies["PHPSESSID"]?.Value.ToLower()),
                        Body    = body
                    };
                    _resourceLocator.HandleContext(requestData);
                }
            }
            catch (HttpListenerException)
            {
                Console.WriteLine("HTTP server was shut down.");
            }
        }