Namespace: ITHit.WebDAV.Server
The DavContextBase type exposes the following members.
Name | Description | |
---|---|---|
DavContextBase(HttpContext) |
Initializes context for IIS/ASP.NET based server.
| |
DavContextBase(HttpListenerContext, HttpListenerPrefixCollection) |
Initializes context for HttpListener-based server.
| |
DavContextBase(DavRequest, DavResponse) |
Initializes a new instance of the WebDAV context.
|
Name | Description | |
---|---|---|
Engine |
Instance of DavEngine which is currently executing the request.
| |
Exception |
Exception which occurred during request execution.
| |
Request |
Object representing current request.
| |
Response |
Object representing current response.
|
Name | Description | |
---|---|---|
BeforeResponse |
This method is called right before engine starts writing response.
| |
EnsureBeforeResponseWasCalled |
Calls BeforeResponse only first time this method is invoked.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetHierarchyItem |
Implementation of this abstract method is used by WebDAV engine to find hierarchy item objects by path.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
LocalizeSatus |
May be overriden to localize HTTP status message.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Context holds request, response and provides item factory method GetHierarchyItem(String).
When you inherit from the DavContext class, you must override GetHierarchyItem(String) method. In this method you will search for file, folder, version or history item in your storage by path provided and return it to WebDAV engine.
In each HTTP request you will create separate instance of your class derived from DavContext with one of its overloaded constructors and pass it to Run(DavContextBase).
The DavContextBase provides several overloaded constructors. They are optimized for use with OWIN, with IIS/ASP.NET-based server and in HttpListener-based server. You can also implement your own request and response classes to run the Engine in virtually any hosting environment.
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(); while (true) { HttpListenerContext context = listener.GetContext(); MacOsXPreprocessor.Process(context.Request); // fixes headers for Mac OS X v10.5.3 or later if (!userAutorized(context)) { context.Response.StatusCode = 401; showLoginDialog(context, context.Response); closeResponse(context); continue; } context.Response.SendChunked = false; var davContext = new MyDavContext(context, listener.Prefixes); engine.Run(ntfsDavContext); if (context.Response.StatusCode == 401) { showLoginDialog(context, context.Response); } closeResponse(context); } } }