Namespace: ITHit.WebDAV.Server
The DavEngine type exposes the following members.
Name | Description | |
---|---|---|
AutoPutUnderVersionControl |
Determines if placing file under version control is automatic.
| |
CalculateContentLength |
Indicates if response content length calculation will occur.
| |
ContentEncoding |
Gets or sets the HTTP character set of the output stream.
| |
CorsAllowedFor |
Enables or disables CORS.
| |
License |
Gets or sets the license text.
| |
Logger | ILogger instance which engine will use for logging.
| |
OutputXmlFormatting |
Specifies whether XML written to the output will be formatted.
| |
UseFullUris |
Specifies whether engine shall use full or relative urls.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
RegisterMethodHandler |
Registers custom method handler.
| |
RegisterOptionsHandler |
Registers custom options handler.
| |
RegisterPropertyHandler |
Registers custom property handler.
| |
RegisterReportHandler |
Registers custom report handler.
| |
Run |
Processes WebDAV request and generates WebDAV response.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Engine parses XML send by WebDAV client, processes requests making calls to your implementations of WebDAV interfaces (IHierarchyItem, IFolder, IFile and other) and finally generates XML response.
In each HTTP request you will create separate instance of your class derived from DavContextBase class and pass it to the Run(DavContextBase) method. Via the context, engine receives all necessary information about hosting environment.
You must set License property before you can use the engine.
All updates invoked within one request execution shall be inside one transactions. Transaction can be committed or rollbacked in BeforeResponse method, which is called right before starting sending response to client. After this method is called, no methods of interfaces which update state will be called. However methods which read state can be called.
The code below is part of 'WebDAVServer.NtfsStorage' sample provided with the SDK.
public class DavHandler : IHttpHandler { private readonly string license = File.ReadAllText(HttpContext.Current.Request.PhysicalApplicationPath + "License.lic"); private static readonly bool debugLoggingEnabled = "true".Equals( ConfigurationManager.AppSettings["DebugLoggingEnabled"], StringComparison.InvariantCultureIgnoreCase); public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { DavEngine engine = getOrInitializeEngine(context); context.Response.BufferOutput = false; DavContext ntfsDavContext = new DavContext(context); engine.Run(ntfsDavContext); } private DavEngine initializeEngine(HttpContext context) { ILogger logger = Logger.Instance; var engine = new DavEngine { Logger = logger // Use idented responses if debug logging is enabled. , OutputXmlFormatting = debugLoggingEnabled ? Formatting.Indented : Formatting.None }; engine.License = license; return engine; } private DavEngine getOrInitializeEngine(HttpContext context) { //we don't use any double check lock pattern here because nothing wrong //is going to happen if we created occasionally several engines. const string ENGINE_KEY = "$DavEngine$"; if (context.Application[ENGINE_KEY] == null) { context.Application[ENGINE_KEY] = initializeEngine(context); } return (DavEngine)context.Application[ENGINE_KEY]; } }
HttpListener-based server:
class Program { static void Main(string[] args) { HttpListener listener = new HttpListener(); listener.Prefixes.Add("http://localhost:8080/"); listener.Start(); DavEngine engine = new DavEngine(); engine.License = "..."; while (true) { HttpListenerContext context = listener.GetContext(); engine.Run(new MyContext(context, listener.Prefixes)); try { context.Response.Close(); } catch { // client closed connection before the content was sent } } } }