当前位置: 首页>>代码示例>>C#>>正文


C# HttpServer.Redirect方法代码示例

本文整理汇总了C#中HttpServer.Redirect方法的典型用法代码示例。如果您正苦于以下问题:C# HttpServer.Redirect方法的具体用法?C# HttpServer.Redirect怎么用?C# HttpServer.Redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpServer的用法示例。


在下文中一共展示了HttpServer.Redirect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            string command = request.UriPath;

            if (command.StartsWith("/threadinfo"))
            {
                string board = request.QueryString["board"].Value;
                string id = request.QueryString["id"].Value;

                if (string.IsNullOrEmpty(board) || string.IsNullOrEmpty(id))
                {
                    response.Redirect("/wjobs"); return true;
                }

                if (Program.active_dumpers.ContainsKey(board))
                {
                    BoardWatcher bw = Program.active_dumpers[board];

                    int tid = 0;

                    Int32.TryParse(id, out tid);

                    if (bw.watched_threads.ContainsKey(tid))
                    {
                        ThreadWorker tw = bw.watched_threads[tid];

                        StringBuilder properties = new StringBuilder();

                        properties.AppendFormat("<span>{0}: </span><code>{1}</code><br/>", "Thread ID", tw.ID);

                        properties.AppendFormat("<span>{0}: </span><code>{1}</code><br/>", "Board", tw.Board.Board);

                        properties.AppendFormat("<span>{0}: </span><code>{1}</code><br/>", "Update Interval (in min)", tw.UpdateInterval);

                        properties.AppendFormat("<span>{0}: </span><code>{1}</code><br/>", "BumpLimit", tw.BumpLimit);

                        properties.AppendFormat("<span>{0}: </span><code>{1}</code><br/>", "ImageLimit", tw.ImageLimit);

                        response.Status = System.Net.HttpStatusCode.OK;
                        response.ContentType = "text/html";

                        byte[] data = Encoding.UTF8.GetBytes
                            (Properties.Resources.threadinfo_page
                            .Replace("{properties}", properties.ToString())
                            .Replace("{Logs}", get_logs(tw.Logs)));

                        response.ContentLength = data.Length;
                        response.SendHeaders();
                        response.SendBody(data);

                        return true;
                    }
                }

                response.Redirect("/wjobs"); return true;
            }

            return false;
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:59,代码来源:ThreadJobInfoPageHandler.cs

示例2: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (request.UriPath.StartsWith(Url))
            {

                string board = request.QueryString[UrlParameters.Board].Value;
                string threadIdStr = request.QueryString[UrlParameters.ThreadId].Value;
                int threadId = -1;
                int.TryParse(threadIdStr, out threadId);

                if (!Program.IsBoardLetterValid(board))
                {
                    ThreadServerModule.write_text("Invalid board letter", response);
                    return true;
                }

                if (threadId <= 0)
                {
                    ThreadServerModule.write_text("Invalid thread id", response);
                    return true;
                }

                string notes = request.QueryString[UrlParameters.ThreadNotesText].Value;

                notes = System.Web.HttpUtility.HtmlDecode(notes);

                ThreadStore.GetStorageEngine().setThreadNotes(board, threadId, notes);

                response.Redirect(ThreadServerModule.GetThreadPageLink(board, threadId));

                return true;
            }
            return false;
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:34,代码来源:ThreadNotesHandler.cs

示例3: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (request.UriPath.StartsWith(Url))
            {
                string value = request.QueryString[UrlParameters.IsEnabled].Value;
                Settings.ThumbnailOnly = value == "true";

                string redirect = request.QueryString[UrlParameters.RedirectUrl].Value;

                if (!string.IsNullOrWhiteSpace(redirect))
                {
                    response.Redirect(redirect);
                }
                else
                {
                    response.Redirect("/");
                }

                return true;
            }

            return false;
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:23,代码来源:ThumbnailOnlySettingsController.cs

