gpt4 book ai didi

javascript - 为什么浏览器从 vibed 得到响应这么慢?

转载 作者:搜寻专家 更新时间:2023-10-30 22:56:11 25 4
gpt4 key购买 nike

我正在从浏览器向 vibed 发送数据。在 vibed 控制台上,我立即收到请求。但是在浏览器控制台中,我需要两次等待 console.log 5-8 秒。而且我不明白问题出在哪里。

     postQuestionsContent : function()
{
this.$http.post('http://127.0.0.1:8080/questions', JSON.stringify(this.questions)).then(function(response)
{
console.log("Server response: ", response.status); // 5-8 seconds here

}, function(response)
{
console.log("Server report that it can't process request");
}
);
}

和D代码:

void getQuestions(HTTPServerRequest req, HTTPServerResponse res)
{

if (req.session)
{
Json questions;
try
{
questions = req.json;
writeln("We got questions content!");
res.statusCode = 200;
}
catch (Exception e)
{
writeln("Can't parse incoming data as JSON");
writeln(e.msg);
writeln("------------------------------------------");
}
}

else
{
res.statusCode = 401;
}

res.writeVoidBody;
}

最佳答案

你读过文档吗?

https://vibed.org/api/vibe.http.server/HTTPServerResponse.writeVoidBody

他们在那里说:

For an empty body, just use writeBody, as this method causes problems with some keep-alive connections.

所以也许你应该尝试使用

https://vibed.org/api/vibe.http.server/HTTPServerResponse.writeBody

关于javascript - 为什么浏览器从 vibed 得到响应这么慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36154264/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com