PySide6.QtHttpServer¶
- PySide6.QtHttpServer.QAbstractHttpServer
- PySide6.QtHttpServer.QFutureHttpServerResponse
- PySide6.QtHttpServer.QHttpServer
- PySide6.QtHttpServer.QHttpServerRequest
- PySide6.QtHttpServer.QHttpServerResponder
- PySide6.QtHttpServer.QHttpServerResponse
- PySide6.QtHttpServer.QHttpServerRouter
- PySide6.QtHttpServer.QHttpServerRouterRule
- PySide6.QtHttpServer.QHttpServerWebSocketUpgradeResponse
Detailed Description¶
Provides a lightweight server implementing the HTTP protocol.
Qt HTTP Server supports building HTTP server functionality into an application. Common use cases are exposing the application’s functionality through REST APIs, or making devices in a trusted environment configurable also via HTTP. The limitations are described in Limitations & Security .
Overview¶
Qt HTTP Server provides building blocks for embedding a lightweight HTTP server based on RFC 2616 in an application. There are classes for the messages sent and received, and for the various parts of an HTTP server.
An HTTP server can be created by subclassing the QAbstractHttpServer
class and overriding the handleRequest()
function. The QAbstractHttpServer
class provides functions for binding to an existing QTcpServer, QSslServer, or QLocalServer. Dispatching to callables based on incoming URLs can be simplified by using the QHttpServerRouter
class.
This can be simplified even further by using the QHttpServer
class. The QHttpServer
class is a subclass of QAbstractHttpServer
and defines an overloaded route function to bind callables to different incoming URLs, and an addAfterRequestHandler()
function to process the response further.
Runtime logging can be configured as described here .
Limitations & Security¶
Qt HTTP Server does not have many of the more advanced features and optimizations that general-purpose HTTP servers have. It also has not seen the same scrutiny regarding various attack vectors over the network. Use Qt HTTP Server, therefore, only for local connections or in a trusted network, and do not expose the ports to the internet.
You can add HTTPS support as a basic security measure, though. If Qt is compiled with support for TLS, you can bind QAbstractHttpServer
and its subclasses to a QSslServer object, providing Transport Layer Security handling.
Licenses¶
Qt HTTP Server is available under commercial licenses from The Qt Company . In addition, it is available under the GNU General Public License, version 3. See Qt Licensing for further details.