/* * Copyright (c) 2023 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials * File: FileProcessArgs.cs * * FileProcessArgs.cs is part of VNLib.Plugins.Essentials which is part of the larger * VNLib collection of libraries and utilities. * * VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * VNLib.Plugins.Essentials is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ using System; using System.Net; #nullable enable namespace VNLib.Plugins.Essentials { /// /// Server routine to follow after processing selector /// public enum FpRoutine { /// /// There was an error during processing and the server should immediatly respond with a error code /// Error, /// /// The server should continue the file read operation with the current information /// Continue, /// /// The server should redirect the conneciton to an alternate location /// Redirect, /// /// The server should immediatly respond with a error code /// Deny, /// /// The server should fulfill the reqeest by sending the contents of an alternate file location (if it exists) with the existing connection /// ServeOther, /// /// The server should immediatly respond with a error code /// NotFound, /// /// Serves another file location that must be a trusted fully qualified location /// ServeOtherFQ, /// /// The connection does not require a file to be processed /// VirtualSkip, } /// /// Specifies operations the file processor will follow during request handling /// /// /// The routine the file processor should execute /// /// /// An optional alternate path for the given routine /// public readonly record struct FileProcessArgs(FpRoutine Routine, string Alternate) { /// /// Signals the file processor should complete with a routine /// public static readonly FileProcessArgs Deny = new (FpRoutine.Deny); /// /// Signals the file processor should continue with intended/normal processing of the request /// public static readonly FileProcessArgs Continue = new (FpRoutine.Continue); /// /// Signals the file processor should complete with a routine /// public static readonly FileProcessArgs Error = new (FpRoutine.Error); /// /// Signals the file processor should complete with a routine /// public static readonly FileProcessArgs NotFound = new (FpRoutine.NotFound); /// /// Signals the file processor should not process the connection /// public static readonly FileProcessArgs VirtualSkip = new (FpRoutine.VirtualSkip); /// /// Initializes a new with the specified routine /// and empty path /// /// The file processing routine to execute public FileProcessArgs(FpRoutine routine):this(routine, string.Empty) { } } }