Namespace: ITHit.WebDAV.Server
The DavContextBaseAsync type exposes the following members.
Name | Description | |
---|---|---|
DavContextBaseAsync |
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 | |
---|---|---|
BeforeResponseAsync |
This method is called right before engine starts writing response.
| |
EnsureBeforeResponseWasCalledAsync |
Calls BeforeResponseAsync 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.) | |
GetHierarchyItemAsync |
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 GetHierarchyItemAsync(String).
When you inherit from WebDAV Context class, you must override GetHierarchyItemAsync(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 WebDAV Context with one of its overloaded constructors and pass it to RunAsync(DavContextBaseAsync).
You can 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); } } }