示例4: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (request.UriPath.StartsWith(Url))
            {
                string board = request.QueryString[UrlParameters.Board].Value;

                if (!string.IsNullOrWhiteSpace(board))
                {
                    BoardWatcher bw = Program.GetBoardWatcher(board);

                    if (bw != null)
                    {
                        for (int i = 0; i < bw.watched_threads.Count; i++)
                        {
                            try
                            {
                                ThreadWorker tw = bw.watched_threads.ElementAt(i).Value;
                                if (!tw.AddedAutomatically)
                                {
                                    tw.Stop();
                                }
                            }
                            catch (System.IndexOutOfRangeException)
                            {
                                break;
                            }
                            catch { }
                        }
                    }
                }
                response.Redirect(MonitoredBoardsPageHandler.Url);
                return true;
            }

            return false;
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:36,代码来源:StopAllManuallyAddedThreadsHandler.cs

示例5: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            string command = request.UriPath;

            if (command.StartsWith("/fileinfo/"))
            {

                string[] a = command.Split('/');

                if (a.Length >= 3)
                {
                    string filehash = a[2];

                    FileQueueStateInfo fqs = Program.get_file_state(filehash);

                    if (fqs != null)
                    {

                        StringBuilder page = new StringBuilder(Properties.Resources.fileinfo);

                        page.Replace("{fullfilelink}", string.Format("/file/{0}.{1}", fqs.Hash, fqs.Ext));

                        page.Replace("{thumbsource}", string.Format("/thumb/{0}.jpg", fqs.Hash));

                        page.Replace("{url}", fqs.Url);

                        page.Replace("{p}", fqs.Percent().ToString());
                        page.Replace("{md5}", fqs.Hash);

                        page.Replace("{name}", fqs.FileName);

                        page.Replace("{workid}", filehash);

                        page.Replace("{jtype}", fqs.Type.ToString());
                        page.Replace("{rcount}", fqs.RetryCount.ToString());

                        page.Replace("{downloaded}", Program.format_size_string(fqs.Downloaded));
                        page.Replace("{length}", Program.format_size_string(fqs.Length));

                        page.Replace("{Logs}", get_logs(fqs.Logs));

                        response.Status = System.Net.HttpStatusCode.OK;
                        response.ContentType = "text/html";

                        byte[] data = Encoding.UTF8.GetBytes(page.ToString());
                        response.ContentLength = data.Length;
                        response.SendHeaders();
                        response.SendBody(data);

                        return true;

                    }
                    else
                    {
                        response.Redirect("/fq");
                        return true;
                    }

                }
            }

            return false;
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:63,代码来源:FileInfoPageHandler.cs

示例6: Process


