Class: Request

Request Class

Namespace

ITHit.WebDAV.Client

Members

Progress info object, auto updated on `OnProgress` event.

Methods

Abort()

Cancels asynchronous request. The Finish event and the callback function will be called immediately after this method call.

AddListener(sEventName, fCallback, oContext)

Name Type Description
sEventName string
fCallback
oContext object optional

RemoveListener(sEventName, fCallback, oContext)

Name Type Description
sEventName string
fCallback
oContext object optional

Events

OnError

Error event trigger when one of request operations have error. Notice: This event trigger before async method callback.
Properties:
Name Type Description
Error Error | ITHit.WebDAV.Client.Exceptions.WebDavException Error object
Request ITHit.WebDAV.Client.Request Current request

OnFinish

Finish event trigger once when all operations in requests is complete. Notice: This event trigger before async method callback.
Properties:
Name Type Description
Request ITHit.WebDAV.Client.Request Current request

OnProgress

Progress event trigger on update information about request progress. See ITHit.WebDAV.Client.RequestProgress for more information.
Properties:
Name Type Description
Progress ITHit.WebDAV.Client.RequestProgress Progress info instance
Request ITHit.WebDAV.Client.Request Current request
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oAsyncResult.Result;

    var oRequest = oFolder.GetChildrenAsync(true, null, function(oAsyncResult) {

        if (oAsyncResult.IsSuccess) {
            console.log('Count of children: ' + oAsyncResult.Result.length);
        }

    });

    // Subscribe on progress event
    oRequest.AddListener('OnProgress', function(oEvent) {
        /** @typedef {ITHit.WebDAV.Client.RequestProgress} oProgress */
        var oProgress = oEvent.Progress;

        var aOfText = oProgress.LengthComputable ?
            [oProgress.BytesLoaded, 'of', oProgress.BytesTotal, 'bytes'] :
            [oProgress.CountComplete, 'of', oProgress.CountTotal];

        console.log('Progress: ' + oProgress.Percent + '% (' + aOfText.join(' ') + ')');
    });

    fCallback(oRequest);
});