diff options
author | Kevin Grandon <kevingrandon@yahoo.com> | 2013-01-28 10:46:21 -0800 |
---|---|---|
committer | Kevin Grandon <kevingrandon@yahoo.com> | 2013-01-28 10:46:21 -0800 |
commit | ee5ae7a9c6ca0ce6136e9b97d4388a1434467b8b (patch) | |
tree | 9e455654fbfec694de58cf5477ce4ebaa91100fe | |
parent | 75c6e99f3d3ff16cc6f5dc26b7bf1dbbb4b3f648 (diff) | |
parent | cfbc4beca74e7baae5c1cd993e18aa92857291c7 (diff) | |
download | jsCalDAV-ee5ae7a9c6ca0ce6136e9b97d4388a1434467b8b.tar.gz |
Merge pull request #10 from mozilla-b2g/empty-propstat
Handle empty propstat by sending false
-rw-r--r-- | caldav.js | 12 | ||||
-rw-r--r-- | lib/caldav/sax/dav_response.js | 12 | ||||
-rw-r--r-- | samples/xml/propget.xml | 7 | ||||
-rw-r--r-- | test/caldav/sax/dav_response_test.js | 7 |
4 files changed, 31 insertions, 7 deletions
@@ -2527,7 +2527,8 @@ function write (chunk) { oncomplete: function() { var propstat = this.stack[this.stack.length - 1]; - propstat = propstat.propstat; + var hash = propstat.propstat; + var key; var status = this.current.status; var props = this.current.prop; @@ -2535,14 +2536,21 @@ function write (chunk) { delete this.current.status; delete this.current.prop; + var hasProps = false; + for (key in props) { + hasProps = true; if (Object.hasOwnProperty.call(props, key)) { - propstat[key] = { + hash[key] = { status: status, value: props[key] }; } } + + if (!hasProps) { + propstat.propstat = false; + } } }); diff --git a/lib/caldav/sax/dav_response.js b/lib/caldav/sax/dav_response.js index 69a4368..f168d97 100644 --- a/lib/caldav/sax/dav_response.js +++ b/lib/caldav/sax/dav_response.js @@ -165,7 +165,8 @@ oncomplete: function() { var propstat = this.stack[this.stack.length - 1]; - propstat = propstat.propstat; + var hash = propstat.propstat; + var key; var status = this.current.status; var props = this.current.prop; @@ -173,14 +174,21 @@ delete this.current.status; delete this.current.prop; + var hasProps = false; + for (key in props) { + hasProps = true; if (Object.hasOwnProperty.call(props, key)) { - propstat[key] = { + hash[key] = { status: status, value: props[key] }; } } + + if (!hasProps) { + propstat.propstat = false; + } } }); diff --git a/samples/xml/propget.xml b/samples/xml/propget.xml index 2db1aa2..dd20c91 100644 --- a/samples/xml/propget.xml +++ b/samples/xml/propget.xml @@ -2,6 +2,13 @@ <D:multistatus xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav"> <D:response> + <D:href>/calendar/fake/</D:href> + <D:propstat> + <D:status>HTTP/1.1 404 Not Found</D:status> + </D:propstat> + </D:response> + + <D:response> <D:href>/calendar/user/</D:href> diff --git a/test/caldav/sax/dav_response_test.js b/test/caldav/sax/dav_response_test.js index 3825043..dd2ecdd 100644 --- a/test/caldav/sax/dav_response_test.js +++ b/test/caldav/sax/dav_response_test.js @@ -83,8 +83,9 @@ suite('caldav/sax/dav_response', function() { }); expected = { - '/calendar/user/': { + '/calendar/fake/': false, + '/calendar/user/': { 'principal-URL': { status: '200', value: { @@ -135,7 +136,7 @@ suite('caldav/sax/dav_response', function() { '/calendar/user/', expected['/calendar/user/'] ], - response[0], + response[1], '/calendar/user/ response' ); @@ -144,7 +145,7 @@ suite('caldav/sax/dav_response', function() { '/calendar/other', expected['/calendar/other'] ], - response[1], + response[2], '/calendar/other/ response' ); |