为什么浏览器从vibed得到的响应如此缓慢



我正在从浏览器向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

他们说:

对于空的实体,只需使用writeBody,因为这种方法会导致一些保持活动连接出现问题。

所以也许你应该尝试使用

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

相关内容

  • 没有找到相关文章

最新更新