using System.Collections.Generic; using WebDAVSharp.Server.Adapters; using WebDAVSharp.Server.Stores; namespace WebDAVSharp.Server.MethodHandlers { /// /// This class implements the OPTIONS HTTP method for WebDAV#. /// internal class WebDavOptionsMethodHandler : WebDavMethodHandlerBase { #region Properties /// /// Gets the collection of the names of the HTTP methods handled by this instance. /// public override IEnumerable Names => new[] { "OPTIONS" }; #endregion #region Functions /// /// Processes the request. /// /// The through which the request came in from the client. /// /// The /// object containing both the request and response /// objects to use. /// /// The that the is hosting. public override void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store) { foreach (string verb in VerbsAllowed) context.Response.AppendHeader("Allow", verb); foreach (string verb in VerbsPublic) context.Response.AppendHeader("Public", verb); // Sends 200 OK context.SendSimpleResponse(); } #endregion #region Variables private static readonly List VerbsAllowed = new List {"OPTIONS", "TRACE", "GET", "HEAD", "POST", "COPY", "PROPFIND", "LOCK", "UNLOCK"}; private static readonly List VerbsPublic = new List {"OPTIONS", "GET", "HEAD", "PROPFIND", "PROPPATCH", "MKCOL", "PUT", "DELETE", "COPY", "MOVE", "LOCK", "UNLOCK"}; #endregion } }