Skip to content

Commit

Permalink
Added the 'Content-Length' header and the 'Accept-Ranges' header in t…
Browse files Browse the repository at this point in the history
…he HEAD method
  • Loading branch information
AdrienCastex committed Jun 10, 2017
1 parent 3df40bb commit 992620b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
15 changes: 13 additions & 2 deletions lib/server/commands/Head.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ function default_1(arg, callback) {
arg.setCode(WebDAVRequest_1.HTTPCodes.InternalServerError);
else if (!type.isFile)
arg.setCode(WebDAVRequest_1.HTTPCodes.MethodNotAllowed);
else
arg.setCode(WebDAVRequest_1.HTTPCodes.OK);
else {
r.size(targetSource, function (e, size) {
if (e)
arg.setCode(WebDAVRequest_1.HTTPCodes.InternalServerError);
else {
arg.setCode(WebDAVRequest_1.HTTPCodes.OK);
arg.response.setHeader('Accept-Ranges', 'bytes');
arg.response.setHeader('Content-Length', size.toString());
callback();
}
});
return;
}
callback();
});
});
Expand Down
15 changes: 14 additions & 1 deletion src/server/commands/Head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@ export default function(arg : MethodCallArgs, callback)
else if(!type.isFile)
arg.setCode(HTTPCodes.MethodNotAllowed)
else
arg.setCode(HTTPCodes.OK);
{
r.size(targetSource, (e, size) => {
if(e)
arg.setCode(HTTPCodes.InternalServerError)
else
{
arg.setCode(HTTPCodes.OK);
arg.response.setHeader('Accept-Ranges', 'bytes')
arg.response.setHeader('Content-Length', size.toString());
callback();
}
})
return;
}

callback();
})
Expand Down

0 comments on commit 992620b

Please sign in to comment.