简体   繁体   English

为什么浏览器如此缓慢地得到响应?

[英]Why browser get response from vibed so slowly?

I am sending data from browser to vibed. 我正在将数据从浏览器发送到vibed。 On vibed console I am getting request instantly. 在振动控制台上,我立即收到请求。 But in browser console I need two wait for console.log 5-8 seconds. 但是在浏览器控制台中,我需要两个等待console.log 5-8秒。 And I can't understand where is problem. 而且我不明白哪里出了问题。

     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");
          }
        ); 
      }

And D code: 和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;
}

Did you read documentation? 您阅读过文档吗?

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

they are saying there: 他们在那儿说:

For an empty body, just use writeBody, as this method causes problems with some keep-alive connections. 对于空的主体,只需使用writeBody,因为此方法会导致一些保持活动的连接出现问题。

So maybe you should try use 所以也许你应该尝试使用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM