Hapi js 和 Postman Chrome App - 后续请求
Hapi js and Postman Chrome App - subsequent requests
我有这个非常小的 hapi 服务器:
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({
port: 8080
});
server.route({
method: 'GET',
path: '/hello',
handler: function(request, reply) {
console.log('hooray');
setTimeout(function() {
console.log('mellow');
return reply("Hello");
}, 7500);//7.5 seconds
}
});
server.start((err) => {
console.log(`Server started at ${ server.info.uri }`);
});
现在,如果使用 Postman Chrome 应用程序(来自 2 个不同的选项卡)发送 2 个延迟 2 秒的请求,我会在控制台上得到以下输出:
Server started at http://clivend-N56VV:8080
hooray
mellow
hooray
mellow
为什么 hapi 在处理另一个请求之前等待回复第一个请求?
谢谢!
等待上一个请求的不开心。我打赌你正在一个浏览器中测试它。尝试从 2 个不同的浏览器或使用 curl 发出 2 个请求。
我有这个非常小的 hapi 服务器:
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({
port: 8080
});
server.route({
method: 'GET',
path: '/hello',
handler: function(request, reply) {
console.log('hooray');
setTimeout(function() {
console.log('mellow');
return reply("Hello");
}, 7500);//7.5 seconds
}
});
server.start((err) => {
console.log(`Server started at ${ server.info.uri }`);
});
现在,如果使用 Postman Chrome 应用程序(来自 2 个不同的选项卡)发送 2 个延迟 2 秒的请求,我会在控制台上得到以下输出:
Server started at http://clivend-N56VV:8080
hooray
mellow
hooray
mellow
为什么 hapi 在处理另一个请求之前等待回复第一个请求?
谢谢!
等待上一个请求的不开心。我打赌你正在一个浏览器中测试它。尝试从 2 个不同的浏览器或使用 curl 发出 2 个请求。