File: simple-example.qdoc

package info (click to toggle)
qt6-httpserver 6.8.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,036 kB
  • sloc: cpp: 7,856; makefile: 20
file content (28 lines) | stat: -rw-r--r-- 1,154 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
\ingroup qthttpserver-examples
\title Simple HTTP Server
\examplecategory {Web Technologies}
\brief Simple example of how to set up an HTTP server.
\image browserwindow.png

This example shows how to set up a server using the QHttpServer class.
The server is bound to a QTcpServer listening to a port with the bind()
function, and the \c route() function is used to add a handler for each
of several different incoming URLs. For one of the URLs, "/auth",
\l{RFC 7617}{Basic HTTP Authentication} is used.

\snippet simple/main.cpp HTTPS Configuration example
In the above example \c QSslConfiguration is used to show how to create
an SSL configuration for a QHttpServer to serve HTTPS traffic.

\snippet simple/main.cpp Using addAfterRequestHandler()
The above example shows how to use the \c addAfterRequestHandler() function of the
QHttpServer to change the QHttpServerResponse object after it has been handled
by the \c route() function. It demonstrates how HTTP headers can be added to the
response.

\example simple
*/