function getRequestWithHeader(name, value) { const req = new http.IncomingMessage(); req.headers[name.toLowerCase()] = value; return req; }
const mockedResponse = (options, callback) => { const incomingMessage = new http.IncomingMessage() callback(incomingMessage) incomingMessage.emit('data', testData) incomingMessage.emit('end') return mockedRequest }
t.test('options.response', function (t) { t.plan(2 + APMServerWithDefaultAsserts.asserts) const req = new http.IncomingMessage() const res = new http.ServerResponse(req) res.statusCode = 204
t.ok(opts.request instanceof http.IncomingMessage)
app = express(); mockAsk = api._askForIssue = jest.fn(); testRequest = new http.IncomingMessage(new net.Socket()); testRequest.url = "/test/route"; testRequest.method = "GET";
t.test('options.request', function (t) { t.plan(2 + APMServerWithDefaultAsserts.asserts) const req = new http.IncomingMessage() req.httpVersion = '1.1' req.method = 'POST'
//get http object var getHttp = function(options) { var req = new http.IncomingMessage(); req.headers = { 'host': 'http://127.0.0.1:8033', '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', }; req.method = 'GET'; req.httpVersion = '1.1'; req.url = '/project/add'; var res = new http.ServerResponse(req); res.write = function() { return true; } return think.http(req, res).then(function(http) { if (options) { for (var key in options) { http[key] = options[key]; } } return http; }) }