12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System.Collections.Generic;
- using WebDAVSharp.Server.Adapters;
- using WebDAVSharp.Server.Stores;
- namespace WebDAVSharp.Server.MethodHandlers
- {
- /// <summary>
- /// This class implements the <c>OPTIONS</c> HTTP method for WebDAV#.
- /// </summary>
- internal class WebDavOptionsMethodHandler : WebDavMethodHandlerBase
- {
- #region Properties
- /// <summary>
- /// Gets the collection of the names of the HTTP methods handled by this instance.
- /// </summary>
- public override IEnumerable<string> Names => new[]
- {
- "OPTIONS"
- };
- #endregion
- #region Functions
- /// <summary>
- /// Processes the request.
- /// </summary>
- /// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
- /// <param name="context">
- /// The
- /// <see cref="IHttpListenerContext" /> object containing both the request and response
- /// objects to use.
- /// </param>
- /// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
- 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<string> VerbsAllowed = new List<string> {"OPTIONS", "TRACE", "GET", "HEAD", "POST", "COPY", "PROPFIND", "LOCK", "UNLOCK"};
- private static readonly List<string> VerbsPublic = new List<string> {"OPTIONS", "GET", "HEAD", "PROPFIND", "PROPPATCH", "MKCOL", "PUT", "DELETE", "COPY", "MOVE", "LOCK", "UNLOCK"};
- #endregion
- }
- }
|