Skip to content

Commit

Permalink
Modified the behaviour of the PROPFIND method when an error occurs in…
Browse files Browse the repository at this point in the history
… the child resources
  • Loading branch information
AdrienCastex committed Oct 1, 2017
1 parent da1c79a commit a91227b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
17 changes: 16 additions & 1 deletion lib/server/v2/commands/Propfind.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ var default_1 = (function () {
ctx.server.getResource(ctx, ctx.requested.path.getChildPath(childName), function (e, r) {
if (e)
return cb(e);
addXMLInfo(r, multistatus, cb);
addXMLInfo(r, multistatus, function (e) { return cb(); });
});
})
.error(err)
Expand All @@ -129,6 +129,21 @@ var default_1 = (function () {
e = null;
else if (!e)
multistatus.add(response);
else {
var errorNumber = WebDAVRequest_1.HTTPRequestContext.defaultStatusCode(e);
if (errorNumber !== null) {
var response_1 = new xml_js_builder_1.XMLElementBuilder('D:response');
response_1.ele('D:propstat').ele('D:status').add('HTTP/1.1 ' + errorNumber + ' ' + http.STATUS_CODES[errorNumber]);
resource.fs.getFullPath(ctx, resource.path, function (e, path) {
if (e)
return nbOut(e);
var p = encode(ctx.fullUri(path.toString()));
response_1.ele('D:href', undefined, true).add(p);
response_1.ele('D:location').ele('D:href', undefined, true).add(p);
});
multistatus.add(response_1);
}
}
_callback(e);
};
var propstat = response.ele('D:propstat');
Expand Down
20 changes: 19 additions & 1 deletion src/server/v2/commands/Propfind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export default class implements HTTPMethod
ctx.server.getResource(ctx, ctx.requested.path.getChildPath(childName), (e, r) => {
if(e)
return cb(e);
addXMLInfo(r, multistatus, cb);
addXMLInfo(r, multistatus, (e) => cb());
});
})
.error(err)
Expand All @@ -233,6 +233,24 @@ export default class implements HTTPMethod
e = null;
else if(!e)
multistatus.add(response);
else
{
const errorNumber = HTTPRequestContext.defaultStatusCode(e);
if(errorNumber !== null)
{
const response = new XMLElementBuilder('D:response');
response.ele('D:propstat').ele('D:status').add('HTTP/1.1 ' + errorNumber + ' ' + http.STATUS_CODES[errorNumber]);
resource.fs.getFullPath(ctx, resource.path, (e, path) => {
if(e)
return nbOut(e);

const p = encode(ctx.fullUri(path.toString()));
response.ele('D:href', undefined, true).add(p);
response.ele('D:location').ele('D:href', undefined, true).add(p);
})
multistatus.add(response);
}
}

_callback(e);
}
Expand Down

0 comments on commit a91227b

Please sign in to comment.