/// <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> /// <exception cref="WebDAVSharp.Server.Exceptions.WebDavUnsupportedMediaTypeException"></exception> /// <exception cref="WebDAVSharp.Server.Exceptions.WebDavMethodNotAllowedException"></exception> /// <param name="response"></param> /// <param name="request"></param> protected override void OnProcessRequest( WebDavServer server, IHttpListenerContext context, IWebDavStore store, XmlDocument request, XmlDocument response) { if (context.Request.ContentLength64 > 0) { throw new WebDavUnsupportedMediaTypeException(); } IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url); string collectionName = context.Request.Url.GetLastSegment(); IWebDavStoreItem item; if ((item = collection.GetItemByName(collectionName)) != null) { WebDavServer.Log.Warning("MKCOL Failed: item {0} already exists as child of {1}. ", collectionName, collection.ItemPath); throw new WebDavMethodNotAllowedException(); } collection.CreateCollection(collectionName); context.SendSimpleResponse((int)HttpStatusCode.Created); }
/// <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> /// <exception cref="WebDAVSharp.Server.Exceptions.WebDavUnsupportedMediaTypeException"></exception> /// <exception cref="WebDAVSharp.Server.Exceptions.WebDavMethodNotAllowedException"></exception> public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store) { if (context.Request.ContentLength64 > 0) { throw new WebDavUnsupportedMediaTypeException(); } IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url); string collectionName = Uri.UnescapeDataString( context.Request.Url.Segments.Last().TrimEnd('/', '\\') ); if (collection.GetItemByName(collectionName) != null) { throw new WebDavMethodNotAllowedException(); } collection.CreateCollection(collectionName); context.SendSimpleResponse(HttpStatusCode.Created); }