nyc-bookstores/node_modules/filed/test/server.js

20 lines
526 B
JavaScript
Raw Normal View History

2013-05-27 20:45:59 +00:00
var http = require('http')
function createServer () {
var s = http.createServer(function (req, resp) {
resp.___end = resp.end
resp.end = function (chunk) {
s.completed[req.url] = true
resp.___end(chunk)
if (Object.keys(s._events).filter(function(n){return n[0] === '/'}).length === Object.keys(s.completed).length) {
setTimeout(function () {
s.close()
}, 0)
}
}
s.emit(req.url, req, resp)
})
s.completed = {}
return s;
}
module.exports = createServer;