Skip to content

Commit

Permalink
Moved the 'Allow' response header from the 'OPTIONS' method to all th…
Browse files Browse the repository at this point in the history
…e methods + Added the 'Server' header to the responses
  • Loading branch information
AdrienCastex committed Jun 15, 2017
1 parent fd4158b commit e015847
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
5 changes: 5 additions & 0 deletions lib/server/MethodCallArgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ var MethodCallArgs = (function () {
MethodCallArgs.create = function (server, request, response, callback) {
var mca = new MethodCallArgs(server, request, response, null, null);
response.setHeader('DAV', '1,2');
response.setHeader('Server', server.options.serverName + '/' + server.options.version);
response.setHeader('Allow', Object
.keys(server.methods)
.map(function (s) { return s.toUpperCase(); })
.join(','));
mca.askForAuthentication(false, function (e) {
if (e) {
callback(e, mca);
Expand Down
5 changes: 0 additions & 5 deletions lib/server/commands/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var WebDAVRequest_1 = require("../WebDAVRequest");
function default_1(arg, callback) {
arg.noBodyExpected(function () {
var methods = Object
.keys(arg.server.methods)
.map(function (s) { return s.toUpperCase(); })
.join(',');
arg.setCode(WebDAVRequest_1.HTTPCodes.OK);
arg.response.setHeader('Allow', methods);
callback();
});
}
Expand Down
5 changes: 5 additions & 0 deletions src/server/MethodCallArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export class MethodCallArgs
{
const mca = new MethodCallArgs(server, request, response, null, null);
response.setHeader('DAV', '1,2');
response.setHeader('Server', server.options.serverName + '/' + server.options.version);
response.setHeader('Allow', Object
.keys(server.methods)
.map(s => s.toUpperCase())
.join(','));

mca.askForAuthentication(false, (e) => {
if(e)
Expand Down
6 changes: 0 additions & 6 deletions src/server/commands/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import { HTTPCodes, MethodCallArgs } from '../WebDAVRequest'
export default function(arg : MethodCallArgs, callback)
{
arg.noBodyExpected(() => {
const methods = Object
.keys(arg.server.methods)
.map(s => s.toUpperCase())
.join(',');

arg.setCode(HTTPCodes.OK);
arg.response.setHeader('Allow', methods);
callback();
})
}

0 comments on commit e015847

Please sign in to comment.