thedesk/app/node_modules/xhr/test/mock-server.js

19 lines
552 B
JavaScript
Raw Normal View History

2018-02-19 04:41:25 +11:00
module.exports = function(req, res) {
console.log('mock:', req.url)
if (req.url === '/mock/200ok') {
res.statusCode = 200
res.end('')
} else if (req.url.substr(0,16) === '/mock/no-content') {
res.statusCode = parseInt(req.url.substring(17), 10)
res.end('')
} else if (req.url === '/mock/echo') {
res.statusCode = 200
req.pipe(res)
} else if (req.url === '/mock/timeout') {
setTimeout(function() {
res.statusCode = 200
res.end()
}, 100)
}
}