GCC 4.8 doesn't like using QPointers in signal connections.
Fixes: QTBUG-79345
Change-Id: I7cd4d79eee3ce7f07874e13f5ecfa9925090d68d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Currently QHttpServerRouterViewTraits contains all helpers and tools
inside itself. It is hard to read and extend.
This patch:
- Moves all helper and tools to QtPrivate namespace
- Tries to "simplify" template magic
- Adds support for unit test
Change-Id: I6aa443b286c4c896b8dbfee85fffb638328868ad
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Using QSharedPointer rather than raw pointer for private data
[ChangeLog][QHttpServerRequest][Fix QHttpServerRequest memory leak] Fixed: memory leak in QHttpServerRequest
Change-Id: I419ec22e56f199677d058938cee046a60a3c2450
Reviewed-by: Jesus Fernandez <jsfdez@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>
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>
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>
This is because QHttpServerResponder uses QByteArray for headers' key/
value.
Change-Id: I21b5af4d08e43ee58a1edc95b714c6da0ae10790
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Commit 4f64330b39bd528a84241e976baa464c6dc89de1 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>
To avoid using the deprecated QString implicit constructor
Change-Id: If6f29952b0dbec96437e0b940c3cb52a801c0d32
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
The forward declaration and the definition was not matching. Some
were forward declared as class and defined as struct.
Change-Id: I8912e6373e24126befba52df0bef8795299e50f7
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@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>
Provide simple API for routing, parsing, capture and call callback
Change-Id: Ibd7c37282d00bd56f96d841db92b473a65a2bf5c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Allow examples have subfolders for depth more than four
Change-Id: Ia85602393034f68bd9b0214be240d17d1a751e1e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
We have undefined behavior when we check server.method.
Because HttpServer::method was uninitialized.
Also start checking a return value from QTcpServer::listen.
Change-Id: Ib7c31f33be956582a6ef264743ca9e44d4de24b1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Change-Id: I5a79cfc3bab647f9bec29e8b08f9262b211c83b1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
The current implementation has several problems.
1. The function takes an ownership the QIODevice and puts it into a smartpointer.
Also we conntected socket's destroyed signal to lambda which has captured the
smartpointer.
So if responder does not find the file, the smartpointer will
call deleteLater which then will call socket::destroyed and then lambda
will be called and try to access the smartpointer which does not exist
anymore.
2. The function takes an ownership the file(QIODevice)
and puts it into a smartpointer.
Also we conntected the QTemporaryFile's aboutToClose signal to lambda which has captured the
smartpointer.
So when the QTemporaryFile calls destructor it will emit aboutToClose
signal which will call the lambda and this lambda will try to access the smartpointer
which does not exist anymore.
3. If we send a file smaller than chunksize,
IOChunkedTransfer we will never be deleted.
4. Does not check a socket connection type (keep-alive).
5. Does not send anything if file is not found or opened in wrong
mode.
Change-Id: I699e7d5a462c4b8d195908747bf0386132b19973
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
It encapsulates the socket and gives an API to answer the received
requests.
Change-Id: Ic95db2c50224a650a02b206faca9a0ff8d1cc62b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ryan Chu <ryan.chu@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
The compiler will complain the invalid use of incomplete type 'class
QTcpSocket' when calling the functions by the socket pointer. Such as
connect(), isTransactionStarted(), startTransaction(), and disconnect().
When connecting the signals of QTcpSocket (QTcpSocket::readyRead,
QTcpSocket::disconnected), the compiler will complain the incomplete
type 'QTcpSocket' used in nested name specifier.
Change-Id: I0e631218b0446e72b994718850f6886bec979a2d
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>