用net模块写测试服务器,浏览器可以打开,用ab做不了压力测试
var net = require('net');
var server = net.createServer(function (socket) {
socket.write("HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nhello world!");
socket.pipe(socket);
});
server.listen(1337, '127.0.0.1');
用浏览器/curl打开显示正常 用ab测试就提示 Benchmarking 127.0.0.1 (be patient)…apr_poll: The timeout specified has expired (70007) Benchmarking 127.0.0.1 (be patient)…apr_poll: The timeout specified has expired (70007)
1 回复
没见过这写法,直接一句就行了呀:
socket.end(“HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nhello world!”);