Skip to content

Commit

Permalink
Modified the HEAD method implementation to avoid the use of the 'read…
Browse files Browse the repository at this point in the history
…' method of the resources
  • Loading branch information
AdrienCastex committed Jun 4, 2017
1 parent eaefedc commit 25d120b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/server/commands/Head.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ function default_1(arg, callback) {
var targetSource = arg.findHeader('source', 'F').toUpperCase() === 'T';
arg.checkIfHeader(r, function () {
arg.requirePrivilege(targetSource ? ['canRead', 'canSource'] : ['canRead'], r, function () {
r.read(targetSource, function (e, c) { return process.nextTick(function () {
r.type(function (e, type) {
if (e)
arg.setCode(WebDAVRequest_1.HTTPCodes.InternalServerError);
else if (!type.isFile)
arg.setCode(WebDAVRequest_1.HTTPCodes.MethodNotAllowed);
else
arg.setCode(WebDAVRequest_1.HTTPCodes.OK);
callback();
}); });
});
});
});
});
Expand Down
7 changes: 5 additions & 2 deletions src/server/commands/Head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ export default function(arg : MethodCallArgs, callback)

arg.checkIfHeader(r, () => {
arg.requirePrivilege(targetSource ? [ 'canRead', 'canSource' ] : [ 'canRead' ], r, () => {
r.read(targetSource, (e, c) => process.nextTick(() => {
r.type((e, type) => {
if(e)
arg.setCode(HTTPCodes.InternalServerError)
else if(!type.isFile)
arg.setCode(HTTPCodes.MethodNotAllowed)
else
arg.setCode(HTTPCodes.OK);

callback();
}))
})
})
})
})
Expand Down

0 comments on commit 25d120b

Please sign in to comment.