vinipsmaker / tufao

An asynchronous web framework for C++ built on top of Qt
http://vinipsmaker.github.io/tufao/
GNU Lesser General Public License v2.1
589 stars 179 forks source link

Some prolem with slow connection. Qt 5.4 Win 7 x64 #60

Closed vedun closed 9 years ago

vedun commented 9 years ago

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.

vinipsmaker commented 9 years ago

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