//.........这里部分代码省略.........
                        break;
                    default:
                        break;
                }
                 */

                if (Settings.AutoRemoveCompleteFiles)
                {
                    page.Replace("{fq3c}", Checked);
                }
                else
                {
                    page.Replace("{fq3c}", "");
                }

                response.Status = System.Net.HttpStatusCode.OK;
                response.ContentType = "text/html";
                byte[] data = Encoding.UTF8.GetBytes(page.ToString());
                response.ContentLength = data.Length;
                response.SendHeaders();
                response.SendBody(data);

                return true;
            }

            if (command.StartsWith("/settings/"))
            {
                // -------------- General Settings ------------
                Settings.AutoStartManuallyAddedThreads = request.QueryString["gs0"].Value == "1";
                Settings.ThumbnailOnly = request.QueryString["gs1"].Value == "1";
                Settings.EnableFileStats = request.QueryString["gs2"].Value == "1";
                Settings.UseHttps = request.QueryString["gs3"].Value == "1";
                Settings.RemoveThreadsWhenTheyEnterArchivedState = request.QueryString["gs4"].Value == "1";
                Settings.SaveBannedFileThumbnail = request.QueryString["gs5"].Value == "1";
                Settings.CacheAPIFilesInMemory = request.QueryString["gs6"].Value == "1";

                if (Settings.EnableFileStats) { FileSystemStats.Init(); }

                // -------------- Security Settings ------------
                Settings.EnableAuthentication = request.QueryString["ss0"].Value == "1";
                Settings.AllowGuestAccess = request.QueryString["ss1"].Value == "1";
                Settings.AuthUsername = request.QueryString["ba_user"].Value;
                Settings.AuthPassword = request.QueryString["ba_pass"].Value;

                // -------------- FFMPEG Settings ------------

                Settings.ConvertGifsToWebm = request.QueryString["ff0"].Value == "1";

                Settings.ConvertWebmToMp4 = request.QueryString["ff1"].Value == "1";
                Settings.Convert_Webmgif_To_Target = request.QueryString["ff2"].Value == "1";

                if (request.QueryString["ff2s1"].Value == "gif")
                {
                    Settings.Convert_Webmgif_Target = Settings.X_Target.GIF;
                }
                else
                {
                    Settings.Convert_Webmgif_Target = Settings.X_Target.MP4;
                }

                Settings.Convert_Webmgif_only_devices = request.QueryString["ff2s2"].Value == "ff2s2o1";

                // -------------- File Queue Settings ------------

                Settings.ListThumbsInQueue = request.QueryString["fq0"].Value == "1";
                /*
                Settings.PrioritizeBumpLimit = request.QueryString["fq1"].Value == "1";

                switch (request.QueryString["fq2s1"].Value)
                {
                    case "fq2s1o1":
                        Settings.FilePrioritizeMode = Settings.FilePrioritizeModeEnum.SmallerFirst;
                        break;
                    case "fq2s1o2":
                        Settings.FilePrioritizeMode = Settings.FilePrioritizeModeEnum.LargerFirst;
                        break;
                    case "fq2s1o3":
                        Settings.FilePrioritizeMode = Settings.FilePrioritizeModeEnum.BoardSpeed;
                        break;
                    default:
                        Settings.FilePrioritizeMode = Settings.FilePrioritizeModeEnum.SmallerFirst;
                        break;
                }*/

                Settings.AutoRemoveCompleteFiles = request.QueryString["fq3"].Value == "1";

                Settings.Save();

                if (!Settings.EnableAuthentication)
                {
                    session.Clear();
                    response.Cookies.Clear();
                }

                response.Redirect("/settings");
                return true;
            }

            return false;
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:101,代码来源:SettingsPageHandler.cs

