Beispiel #1
0
        public override void handleGETRequest(HttpProcessor p)
        {
            try
            {
                string requestedPage = p.request_url.AbsolutePath.TrimStart('/');

                if (requestedPage == "image")
                {
                    byte[] imgData = imageManager.GetImageAuto(p);
                    Console.WriteLine("Sending image at " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
                    p.writeSuccess("image/jpeg", imgData.Length);
                    p.outputStream.Flush();
                    p.rawOutputStream.Write(imgData, 0, imgData.Length);
                    p.rawOutputStream.Flush();
                }
                else if (requestedPage == "")
                {
                    p.writeSuccess();
                    p.outputStream.Write(ImageRefreshPage.GetHtml(p));
                }
                else if (requestedPage == "jQuery.js")
                {
                    p.writeSuccess();
                    p.outputStream.Write(Javascript.JQuery());
                }
                else if (requestedPage == "photoframe.js")
                {
                    p.writeSuccess();
                    p.outputStream.Write(Javascript.PhotoFrame());
                }
            }
            catch (Exception ex)
            {
                if (!p.isOrdinaryDisconnectException(ex))
                {
                    Logger.Debug(ex);
                }
            }
        }