summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Fix linkage error in QFutureInterface<QHttpServerResponse>::takeResultHEADmasterMikhail Svetkin2020-07-022-23/+28
| | | | | | | | | | The error: QtPrivate::ExceptionStore::throwPossibleException already defined in QHttpServerFutureResponse. Task-number: QTBUG-85191 Change-Id: I055b2aa563cbde7d01309a01fa59d4283c9c2e36 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Introduce QHttpServerFutureResponseMikhail Svetkin2020-06-1110-34/+413
| | | | | | | Provide simple API for asynchronous resoponses Change-Id: Ic0c92cce95751dc8f9d6b0dfa96e39019f5f5e9e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Don't destory socket and request objects while handling a requestMikhail Svetkin2020-06-064-2/+35
| | | | | | Task-number: QTBUG-84617 Change-Id: Ibf98fb329c817ae39f66e539cdb30a4194cb3b42 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* cmake: Remove unused conditionsMikhail Svetkin2020-05-160-0/+0
| | | | | Change-Id: I15a7bdd80c6bbaab85f2ed10d1e598661eb38a05 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add QHttpServer::afterRequestMikhail Svetkin2020-05-1417-250/+643
| | | | | | | | 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>
* tst_qhttpserver: Add expected warning messagesMikhail Svetkin2020-05-142-1/+7
| | | | | Change-Id: Iffbde346b6e8454dc9e8b19d96e8a4a4e860f1e2 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* gitignore: add object_script.*Mikhail Svetkin2020-05-061-0/+1
| | | | | | | | | msys2 environment generates - src/httpserver/object_script.Qt5HttpServer.Release - src/httpserver/object_script.Qt5HttpServerd.Debug Change-Id: Ia828cf2cf2aebb8d81992a49ada8af56ab1f7a5f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add cmake support for Qt6/dev branchMikhail Svetkin2020-05-0519-8/+236
| | | | | | Change-Id: Icca0edab01d6028d786b76f99fba388565bd6e76 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add missing QStringBuilder headerMikhail Svetkin2020-05-051-0/+1
| | | | | Change-Id: Idfda1af35ac2b65f202b3b76682a959e946b426f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix Project ERROR: Unknown module(s) in QT: sslserverMikhail Svetkin2020-04-241-3/+2
| | | | | | | It looks like qmake -r does not resolve dependencies correctly. Change-Id: Ifd6bd6cac9af1b5eee249aef99fd32ed68f72a9e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix warning about unused variableMaurice Kalinowski2020-04-241-1/+0
| | | | | Change-Id: I42fdf82516dce4ea504c402981ee4bc969471e7e Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* Add cmake test and remove dead codeMikhail Svetkin2020-04-192-13/+1
| | | | | | | cmake test was removed accidentally 9719bf64bb471b8da10e8a5aa419308e8d3b1238 Change-Id: I96f3717e936256d353816094506c6b48538f0fc8 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* Add dependencies file for CoinMikhail Svetkin2020-04-199-17/+45
| | | | | | | | Coin by default uses dev branch of qtbase. Add 5.12 qtbase into the dependencies file Change-Id: I849ea65e36c74f153dbd5531c01e3a3b00ab4fef Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* Do not disconnect on HTTP CONNECT methodMikhail Svetkin2020-02-263-3/+14
| | | | | | | | | | According HTTP/1.1 specifications (RFC 7231) CONNECT is intended only for use in requests to a proxy. That it is why http-parser sets the upgrade flag. This patch will allow users to decide how to handle this. Change-Id: Ic2d10ca4ab113b4cac85e14f15af7890d5773e98 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Small refactoring of QHttpServerRequest and QAbstractHttpServerMikhail Svetkin2020-02-242-23/+19
| | | | | | | | | | | | 1. Move initialization of httpParser from QAbstractHttpServer to QHttpServerRequest. 2. Simplify access to an upgrade header value from a request. httpParser sets an upgrade flag only if the request has two headers or the request is HTTP CONNECT method. Change-Id: I39c2325558a58679e40d38e46706cd61ef36d327 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* Fix QString::QString(const QByteArray&)’ is deprecatedMikhail Svetkin2020-02-241-2/+2
| | | | | | | | warning: ‘QString::QString(const QByteArray&)’ is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String Change-Id: Ia3901f2a1aeb7a3f241eb3ae4ed2f67da76e57bc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix memory leak in testMikhail Svetkin2020-02-201-5/+5
| | | | | | | | | QTcpSocket was created on heap without a parent and it never called delete. Change-Id: I492633f9797427e546065f9afadf19a672dc552c Reviewed-by: Tasuku Suzuki <tasuku.suzuki@kdab.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make QAbstractHttpServer::listen return 0 on failMårten Nordheim2020-02-185-9/+34
| | | | | | | | | | | | | | | | 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>
* Fix crash when CONNECT method is usedTasuku Suzuki2020-02-132-1/+20
| | | | | | | | | | When the parser received "CONNECT / HTTP/1.1\n\n", its upgrade variable is set to 1 even though there is no "upgrade" header available. In this case, QMap::find() returns its end. Task-number: QTBUG-82053 Change-Id: I41cc23511459c6735a474bb7b903638dd4b1208f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove dependence on QtNetworkPrivate from QSslServerMårten Nordheim2020-02-074-10/+11
| | | | | | | | | Locally I was unable to build QSslServer due to QAbstractSocketEnginePrivate not being exported. Change-Id: I739b63d03d2ff378e03ef3fcd7b1ab55db24f63b Reviewed-by: Tasuku Suzuki <tasuku.suzuki@kdab.com> 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>
* Remove unused local variablesMårten Nordheim2020-02-061-4/+0
| | | | | | | Fixes compiler complaints Change-Id: Ic5923a9a15d7ec9f487d3fe02ec16361eaa4838c Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com>
* qhttpserver: Fix documentation for special argumentsMikhail Svetkin2019-11-211-3/+3
| | | | | | Change-Id: Ibb373e7462220cb678330bb0cb7421407ccb37e3 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Refactor access to QMetaEnum for QHttpServerRequest::MethodMikhail Svetkin2019-11-102-14/+5
| | | | | | | | Replace QHttpServerRequest::staticMetaObject.indexOfEnumerator("Method") with QMetaEnum::fromType<QHttpServerRequest::Method>. Change-Id: Idda142fd065e9ce216e2d76c09a5b19d384df1b3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Refactor QHttpServerRequestPrivate::parseUrlMikhail Svetkin2019-11-101-19/+21
| | | | | | | | | | | | There are few changes: 1. Remove std::function. A lambda can be converted to a function pointer if it does not capture. 2. Change std::map to std::array and mark it as constexpr. It will eliminate run-time initialization and checking. 3. Remove unnecessary nesting Change-Id: I5379cb11016def47aee0c57c3de39677aae072d7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qhttpserverrequest: Change QSharedPointer to QScopedPointerMikhail Svetkin2019-10-292-8/+3
| | | | | | | | And disable copy for QHttpServerRequest since it's not intended to be copy-able. Change-Id: I34ba6929507cc4f020fac52bf36c816b194fd250 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix compilation with gcc 4.8Mikhail Svetkin2019-10-291-2/+2
| | | | | | | | | | GCC 4.8 doesn't like using QPointers in signal connections. Additional to e35fdc4763a54aff3768bcd0144ae97249bd7185. Fixes: QTBUG-79345 Change-Id: Id5677139a31affab737d11e4456f9bf8d174601f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* Allow using QHttpServerRequest/Responder at the same timeMikhail Svetkin2019-10-254-9/+58
| | | | | | Fixes: QTBUG-77088 Change-Id: I2208cee290d086339aba705f959c57e0f6a73a87 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix compilation with gcc 4.8Mikhail Svetkin2019-10-241-4/+4
| | | | | | | | 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>
* QHttpServerRouterViewTraits: Make it simpler and testableMikhail Svetkin2019-10-244-161/+597
| | | | | | | | | | | | | 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>
* Fix memory leak in QHttpServerRequest5.15Sylvain Garcia2019-10-141-1/+1
| | | | | | | | | 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>
* HTTPS supportSylvain Garcia2019-10-0413-50/+512
| | | | | | | | | | | | | | | 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>
* QHttpServerResponse: Extend the APIMikhail Svetkin2019-10-036-17/+358
| | | | | | | | | | | | 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>
* QHttpServerResponse: Change text/html -> application/x-emptyMikhail Svetkin2019-08-222-6/+6
| | | | | | | | | | 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>
* Add QHttpServerLiteralsMikhail Svetkin2019-08-2110-42/+181
| | | | | | | | | | 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>
* QHttpServerResponse: Use rvalue moreMikhail Svetkin2019-08-202-1/+49
| | | | | | Change-Id: I442245dc800a545142f3f28ea51a4465d6eaff84 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHttpServerResponder: refactor and extend the APIMikhail Svetkin2019-08-205-108/+294
| | | | | | | | | | | | | 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>
* QHttpServerResponse: add ctor for QJsonArrayMikhail Svetkin2019-07-113-0/+23
| | | | | | | Task-number: QTBUG-76619 Change-Id: Ibce12e33754e950f467c8fb291d447cfc0694062 Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHttpServerResponse: use compact mode for json objectsMikhail Svetkin2019-07-112-1/+17
| | | | | | Change-Id: Ia01f2f9a1483b326bc92eda20045f9764616cf66 Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add remoteAddress() to QHttpServerRequestTasuku Suzuki2019-07-105-6/+20
| | | | | Change-Id: If72ff6f96a645e86f718d61e57e1f8549f8806da Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QAbstractHttpServer: Simplify handleNewConection/handleReadyReadMikhail Svetkin2019-07-095-50/+44
| | | | | | | | Remove usage of QObjectUserData. Remove usage of QHash of QHttpServerRequest. Change-Id: I8a6c44bcfefc12c841ae67562e9bbec10f6ab9bf 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-1412-1/+91
| | | | | | | | 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>
* Silent -Wdeprecated-declarations warningJesus Fernandez2019-05-211-1/+1
| | | | | | | | | warning: ‘QString::QString(const QByteArray&)’ is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations] # define qPrintable(string) QtPrivate::asString(string).toLocal8Bit().constData() Change-Id: I24fb34c6ed4dd5ebddf92b988e31a01322fc0a57 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io>
* Fix crash for passing lambda with captures to QHttpServer::routeMikhail Svetkin2019-05-152-15/+45
| | | | | | | | | | | | 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>
* Use Qt5TestMacros for run cmake testsMikhail Svetkin2019-05-151-11/+1
| | | | | Change-Id: I54486c20d047b5aa73e6012d43c9ca5019f9a51f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove unused signalMikhail Svetkin2019-05-091-2/+0
| | | | | | Change-Id: I28fb6f9f45e43d21cace1978c03acd330a9e6faa Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qbc.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Change QString for headers in QHttpServerRequest to QByteArrayTasuku Suzuki2019-05-094-14/+15
| | | | | | | | | | 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>
* Remove a member variable unusedTasuku Suzuki2019-05-091-1/+0
| | | | | | Change-Id: Iacb3259742ca1d3e352624d953b5f5581cb72102 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix tests failure introduced by the mime type detectionTasuku Suzuki2019-05-092-25/+25
| | | | | | | | | | 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>