示例7: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (request.UriPath == Url)//|| request.UriPath == (Url + "/"))
            {
                StringBuilder sb = new StringBuilder(HtmlTemplates.ThreadFiltersPageTemplate);

                IncludeCommonHtml(sb);

                sb.Replace("{{boards-list-html}}", ThreadServerModule.get_board_list(UrlParameters.Board));
                sb.Replace("{{available-filters-list}}", get_available_filters());
                sb.Replace("{{filters-list}}", GetThreadFiltersTableHtml());

                WriteFinalHtmlResponse(response, sb.ToString());

                return true;
            }

            if (request.UriPath.StartsWith("/filters/"))
            {
                string mode = request.QueryString["mode"].Value;
                string board = request.QueryString[UrlParameters.Board].Value;

                BoardWatcher bw;

                switch (mode)
                {
                    case "add":
                        {
                            if (Program.active_dumpers.ContainsKey(board))
                            {
                                bw = Program.active_dumpers[board];
                            }
                            else
                            {
                                bw = new BoardWatcher(board);
                                Program.active_dumpers.Add(board, bw);
                            }

                            string filter_type = request.QueryString["type"].Value;
                            string filter_exp = request.QueryString["exp"].Value;

                            if (string.IsNullOrEmpty(filter_exp) || string.IsNullOrEmpty(filter_type))
                            {
                                return false;
                            }
                            else
                            {
                                ChanArchiver.Filters.IFilter f = get_filter(filter_type, filter_exp);
                                if (f != null)
                                {
                                    bw.AddFilter(f);
                                    bw.SaveFilters();
                                    response.Redirect("/filters");
                                    return true;
                                }
                                else
                                {
                                    return false;
                                }
                            }
                        }
                    case "edit":
                        return false;
                    case "delete":
                        {
                            if (Program.active_dumpers.ContainsKey(board))
                            {
                                string index = request.QueryString["i"].Value;

                                bw = Program.active_dumpers[board];

                                int inde = -1;
                                Int32.TryParse(index, out inde);

                                if (inde >= 0 && inde <= bw.Filters.Length - 1)
                                {
                                    bw.RemoveFilter(inde);
                                    bw.SaveFilters();
                                    response.Redirect(ThreadFiltersPageHandler.Url);
                                    return true;
                                }
                                else { return false; }
                            }
                            else { return false; }
                        }
                    case "editnotes":
                        {
                            string fID = request.QueryString["filterindex"].Value;
                            string notes_text = request.QueryString["notestext"].Value;

                            if (string.IsNullOrEmpty(fID) || string.IsNullOrEmpty(board))
                            {
                                response.Redirect(ThreadFiltersPageHandler.Url);
                                return true;
                            }
                            else
                            {
                                if (Program.active_dumpers.ContainsKey(board))
                                {
                                    bw = Program.active_dumpers[board];
//.........这里部分代码省略.........
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:101,代码来源:ThreadFiltersPageHandler.cs

示例8: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            string command = request.UriPath.ToString();

            #region Thread & Index View

            if (command.StartsWith("/boards/"))
            {
                response.Encoding = System.Text.Encoding.UTF8;

                string[] parame = command.Split('?')[0].Split('/');

                if (parame.Length == 3)
                {
                    //board index view mode
                    string board = parame[2]; if (string.IsNullOrEmpty(board))
                    {
                        response.Redirect("/boards");
                        return true;
                    }

                    ThreadStore.GetStorageEngine().UpdateThreadStoreStats();

                    int board_thread_count = ThreadStore.GetStorageEngine().StoreStats[board];

                    if (board_thread_count == 0)
                    {
                        response.Redirect("/boards");
                        return true;
                    }

                    int rem = (board_thread_count % ThreadPerPage);

                    int page_count = ((board_thread_count - rem) / ThreadPerPage) + (rem > 0 ? 1 : 0);

                    if (page_count <= 0) { page_count = 1; }

                    int page_offset = 0;

                    Int32.TryParse(request.QueryString["pn"].Value, out page_offset); page_offset = Math.Abs(page_offset);

                    int start = page_offset * (ThreadPerPage);

                    PostFormatter[] board_index = ThreadStore.GetStorageEngine().GetIndex(board, start, ThreadPerPage);

                    StringBuilder s = new StringBuilder();

                    foreach (var pf in board_index)
                    {
                        s.Append("<div class='row'>");
                        s.Append
                            (
                                   pf.ToString()
                                  .Replace("{post:link}", string.Format("/boards/{0}/{1}", board, pf.PostID))
                            );
                        s.Append("</div>");
                    }

                    StringBuilder page_numbers = new StringBuilder();

                    for (int i = 0; i < page_count; i++)
                    {
                        if (i == page_offset)
                        {
                            page_numbers.AppendFormat("<li class=\"active\"><a href=\"?pn={0}\">{1}</a></li>", i, i + 1);
                        }
                        else
                        {
                            page_numbers.AppendFormat("<li><a href=\"?pn={0}\">{1}</a></li>", i, i + 1);
                        }
                    }

                    byte[] data = Encoding.UTF8.GetBytes(
                        Properties.Resources.board_index_page
                        .Replace("{po}", Convert.ToString(page_offset == 0 ? 0 : page_offset - 1))
                        .Replace("{no}", Convert.ToString(page_offset == page_count - 1 ? page_count : page_offset + 1))
                        .Replace("{pagen}", page_numbers.ToString())
                        .Replace("{Items}", s.ToString()));

                    response.ContentType = ServerConstants.HtmlContentType;
                    response.Encoding = Encoding.UTF8;
                    response.Status = System.Net.HttpStatusCode.OK;
                    response.ContentLength = data.Length;
                    response.SendHeaders();
                    response.SendBody(data);

                    return true;
                }
                else if (parame.Length >= 4)
                {
                    //thread view mode
                    string board = parame[2];
                    string threadid = parame[3];

                    int parsedThreadId = -1;
                    int.TryParse(threadid, out parsedThreadId);

                    if (string.IsNullOrEmpty(board) || string.IsNullOrEmpty(threadid)) { _404(response); return true; }
                    if (parsedThreadId <= 0) { _404(response); return true; }

//.........这里部分代码省略.........
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:101,代码来源:ThreadServerModule.cs


注:本文中的HttpServer.Redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。