Click or drag to resize

DavContextBaseAsync Class

IT Hit WebDAV Classes Reference
Serves as the abstract base class for WebDAV context.
Inheritance Hierarchy

Namespace: ITHit.WebDAV.Server
Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 7.1.4620
Syntax
public abstract class DavContextBaseAsync

The DavContextBaseAsync type exposes the following members.

Constructors
  NameDescription
Public methodDavContextBaseAsync
Initializes a new instance of the WebDAV context. Initializes Request and Response properties.
Top
Properties
  NameDescription
Public propertyEngine
Instance of DavEngine which is currently executing the request.
Public propertyException
Exception which occurred during request execution.
Public propertyRequest
Object representing current request.
Public propertyResponse
Object representing current response.
Top
Methods
  NameDescription
Public methodBeforeResponseAsync
This method is called right before engine starts writing response.
Public methodEnsureBeforeResponseWasCalledAsync
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodCode exampleGetHierarchyItemAsync
Implementation of this abstract method is used by WebDAV engine to find hierarchy item objects by path.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLocalizeSatus
May be overriden to localize HTTP status message.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

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.

Examples

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);
        }
    }
}
Thread Safety
Instance members of this class are not thread safe. You must create a separate instance of DavContextBaseAsync class for each request.
See Also