HttpServer is a C++ library that uses the Qt platform to setup a feature rich, easy-to-use HTTP server.
Two existing Qt HTTP server libraries exist out there already, but the licenses are more restrictive (GPL & LGPL), so I decided to create my own:
- Single-threaded with asynchronous callbacks
- HTTP/1.1
- TLS support
- Compression & decompression (GZIP-only)
- Easy URL router with regex matching
- Form parsing (multi-part and www-form-urlencoded)
- Sending files
- JSON sending or receiving support
- Custom error responses (e.g. HTML page or JSON response)
There are two variants of this library, one with and without promise support. Promises allow for easier & cleaner development with asynchronous logic. The two variants are supported via separate branches:
- master - No promise support
- promises - Promise support
Note: The variant without promise support is considered deprecated and will only be supported via bug fixes in the future. For new development, promises are encouraged. The code will remain in two separate branches until sufficient unit testing & documentation is provided for promises support. If you would like to help, please contribute!
- Qt & Qt Creator for IDE
- zlib
- OpenSSL binaries for TLS support (see here)
- Open
HttpServer.pro
in Qt Creator. - Create a
common.pri
file in the top-level directory. This will store any specific include & library paths on a per-machine basis.- Append paths to your
zlib
build withINCLUDEPATH
andLIBS
- Make sure on Windows that the compiled zlib DLL is in your environment
PATH
variable
- Append paths to your
- Build and run the application
- Building the application will build the shared library as well as the test application. When you press run, it will run the test application in which you can experiment with the library via the provided URLs
Note: Since this is just a normal Qt project with a pro
file, you can compile the project via the command-line with qmake
and your platform-specific compiler (i.e. make
for Linux or nmake
for Windows).
See here for example code using HttpServer.
- TLS session resumption is not supported by Qt currently
Pull requests are welcome (and encouraged) for any or all issues!
HttpServer has an MIT-based license.