javascriptdvue.jsvibed

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

Solution

  • 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