[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - jsdav.js:1.7
Stephan Richter
srichter@cbu.edu
Sun, 23 Mar 2003 13:39:27 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv17264/moztop/content/lib
Modified Files:
jsdav.js
Log Message:
Get a first version of PROPFIND implemented. Still untested and cannot
do anything with the response.
=== Packages/Moztop/moztop/content/lib/jsdav.js 1.6 => 1.7 ===
--- Packages/Moztop/moztop/content/lib/jsdav.js:1.6 Sun Mar 23 13:03:22 2003
+++ Packages/Moztop/moztop/content/lib/jsdav.js Sun Mar 23 13:39:27 2003
@@ -44,19 +44,39 @@
}
-DavClient.prototype.PROPFIND = function(url, headers) {
+DavClient.prototype.PROPFIND = function(url, propfind, depth) {
/* Implementation of WebDAV command PROPFIND.
See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.1
*/
+ var request = new XMLHttpRequest();
- // look for optional Depth Header
+ function handleResponse(error) {
+ if (request.responseXML) {
+ var response = request.responseXML;
+ // XXX: Handle returned XML
- // generate propfind XML element (12.14)
+ // Debugging
+ var serializer = new XMLSerializer();
+ var response_str = serializer.serializeToString(response);
+ dump("\nmade it in PUT\n" + response_str + "\n");
+ }
+ }
+ request.onload = handleResponse;
+ request.open("PROPFIND", url);
+ request.setRequestHeader("Content-type", "text/xml");
+ request.setRequestHeader("Host", this.hostname);
+ // look for optional Depth Header
+ if (depth)
+ request.setRequestHeader('Depth', this.createDepthHeader(depth))
// request body optional (if not, all names and values are returned)
+ if (!propfind)
+ request.send("");
+ else
+ request.send(propfind.serialize());
- // Return value text/xml using multi-status
+ return;
}
@@ -218,7 +238,7 @@
Example: 'DAV:1,2'
*/
- var header = "DAV: ";
+ var header = "";
for (var index = 0; index < classes.length; index++) {
header += classes[index];
if (index != classes[length])
@@ -234,7 +254,7 @@
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;
+ return depth;
}
DavClient.prototype.createDestinationHeader = function(absoluteURI) {
@@ -242,7 +262,7 @@
See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.3
*/
- return "Destination: " + absoluteURI;
+ return absoluteURI;
}
@@ -260,7 +280,7 @@
See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.5
*/
- return "Lock-Token: " + codedURL;
+ return codedURL;
}
@@ -269,11 +289,10 @@
See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.6
*/
- header = "Overwrite: ";
if (bool == true)
- return header + "T";
+ return "T";
else
- return header + "F";
+ return "F";
}