简体   繁体   中英

Why browser get response from vibed so slowly?

I am sending data from browser to vibed. On vibed console I am getting request instantly. But in browser console I need two wait for console.log 5-8 seconds. 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:

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

they are saying there:

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

So maybe you should try use

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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