首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么浏览器从vibed获得响应的速度这么慢?

为什么浏览器从vibed获得响应的速度这么慢?
EN

Stack Overflow用户
提问于 2016-03-22 12:21:39
回答 1查看 139关注 0票数 1

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

代码语言:javascript
运行
复制
     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码:

代码语言:javascript
运行
复制
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;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-22 14:34:29

你看过文件了吗?

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

他们在那里说:

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

所以也许你应该试试

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36154264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档