-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhttp-node.js
More file actions
38 lines (32 loc) · 899 Bytes
/
http-node.js
File metadata and controls
38 lines (32 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* should-http
* Copyright(c) 2010-2013 TJ Holowaychuk <tj@vision-media.ca>
* Copyright(c) 2013-2016 Denis Bardadym <bardadymchik@gmail.com>
* MIT Licensed
*/
var http = require('http');
module.exports = function(should) {
var t = should.modules.type;
var format = should.modules.format;
var NODE_HTTP_INCOMMING_MESSAGE = new t.Type(t.OBJECT, 'node-http-incomming-message');
t.checker.addBeforeFirstMatch({}, function(obj) {
if (obj instanceof http.IncomingMessage) {
return NODE_HTTP_INCOMMING_MESSAGE;
}
});
var FIELDS = {
headers: true,
httpVersion: true,
method: true,
statusCode: true,
url: true,
body: true
};
format.Formatter.addType(NODE_HTTP_INCOMMING_MESSAGE, function(value) {
return format.formatPlainObject.call(this, value, {
filterKey: function(key) {
return key in FIELDS;
}
});
});
};