[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - jsdav.js:1.5

Stephan Richter srichter@cbu.edu
Sun, 23 Mar 2003 11:29:49 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv32635/moztop/content/lib

Modified Files:
	jsdav.js 
Log Message:
More skelleton work. Moved to Prototype-based approach.


=== Packages/Moztop/moztop/content/lib/jsdav.js 1.4 => 1.5 ===
--- Packages/Moztop/moztop/content/lib/jsdav.js:1.4	Sun Mar 23 10:07:16 2003
+++ Packages/Moztop/moztop/content/lib/jsdav.js	Sun Mar 23 11:29:49 2003
@@ -17,7 +17,88 @@
 
 ******************************************************************************/
 
-function DELETE(url) {
+// Some constants
+const RESOURCE_DEPTH = '0';
+const CHILDREN_DEPTH = '1';
+const ALLSUBS_DEPTH = 'infinity';
+
+/* WebDAV Status Code Extensions
+
+   See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-10
+*/
+var statusCodes = new Array();
+statusCodes[102] = 'Processing';
+statusCodes[207] = 'Multi-Status';
+statusCodes[422] = 'Unprocessable Entity';
+statusCodes[423] = 'Locked';
+statusCodes[424] = 'Failed Dependency';
+statusCodes[507] = 'Insufficient Storage';
+
+
+function DavClient(hostname) {
+    /* This library intends to be a complete implementation of the WebDAV RFC.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.6
+    */
+    this.hostname = hostname;
+}
+
+
+DavClient.prototype.PROPFIND = function(url) {
+    /* Implementation of WebDAV command PROPFIND.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.1
+    */
+
+}
+
+
+DavClient.prototype.PROPPATCH = function(url) {
+    /* Implementation of WebDAV command PROPPATCH.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.2
+    */
+
+}
+
+
+DavClient.prototype.MKCOL = function(url) {
+    /* Implementation of WebDAV command MKCOL.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.3
+    */
+
+}
+
+
+DavClient.prototype.GET = function(url) {
+    /* Implementation of WebDAV command GET.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.4
+    */
+
+}
+
+
+DavClient.prototype.HEAD = function(url) {
+    /* Implementation of WebDAV command HEAD.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.4
+    */
+
+}
+
+
+DavClient.prototype.POST = function(url) {
+    /* Implementation of WebDAV command POST.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.5
+    */
+
+}
+
+
+DavClient.prototype.DELETE = function(url) {
     /* Implementation of WebDAV command DELETE.
 
        See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.6
@@ -38,15 +119,14 @@
     request.onload = handleResponse;
     request.open("DELETE", url);
     request.setRequestHeader("Content-type", "text/plain");
-    // XXX: implement "Host" header in a non-static way
-    request.setRequestHeader("Host", "localhost");
-    request.send(putcontent);
+    request.setRequestHeader("Host", this.hostname);
+    request.send("");
 
     return;
 }    
 
 
-function PUT(url, headers) {
+DavClient.prototype.PUT = function(url, headers) {
     /* Implementation of WebDAV command PUT.
 
        See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.7
@@ -88,7 +168,7 @@
 }    
 
 
-function COPY(url, destination, content, headers) {
+DavClient.prototype.COPY = function(url, destination, content, headers) {
     /* Implementation of WebDAV command COPY.
 
        See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.8
@@ -97,7 +177,7 @@
 }
 
 
-function MOVE(url, destination, headers) {
+DavClient.prototype.MOVE = function(url, destination, headers) {
     /* Implementation of WebDAV command MOVE.
 
        See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.9
@@ -106,7 +186,7 @@
 }
 
 
-function LOCK(url, content, headers) {
+DavClient.prototype.LOCK = function(url, content, headers) {
     /* Implementation of WebDAV command LOCK.
 
        See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.10
@@ -115,7 +195,7 @@
 }
 
 
-function UNLOCK(url, headers) {
+DavClient.prototype.UNLOCK = function(url, headers) {
     /* Implementation of WebDAV command UNLOCK.
 
        See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.11 
@@ -124,33 +204,42 @@
 }
 
 
-function createDAVHeader(version) {
+DavClient.prototype.createDAVHeader = function(classes) {
     /* Creates a DAV Header. 
 
       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.1
-    */
 
+      Example: 'DAV:1,2'
+    */
+    var header = "DAV: ";
+    for (index = 0; index == classes.length; index++) {
+	header += classes[index];
+	if (index != classes[length])
+	    header += ",";
+    }
+    return header;
 }
 
 
-function createDepthHeader(depth) {
+DavClient.prototype.createDepthHeader = function(depth) {
     /* Creates a Depth Header. 
 
       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.2
     */
-
+    // XXX: Check for correct depth and raise exception if necessary
+    return "Depth: " + depth;
 }
 
-function createDestinationHeader(destination) {
+DavClient.prototype.createDestinationHeader = function(absoluteURI) {
     /* Creates a Destination Header. 
 
       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.3
     */
-
+    return "Destination: " + absoluteURI;
 }
 
 
-function createIfHeader() {
+DavClient.prototype.createIfHeader = function() {
     /* Creates a If Header. 
 
       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.4
@@ -159,51 +248,42 @@
 }
 
 
-function createLockTokenHeader(url) {
+DavClient.prototype.createLockTokenHeader = function(codedURL) {
     /* Creates a Lock-Token Header. 
 
       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.5
     */
-
+    return "Lock-Token: " + codedURL;
 }
 
 
-function createOverwriteHeader(bool) {
+DavClient.prototype.createOverwriteHeader = function(bool) {
     /* Creates an Overwrite Header. 
 
       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.6
     */
-
+    header = "Overwrite: ";
+    if (bool == true) 
+	return header + "T";
+    else
+	return header + "F";
 }
 
 
-
-function handleStatusURIHeader(header) {
+DavClient.prototype.handleStatusURIHeader = function(header) {
     /* Handle a Status-URI Response Header. 
 
       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.7
     */
+    // Should return statusCode and CodedURL
 
 }
 
 
-function createTimeoutHeader(time) {
+DavClient.prototype.createTimeoutHeader = function(time) {
     /* Creates an Timeout Request Header. 
 
       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.8
     */
 
 }
-
-
-/* WebDAV Status Code Extensions
-
-   See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-10
-*/
-var statusCodes = new Array();
-statusCodes[102] = 'Processing';
-statusCodes[207] = 'Multi-Status';
-statusCodes[422] = 'Unprocessable Entity';
-statusCodes[423] = 'Locked';
-statusCodes[424] = 'Failed Dependency';
-statusCodes[507] = 'Insufficient Storage';