/// <summary> /// Initializes new instance of this class based on the WebDAV Engine configuration options and logger instance. /// </summary> /// <param name="config">WebDAV Engine configuration.</param> /// <param name="logger">Logger instance.</param> /// <param name="env">IWebHostEnvironment instance.</param> public DavEngineCore(IOptions <DavEngineConfig> config, ILogger logger, IWebHostEnvironment env) : base() { DavEngineConfig engineConfig = config.Value; OutputXmlFormatting = engineConfig.OutputXmlFormatting; UseFullUris = engineConfig.UseFullUris; CorsAllowedFor = engineConfig.CorsAllowedFor; License = engineConfig.License; Logger = logger; // Set custom handler to process GET and HEAD requests to folders and display // info about how to connect to server. We are using the same custom handler // class (but different instances) here to process both GET and HEAD because // these requests are very similar. // Note that some WebDAV clients may fail to connect if HEAD request is not processed. MyCustomGetHandler handlerGet = new MyCustomGetHandler(env.ContentRootPath); MyCustomGetHandler handlerHead = new MyCustomGetHandler(env.ContentRootPath); handlerGet.OriginalHandler = RegisterMethodHandler("GET", handlerGet); handlerHead.OriginalHandler = RegisterMethodHandler("HEAD", handlerHead); // Set your iCalendar & vCard library license before calling any members. // iCalendar & vCard library accepts: // - WebDAV Server Engine license with iCalendar & vCard modules. Verify your license file to see if these modules are specified. // - or iCalendar and vCard Library license. ITHit.Collab.LicenseValidator.SetLicense(config.Value.License); }
/// <summary> /// Initializes a new instance of the DavContext class. /// </summary> /// <param name="listenerContext"><see cref="HttpListenerContext"/> instance.</param> /// <param name="prefixes">Http listener prefixes.</param> /// <param name="repositoryPath">Local path to repository.</param> /// <param name="logger"><see cref="ILogger"/> instance.</param> public DavContext( HttpListenerContext listenerContext, HttpListenerPrefixCollection prefixes, System.Security.Principal.IPrincipal principal, string repositoryPath, ILogger logger) : base(listenerContext, prefixes) { this.Logger = logger; this.RepositoryPath = repositoryPath; if (!Directory.Exists(repositoryPath)) { Logger.LogError("Repository path specified in Web.config is invalid.", null); } if (principal != null) { Identity = principal.Identity; } }
/// <summary> /// Initializes new instance of this class based on the WebDAV Engine configuration options and logger instance. /// </summary> /// <param name="config">WebDAV Engine configuration.</param> /// <param name="logger">Logger instance.</param> /// <param name="env">IWebHostEnvironment instance.</param> public DavEngineCore(IOptions <DavEngineConfig> config, ILogger logger, IWebHostEnvironment env) : base() { DavEngineConfig engineConfig = config.Value; OutputXmlFormatting = engineConfig.OutputXmlFormatting; UseFullUris = engineConfig.UseFullUris; CorsAllowedFor = engineConfig.CorsAllowedFor; License = engineConfig.License; Logger = logger; // Set custom handler to process GET and HEAD requests to folders and display // info about how to connect to server. We are using the same custom handler // class (but different instances) here to process both GET and HEAD because // these requests are very similar. // Note that some WebDAV clients may fail to connect if HEAD request is not processed. MyCustomGetHandler handlerGet = new MyCustomGetHandler(env.ContentRootPath); MyCustomGetHandler handlerHead = new MyCustomGetHandler(env.ContentRootPath); handlerGet.OriginalHandler = RegisterMethodHandler("GET", handlerGet); handlerHead.OriginalHandler = RegisterMethodHandler("HEAD", handlerHead); }
/// <summary> /// Processes WebDAV request. /// </summary> public async Task Invoke(HttpContext context, ContextCoreAsync <IHierarchyItemAsync> davContext, IOptions <DavContextConfig> config, ILogger logger) { if (context.Request.Method == "PUT") { // To enable file upload > 2Gb in case you are running .NET Core server in IIS: // 1. Unlock RequestFilteringModule on server level in IIS. // 2. Remove RequestFilteringModule on site level. Uncomment code in web.config to remove the module. // 3. Set MaxRequestBodySize = null. context.Features.Get <IHttpMaxRequestBodySizeFeature>().MaxRequestBodySize = null; } await engine.RunAsync(davContext); }