Generates less code, and we may be able to remove QDebug includes.
Some uses aren't easily ported, leave them as ostream-style.
Also prefer %ls/qUtf16Printable() over %s/qPrintable() (again: less
code).
Pick-to: 6.4
Task-number: QTBUG-100868
Change-Id: I812bed2ecfeb5776155ff5f95320d6accc5974d3
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
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>
- in route() implementations, the viewHandler was passed by universal
reference, however, it was then captured either by value (copying,
which some viewHandlers may not support) or - yuck - by reference,
creating a dangling pointer in case a temporary was passed. This
error was also present in the example implementations in the docs
and the test. To fix, std::forward the viewHandler into the mutable
lambda and std::move() it inside the lambda into
route.bindCaptured().
- One more case of RouterHandler being passed by rvalue ref and then
std::forward()ed, fixed by taking by value and std::move()ing
instead.
Pick-to: 6.4
Task-number: QTBUG-100868
Change-Id: I729f7e0c8fd0838679bcefc141fd5cea333d276b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
- replace with QLatin1StringView
- take by value, not by cref
- in one case, replace with a char16_t, because size() == 1
Pick-to: 6.4
Task-number: QTBUG-100868
Change-Id: Ib1d9c3058d3dc9aad560b27bda89b7dc1f897dbb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Always ignore the same set of errors instead. At least on macOS it
is possible to compile Qt with OpenSSL support but don't have it
at runtime.
Fixes: QTBUG-100479
Change-Id: I213de297f840e6ef344fc87317103a9766f0598b
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Current openssl versions do not accept secret keys shorter than
2048 by default. This causes tests with 1024 bytes key to fail.
This commit replaces the certificate/key pair with new one with
the key length of 4096 that should be good enough for some time.
Fixes: QTBUG-100479
Change-Id: I185812e867eae2c6295cb28df229785f91fc99f2
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Provide simple API for asynchronous resoponses
Change-Id: Ic0c92cce95751dc8f9d6b0dfa96e39019f5f5e9e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
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>
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>
Added new `QAbstractHttpServer::sslSetup` which enables HTTPS usage.
Added new `QSslServer` which inherits from `QTcpServer` and configures
incoming TCP clients to use SSL.
[ChangeLog][QHttpServer][Https support] Https support added to
QAbstractHttpServer class
Change-Id: I536cf48b86b246e3f4b9d960f793b93670afe06f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Guy Poizat <gerrit.qt@gmail.com>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
Add new API for HTTP headers manipulations.
Add QHttpServerResponse::write function which will
allow to write custom response objects in a future.
Fixes: QTBUG-76933
Change-Id: I744303be1b517c07f698c4a3dd2c4296f77e3b03
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@tqcs.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
It does not make sense to set "text/html" as content type for empty
responses.
Change-Id: I93f540c97cef38409f1479f1c332349155edd176
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io>
Currently we have a lot of duplication of most common HTTP headers and their
values.
This patch moves them to one place.
Change-Id: Idf9ddc5164e81649b4cc37ed92a516eb1eedab3a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io>
Currently QHttpServerResponder is not flexible enough:
- Does not allow to rewrite headers
- Does not allow to write headers without storing them internaly first
- Does not provide API to make your own HTTP response
This patch will help to implement QHttpServerResponse
setHeaders/addHeaders
Change-Id: If9e21f7f7a58629bfedad0f10cab67d67fce0a89
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
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>
QHttpServer::route accepted the lambda by universal reference, but did
not pass it to QHttpServerRouter::addRule by std::forward.
We can not initialize lambda captures with C++11.
So we always need to copy the lambda by value.
Task-number: QTBUG-74882
Change-Id: I3e2dc6003624414d0ff45ba2e2f1af472e219ff1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Commit 4f64330b39 changes some mime types
of responses to text/plain.
The commit also FIXED the "No newline at end of file" warning in a test
data for QHttpServerResponder.
Change-Id: I9b6b1878a2b61bf80db1e39b81ae75c4cedce615
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
QByteArray can be used for any data that QMimeDatabase understands
Change-Id: I17d8f0060065c0a93fc4a8cf6450bdd11aed49d0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
QAbstractHttpServer did not clear a request's internal properties (headers,
url, body).
If a request has a keep-alive header, QAbstractHttpServer should clear the
request's internal properties.
Change-Id: I2dfd0565369bd3291cd8d9900045c5a7f9d43ca3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
It is required to have continuous integration enabled in the
repository.
Change-Id: I71728a6e89841640e77c50a05cf59f34d697f897
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
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>