vinipsmaker / tufao

An asynchronous web framework for C++ built on top of Qt

Home Page:http://vinipsmaker.github.io/tufao/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some prolem with slow connection. Qt 5.4 Win 7 x64

vedun opened this issue · comments

commented

Greetings.
The following minimum code demonstrates the problem:

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    HttpServer server;
    QObject::connect(&server, &HttpServer::requestReady,
                     [](HttpServerRequest &request, HttpServerResponse &res) {
                        qDebug() << "request body = " << request.readBody();
                        res.writeHead(200, "OK");
                        res.end("Hello World\n");
    });
    server.listen(QHostAddress::Any, 8000);
    return a.exec();
}

When client sends POST request with some time pause between headers and request body, i see empty request body in handler.
Investigation of source has not yet led to a beautiful solution. Please advise how to act in a case where I need to use POST request data in handler?
Thank.

The data() signal is emitted when a piece of body is received. Use readBody() after data() or end() are emitted.