示例#1
0
        public void HandleGet(HttpListenerRequest request, HttpListenerResponse response)
        {
            string queryString = request.Url.Query;
            var queryParts = Server.ParseQueryString(queryString);

            string presetName = queryParts.GetFirstValue("preset");

            if (string.IsNullOrEmpty(presetName))
            {
                response.StatusCode = 200;
                response.WriteResponse(presets.GetAll());
            }
            else
            {
                string result = presets.Get(presetName);
                if (result == null)
                {
                    response.StatusCode = 404;
                    response.WriteResponse("No such preset has been registered");
                }
                else
                {
                    response.StatusCode = 200;
                    response.WriteResponse(result);
                }
            }
        }
示例#2
0
        public void HandleGet(HttpListenerRequest request, HttpListenerResponse response)
        {
            try
            {
                string path = request.Url.AbsolutePath;
                if (path.Length < 9)
                {
                    response.StatusCode = 404;
                    response.WriteResponse("Thumbnail not found");
                    return;
                }
                string file = path.Substring(8);
                if (string.IsNullOrEmpty(file))
                {
                    response.StatusCode = 404;
                    response.WriteResponse("Thumbnail not found");
                    return;
                }
                // Ensure format matches thumbnail-identifier_x.jpg
                var match = Regex.Match(file, "^thumbnail-([a-zA-Z0-9_-]+)_[0-9]+\\.jpg$");
                if (!match.Success)
                {
                    response.StatusCode = 404;
                    response.WriteResponse("Thumbnail not found");
                    return;
                }
                var jobID = match.Groups[1].Value;
                string filePath = FFRest.config["workingdir"] + Path.DirectorySeparatorChar + jobID + Path.DirectorySeparatorChar + file;
                if (!File.Exists(filePath))
                {
                    response.StatusCode = 404;
                    response.WriteResponse("Thumbnail not found");
                    return;
                }
                response.StatusCode = 200;

                FileInfo fi = new FileInfo(filePath);
                response.ContentLength64 = fi.Length;
                response.ContentType = Utility.GetMime(fi.Extension);
                using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    Utility.CopyStream(fs, response.OutputStream);
                }
                response.OutputStream.Flush();
                response.OutputStream.Close();
            }
            catch (Exception ex)
            {
                log.Error("Failed to process thumb request", ex);
            }
        }
示例#3
0
        public void HandlePost(HttpListenerRequest request, HttpListenerResponse response, Server.RequestData data)
        {
            var presetName = data.PostParameters.GetFirstValue("preset");
            var value = data.PostParameters.GetFirstValue("value");

            if (string.IsNullOrEmpty(presetName))
            {
                response.StatusCode = 400;
                response.WriteResponse("Missing preset name");
                return;
            }
            if (string.IsNullOrEmpty(value))
            {
                response.StatusCode = 400;
                response.WriteResponse("Missing preset value");
                return;
            }

            // TODO do we need to do filtering on this value?
            presets.Add(presetName, value);
            response.WriteResponse(200, "Preset added");
        }
示例#4
0
文件: Stats.cs 项目: cchamplin/FFRest
 public void HandleGet(HttpListenerRequest request, HttpListenerResponse response)
 {
     try
     {
         StringBuilder bld = new StringBuilder();
         bld.Append("Total Jobs: " + totalJobs + "\n");
         bld.Append("Total Files Transcoded: " + totalFilesTranscoded + "\n");
         bld.Append("Active: " + runningJobs + "\n");
         response.StatusCode = 200;
         response.WriteResponse(bld.ToString());
     }
     catch (Exception ex)
     {
         log.Error("Stats Request Exception Occured", ex);
     }
        // return new Httpd.HttpResponse(200,bld.ToString());
 }
示例#5
0
文件: Stats.cs 项目: cchamplin/FFRest
 public void HandlePost(HttpListenerRequest request, HttpListenerResponse response, Server.RequestData data)
 {
     response.StatusCode = 400;
     response.WriteResponse("Bad Request");
     //return new Httpd.HttpResponse(400, "Bad Request");
 }
示例#6
0
 public void HandlePost(HttpListenerRequest request, HttpListenerResponse response, Server.RequestData data)
 {
     response.StatusCode = 404;
     response.WriteResponse("404 Page Not Found");
 }
示例#7
0
 public void HandleGet(HttpListenerRequest request, HttpListenerResponse response)
 {
     response.StatusCode = 404;
     response.WriteResponse("404 Page Not Found");
 }