var http = require('http'); function createReqRes() { var req = new http.IncomingMessage(); req.headers = { 'x-real-ip': '127.0.0.1', 'x-forwarded-for': '127.0.0.1', 'host': 'www.thinkjs.org', 'x-nginx-proxy': 'true', 'connection': 'close', 'cache-control': 'max-age=0', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36', 'accept-encoding': 'gzip,deflate,sdch', 'accept-language': 'zh-CN,zh;q=0.8,en;q=0.6,ja;q=0.4,nl;q=0.2,zh-TW;q=0.2' }; req.method = 'GET'; req.httpVersion = '1.1'; req.url = '/index/index/name/welefen?test=welefen&value=1111'; var res = new http.ServerResponse(req); res.write = function(){ return true; } return { req: req, res: res } } let instance = createReqRes(); module.exports = { req: instance.req, res: instance.res, createReqRes }