-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7c5192
commit 105580f
Showing
7 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { MethodCallArgs } from '../WebDAVRequest'; | ||
export default function (arg: MethodCallArgs, callback: any): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var WebDAVRequest_1 = require("../WebDAVRequest"); | ||
function default_1(arg, callback) { | ||
arg.getResource(function (e, r) { | ||
if (e) { | ||
arg.setCode(WebDAVRequest_1.HTTPCodes.NotFound); | ||
callback(); | ||
return; | ||
} | ||
r.read(function (e, c) { | ||
if (e) | ||
arg.setCode(WebDAVRequest_1.HTTPCodes.MethodNotAllowed); | ||
else | ||
arg.setCode(WebDAVRequest_1.HTTPCodes.OK); | ||
callback(); | ||
}); | ||
}); | ||
} | ||
exports.default = default_1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { HTTPCodes, MethodCallArgs, WebDAVRequest } from '../WebDAVRequest' | ||
import { IResource } from '../../resource/Resource' | ||
|
||
export default function(arg : MethodCallArgs, callback) | ||
{ | ||
arg.getResource((e, r) => { | ||
if(e) | ||
{ | ||
arg.setCode(HTTPCodes.NotFound) | ||
callback(); | ||
return; | ||
} | ||
|
||
r.read((e, c) => { | ||
if(e) | ||
arg.setCode(HTTPCodes.MethodNotAllowed) | ||
else | ||
arg.setCode(HTTPCodes.OK); | ||
callback(); | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var webdav = require('../../lib/index.js'), | ||
request = require('request') | ||
|
||
module.exports = (test, options, index) => test('HEAD method', isValid => | ||
{ | ||
var server = new webdav.WebDAVServer(); | ||
server.start(options.port + index); | ||
isValid = isValid.multiple(2, server); | ||
|
||
request({ | ||
url: 'http://localhost:' + (options.port + index), | ||
method: 'HEAD' | ||
}, (e, res, body) => { | ||
isValid(!e && res.statusCode !== 200); | ||
}) | ||
|
||
server.rootResource.addChild(new webdav.VirtualFile('file'), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
request({ | ||
url: 'http://localhost:' + (options.port + index) + '/file', | ||
method: 'HEAD' | ||
}, (e, res, body) => { | ||
isValid(!e && res.statusCode === 200); | ||
}) | ||
}) | ||
}) |