using System.Collections.Generic; using System.Net; using System.Web; using WebDAVSharp.Server.Adapters; using WebDAVSharp.Server.Exceptions; using WebDAVSharp.Server.Stores; namespace WebDAVSharp.Server.MethodHandlers { /// /// This class implements the PROPFIND HTTP method for WebDAV#. /// internal class WebDavHeadMethodHandler : WebDavMethodHandlerBase { #region Properties /// /// Gets the collection of the names of the HTTP methods handled by this instance. /// /// /// The names. /// public override IEnumerable Names => new[] { "HEAD" }; #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. /// /// /// specifies a request for a store item that does not exist. /// /// - or - /// /// specifies a request for a store item that is not a document. /// /// /// /// specifies a request for a store item using a /// collection path that does not exist. /// public override void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store) { // Get the parent collection of the item IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url); // Get the item from the collection IWebDavStoreItem item = GetItemFromCollection(collection, context.Request.Url); /*************************************************************************************************** * Send the response ***************************************************************************************************/ // HttpStatusCode doesn't contain WebDav status codes, but HttpWorkerRequest can handle these WebDav status codes context.Response.StatusCode = (int) HttpStatusCode.OK; context.Response.StatusDescription = HttpWorkerRequest.GetStatusDescription((int) HttpStatusCode.OK); // set the headers of the response context.Response.ContentLength64 = 0; context.Response.AppendHeader("Content-Type", "text/html"); context.Response.AppendHeader("Last-Modified", item.ModificationDate.ToUniversalTime().ToString("R")); context.Response.Close(); } #endregion } }