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>
When QT_NO_SSL is used, the value of QT_FEATURE_ssl is also defined to
'-1' in qtnetwork-config.h. The "#if defined(QT_FEATURE_ssl)" block will
be compiled, and then it implies that 'QSslSocket' was not declared in
this scope.
The QT_CONFIG macro implements a compile-time check for features of Qt.
If QT_FEATURE_ssl is '0' or undefined, QT_ CONFIG(ssl) will lead to a
compile error. If QT_FEATURE_ssl is '-1' (unavailable), the
constant-expression of QT_ CONFIG(ssl) will be false.
Change-Id: I80bef731e8246f9206601527435a43195989331b
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>
Change-Id: I6d0c6e9f4bbdf203fb29ae611e064aa284d52ebe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Change-Id: I536226270db1534b0bda1a2205898c291285721a
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
It allows knowing the server port in case the user chooses to use a
random port. In the previous implementation listen() was returning a
boolean value making it impossible to know the port number.
Change-Id: I73384188b3b2eb57816eb6c6c9a7ac1a511b7456
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
qhttpserverrequest.cpp: In function ‘QDebug operator<<(QDebug, const http_parser*)’:
qhttpserverrequest.cpp:70:89: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers]
debug.nospace() << "http_parser(" << reinterpret_cast<const void * const>(httpParser) << ": ";
Change-Id: Idf1e92d19033e58634638f3c1a1ccf3a9c3b81d8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Small, Qt integrated framework for creating specialized http server.
Goals of the project:
- Create a framework allowing creation of a specialized web server
running in non public networks (home and company networks, stealth
or hidden services)
- Create an easy tool for developers to embed http servers in their
apps.
- Playground to narrow down problems in Qt, related to network
stack, but also to explore general usability.
- Potentially reduce code duplication in Qt.
Not goals:
- Standalone server, in particular not Apache or nginx replacement
Change-Id: I0d8b83e50992b9a95c88f4735539329279cf5425
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>