summaryrefslogtreecommitdiffstats
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
* Correct license for examples filesLucie Gérard2024-03-153-3/+3
| | | | | | | | | | | | According to QUIP-18 [1], all examples file should be LicenseRef-Qt-Commercial OR BSD-3-Clause [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: Ic7efd078b24140fa5e089cd2067c4b5ab1ce9344 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Use QHttpHeaders in QHttpServerResponseLena Biliaieva2024-02-131-4/+7
| | | | | | | | | | | | Added withHeaders() method to pass headers to the QHttpServerResponse object. Removed methods using QHttpServerResponder::HeaderList because it will be also replaced by QHttpHeaders. Added headers() method for convenience. Updated tests and examples. Fixes: QTBUG-107749 Change-Id: Ia9ce631a17b1b60e84ffc85e09215ac262407144 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Use QHttpHeaders in QHttpServerRequestLena Biliaieva2024-02-071-6/+4
| | | | | | | | | QHttpServerRequest::headers() method is changed to return QHttpHeaders. RESTful API Server Example is updated. Task-number: QTBUG-107750 Change-Id: Id6c9c4a051aa05d28fc49357baf1895b40642db4 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Make 'token' HTTP header name comparison case-insensitiveJuha Vuolle2024-01-091-4/+3
| | | | | | | | | | | | HTTP header names are case-insensitive. With the new QHttpHeaders class in use at the client-side (the colorpaletteclient app in qtdoc), the request will contain a lower-cased 'token' header => change the server-side to ignore casing Pick-to: 6.7 Task-number: QTBUG-114649 Change-Id: I69b52325017721c8d50fa3ea129802c93b2e521a Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Brush up the simple exampleFriedemann Kleint2023-03-243-30/+45
| | | | | | | | | | | | | | - Use per-class includes - Use modern string literals and avoid .arg() for simple cases - Return non-0 exit code in case of errors - Use qWarning()/qInfo() - Make it a console example (qmake) - Update the logo to neon Pick-to: 6.5 Task-number: QTBUG-110895 Change-Id: Ie62eb3787ac3f6d38c9274270d8f59e7e54b1480 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* simple example: Inline assets_resource_files in CMakeLists.txtIevgenii Meshcheriakov2023-02-201-7/+3
| | | | | | | | | There is no need to introduce a variable to use it only once. Task-number: QTBUG-110895 Pick-to: 6.5 Change-Id: I9781ca5aca91be1e55e6feeaac65dde9cc99381b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Examples: Call qt_standard_project_setup() in CMakeLists.txtIevgenii Meshcheriakov2023-02-202-0/+4
| | | | | | | Task-number: QTBUG-110895 Pick-to: 6.5 Change-Id: I5e1c46675f8cbe25c13754a517521341dc63d9e2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* simple example: Remove QRC fileIevgenii Meshcheriakov2023-02-092-8/+3
| | | | | | | | | Use resource file names directly inside the .pro file. Task-number: QTBUG-110895 Pick-to: 6.5 Change-Id: I30b30c1ccd576bf7a3f50fd88f631c21ddf5791b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* colorpalette: Remove qrc fileIevgenii Meshcheriakov2023-02-092-20/+20
| | | | | | | | | | | | | | Specify resources directly in the qmake project file instead. This is consistent with the specification in CMakeLists.txt. Also specify HEADERS in the qmake project file. Task-number: QTBUG-110895 Pick-to: 6.5 Change-Id: Ic491917d47066e31639a6a8d94b3a567ee6d6766 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* examples: Integrate 'afterrequest' example into 'simple' exampleIevgenii Meshcheriakov2023-02-086-85/+7
| | | | | | | | | Task-number: QTBUG-110895 Pick-to: 6.5 Change-Id: Ia44cdb14f2a6e16ca2b5a135b8252384f5465bea Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Few example build improvementsJuha Vuolle2023-01-315-1/+27
| | | | | | | | | | - Simple example to build without SSL - Link example apps against Gui on Android Pick-to: 6.5 Change-Id: I30f35f9c86b617aea95c0099abab3fc2d62f0535 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Refactor AddressBook server to be compatible with the reqres.inKonrad Kujawa2023-01-3026-195/+880
| | | | | | | | | | | | | Remove AddressBook example, instead create ColorPalette example. ColorPalette is based on reqres.in, and it contains static assets like colors, users, sessions JSON and avatar images to preload to server upon start. Pick-to: 6.5 Fixes: QTBUG-106040 Change-Id: I5edec8d26f11809782d5d40d8e2c15143617eeb9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* addressbookserver: Use X-API-Key as the authentication headerIevgenii Meshcheriakov2023-01-061-1/+1
| | | | | | | | | | | | | | | | | | Non-standard headers must start with "X-". The header check was also made case-insensitive to match behavior of the standard headers. Added documentation snippet showing how to create entries using curl. Fixed JSON syntax in the documentation. Use \badcode blocks for non-C++ code examples. Fixes: QTBUG-107927 Pick-to: 6.5 Change-Id: I48fc171fe32164541d777e4dae5747683aba37ad Reviewed-by: Luca Di Sera <luca.disera@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Rename addressbook example directory to match the example nameIevgenii Meshcheriakov2022-11-083-0/+1
| | | | | | | | | | | Also actually build the example and rename the example in the documentation. Pick-to: 6.4 Change-Id: I9c403ceed1562728f8f280d3412f6fb2c3b2a0f4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add missing functionalities to RESTful Address Book serverKonrad Kujawa2022-08-302-45/+74
| | | | | | | | | Added server side basic authorization. Fixes: QTBUG-105196 Pick-to: 6.4 Change-Id: Ia73ec2779da6615ef23e253f0ccf28853c78875b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-254-4/+4
| | | | | | Task-number: QTBUG-105718 Change-Id: I6817ba90abea4ea72ad9d58bd17c825a38abb07f Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* REST server endpoint in QHttpServer for an Address book exampleKonrad Kujawa2022-08-152-0/+165
| | | | | | | | | Add an address book implementation example using QHttpServer. Task-number: QTBUG-105198 Pick-to: 6.4 Change-Id: I72d88a4814425cfc94601f4c7955ca8b395b8ede Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Provide an example covering the HTTPS functionalityKonrad Kujawa2022-08-095-4/+120
| | | | | | | | | | | | Extend QHttpServer simple example by adding SSL configuration that serves HTTPS requests. Change Qt::HttpServer linking to private. Fixes: QTBUG-105073 Pick-to: 6.4 Change-Id: I2da8d8e4418eac171494ccf7716fe8369d81020e Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* CMake: Cosmetic cleanupKai Köhne2022-08-082-4/+4
| | | | | | | | | Prefer Qt6::HttpServer vs Qt::HttpServer (we don't expose all information in Qt::HttpServer). Also, use PRIVATE linking by default. Pick-to: 6.4 Change-Id: I3f6cce21cf124067321aa5b8bb17d3fa44a21501 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* QHttpServerRequest: Make headers() return a QtNetwork compatible typeIevgenii Meshcheriakov2022-07-291-1/+1
| | | | | | | | | | Return QList<QPair<QByteArray, QByteArray>> instead of QVariantMap. Task-number: QTBUG-100868 Pick-to: 6.4 Change-Id: I05da8b3ea15f1b7037d625c4d0ea320fca3e1016 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-073-0/+9
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I4463e3d03c18748e9a03320261b7f6efcdbd43f8 Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* CMake: Take preconfigured INSTALL_EXAMPLESDIR into accountKai Köhne2022-06-292-2/+10
| | | | | Change-Id: I0fbfcde2c98a27126424c8a5d830cef1d96c134c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Clean up CMakeLists.txt in examplesKai Köhne2022-06-294-23/+3
| | | | | | | | | * Remove "# Generated from" comments * Remove unneeded CMAKE_AUTOXXX variables * Prefer unversioned CMake commands Change-Id: I0671ffba98c4da781faa638bb70ae19555744619 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* CMake: Use find_package(Qt6 REQUIRED ...)Kai Köhne2022-06-292-2/+2
| | | | | | | | This will make sure find_package explicitly fails if HttpServer component is missing. Change-Id: Ibda6059b77411cf482a747a16c97c178ea4f8563 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* Use SPDX license identifiersLucie Gérard2022-06-222-99/+5
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I657c36f679b9448ec68d411a492171bc39df1411 Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* examples: Add an example of using Basic authenticationIevgenii Meshcheriakov2022-03-291-0/+22
| | | | | | | Fixes: QTBUG-75084 Change-Id: Ic898db9ebed5d30d460c07bc0b54bf3f67031a02 Reviewed-by: Jesus Fernandez <jsfdez@gmail.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Switch examples to build as isolated sub-builds part 2Alexandru Croitor2022-02-051-1/+1
| | | | | | | | | | | | | | qt_examples_build_begin needs the EXTERNAL_BUILD flag to know that it's safe to build examples as ExternalProjects. It still won't do it in CI until we enable building examples as ExternalProjects for prefix builds. This is preparation for that. Task-number: QTBUG-90820 Change-Id: Ifa72ee29d7515b585314caef47a0d8817910c186 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Switch examples to build as isolated sub-buildsAlexandru Croitor2021-12-151-2/+2
| | | | | | Task-number: QTBUG-90820 Change-Id: I8ee6372f9cb503207b0e63549b74b7d70db5dcf8 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Bump almost all cmake_minimum_required calls to 3.16Alexandru Croitor2021-09-222-2/+2
| | | | | | | | | | | Needed for subsequent change that will check and error out if the version is lower than 3.16. We do that to ensure all policies introduced by CMake up to version 3.16 have their behavior set to NEW. Task-number: QTBUG-95018 Change-Id: Iebd35ee1643c022a9358f51c76b7b52d1da9b5f1 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* CMake: Fix build with Qt 6.1/6.2Alexandru Croitor2021-08-122-2/+2
| | | | | | Change-Id: I7f10d37a347b982d904024ebb583ad4d9628769c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Add QHttpServer::afterRequestMikhail Svetkin2020-05-145-0/+122
| | | | | | | | This function allows to register a function to be run after each request. Task-number: QTBUG-77090 Change-Id: I40dd4c1e9a447fbe034149ffc1923c7c814cf0e9 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* Add cmake support for Qt6/dev branchMikhail Svetkin2020-05-053-0/+50
| | | | | | Change-Id: Icca0edab01d6028d786b76f99fba388565bd6e76 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Make QAbstractHttpServer::listen return 0 on failMårten Nordheim2020-02-181-2/+2
| | | | | | | | | | | | | | | | Which then makes it compatible with other listen() functions in Qt in the sense that doing if (server.listen()) will behave consistently. Ports being listened to can then be gotten from the new serverPorts() function, mirroring serverPort() from QTcpServer etc., except it's a QVector. This is a source incompatible change, but is allowed because this module is still in tech preview. Fixes: QTBUG-79411 Change-Id: I09764afbf8fd866af4f43ab90fcf9c2e9a373237 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* Allow simple example to be built without gui moduleTasuku Suzuki2020-02-071-1/+1
| | | | | | | Change-Id: I173e418eb03dc471e64284f89182bbb1b2806d88 Reviewed-by: Jesus Fernandez <jsfdez@gmail.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* Add remoteAddress() to QHttpServerRequestTasuku Suzuki2019-07-101-0/+4
| | | | | Change-Id: If72ff6f96a645e86f718d61e57e1f8549f8806da Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Example: add 'cmdline' to CONFIGMårten Nordheim2019-07-081-0/+2
| | | | | | | | | So it doesn't detach from command line on Windows, and doesn't generate app bundles on macOS. Change-Id: I0449b1224b9c01f2f040ac98508732f9d280ee3b Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io> Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* Introduce QHttpServerResponse::fromFile()Tasuku Suzuki2019-06-144-0/+12
| | | | | | | | This is a shortcut for static file contents. Change-Id: I54d97c60822e661c1405f27ea8d4598f0363b144 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Introduce QHttpServerMikhail Svetkin2019-01-254-0/+138
QHttpServer provides a simplified interface to QAbstractHttpServer and QHttpServerRouter. Change-Id: I884204aa8140bbab4c0d6a8ab4c798e0b2470e29 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>