From a91227bbffc544aa97790bfabf34f1eafba75f0c Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Sun, 1 Oct 2017 14:22:57 +0200 Subject: [PATCH] Modified the behaviour of the PROPFIND method when an error occurs in the child resources --- lib/server/v2/commands/Propfind.js | 17 ++++++++++++++++- src/server/v2/commands/Propfind.ts | 20 +++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/server/v2/commands/Propfind.js b/lib/server/v2/commands/Propfind.js index 16ad72a9..acb6b797 100644 --- a/lib/server/v2/commands/Propfind.js +++ b/lib/server/v2/commands/Propfind.js @@ -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) @@ -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'); diff --git a/src/server/v2/commands/Propfind.ts b/src/server/v2/commands/Propfind.ts index 0034d557..caa7516a 100644 --- a/src/server/v2/commands/Propfind.ts +++ b/src/server/v2/commands/Propfind.ts @@ -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) @@ -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); }