Qt webserver with POST support

  • Hi,
    Currently I am implementing a webserver using the QTcpServer class. The basic feature is working pretty well but now I have to support the management of POST requests. For now, I am able to read the header of the client request, but I can't have access to the variables attached to it. Is there any way to implement this feature using Qt?

    I really appreciate any hint. Thanks!

  • Hi,

    HTTP doesn't define the format of Request body; here you can see an example (after the headers there'a a blank line and after the body).

    This means that, after the header, you'll find a blank line and the body; the format of the body depends on your interface (the most common formats for body are Text, XML and JSON)

    NOTE: if you're writing the server, you have to define the format of the body

    UPDATE: here you'll find more information

  • Thank you so much for your answer. Very handy resources! :D

  • You're welcome,

    Happy coding

  • @xtingray

    I have written a more powerful framework than doing everything from scratch with QTcpServer, might check it out here:


    And here are examples how to easily use it in your project:


    Not only does it handle all kind of methods, but also decodes form data and support https out of the box. I wrote it originally to suit my needs, but it has evolved since, so I have have cleaned up the code and generalized it for others to be used.

  • Damn it! I was looking for something like this and just found it when I already implemented what I need. Will be your class QtWebServer a future native component of Qt?

    Anyway, nice to see this kind of resources for future developments. Great contribution, congratulations! :)

  • @xtingray
    I think that currently it's not close to being ready for integration into the official framework, but it is optionally being distributed through qt-pods (a standardized package system for smaller, inofficial Qt extensions). See here for more info:


    The aim of qt-pods (inspired by cocoapods from MacOS) is to have foreign code included in your project with a single click through standardized means. It's in early stage though.

  • I had no idea about the qt-pods. Thank you for the handy information. It's incredible how I am learning things every time I check this forum XD

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.