summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a fork() testJesus Fernandez2019-04-291-0/+58
| | | | | | Change-Id: Ic7c797f9757ad14803154f6125298bfc8fe03baa Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Find proper mime type for QByteArray dataTasuku Suzuki2019-04-2612-7/+178
| | | | | | | | | | 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>
* Fix support for keep-alive connectionMikhail Svetkin2019-04-084-3/+72
| | | | | | | | | | 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>
* Accept a string as request method in QHttpServer::route()Mikhail Svetkin2019-04-046-5/+170
| | | | | | | | | | | | | | | Allow writing simpler source code. For example: httpserver.route("/", "GET|POST", [] () { return ""; }) Instead of: httpserver.route("/", QHttpServerRequest::Method::Post | QHttpServerRequest::Method::Get, [] () { return ""; }) Change-Id: Id0a754eccaba6b5f9f3be6a3b975383eb94840a0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix HTTP chunked request body handlingMikhail Svetkin2019-04-032-3/+50
| | | | | | Task: QTBUG-74843 Change-Id: I4978c80195246c99a5e6d1e608b3980f56b39207 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
* Reuse HTTP status codes from nodejs http-parserMikhail Svetkin2019-04-021-63/+5
| | | | | | Change-Id: Id5f224ff797a56e379ec37c6f57ccd422b098f16 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use multi-arg version of QString::argJesus Fernandez2019-03-191-4/+4
| | | | | | Change-Id: Ib16a2c3feee10bbd9c784c5303fc0e4e97e5ef5b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Allow use of custom data structures as router callback argumentsMikhail Svetkin2019-03-064-6/+114
| | | | | | | | Change-Id: I6dcc66a95b72bb461f237cade0352a0177065227 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix build on WindowsMaurice Kalinowski2019-02-281-0/+1
| | | | | | Change-Id: I7bb287dedfc146ba717a69170cec529d7ef7fadb Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix several build issues and fix the unit testsJesus Fernandez2019-02-2821-127/+106
| | | | | | | | | | 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>
* Use QStringLiteralJesus Fernandez2019-02-121-1/+2
| | | | | | | | | 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>
* Update http-parser submodule to version 2.9.0Jesus Fernandez2019-02-082-0/+1
| | | | | | | Change-Id: I965ecc876213e91ebd57faae676334a1fb14efc2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
* Fix license headersJesus Fernandez2019-01-3129-448/+842
| | | | | | Change-Id: Ie15244adb917e2938fe7897c30d4616218d26ac0 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix -Wmismatched-tags warningsJesus Fernandez2019-01-303-3/+6
| | | | | | | | | 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>
* Fix buildJesus Fernandez2019-01-303-2/+4
| | | | | Change-Id: I9a4e3f9c3bea160af4affbda600ee292cb131a13 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Introduce QHttpServerMikhail Svetkin2019-01-2517-0/+1238
| | | | | | | | | 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>
* Introduce QHttpServerRouterMikhail Svetkin2019-01-2313-15/+1336
| | | | | | | | | 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>
* Update .gitignoreMikhail Svetkin2018-12-201-6/+0
| | | | | | | Allow examples have subfolders for depth more than four Change-Id: Ia85602393034f68bd9b0214be240d17d1a751e1e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix tst_QAbstractHttpServer::requestMikhail Svetkin2018-12-201-2/+2
| | | | | | | | | | 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>
* Fix build the test without the websocket supportMikhail Svetkin2018-12-201-1/+2
| | | | | Change-Id: If32f6a7a42258f9a5a8bed15c776ffa18240da24 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add .gitignoreMikhail Svetkin2018-12-201-0/+159
| | | | | Change-Id: I6e22ef8fa4f906e3e2fd0803b2cb2d8b8334d37a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix CMake testsJesus Fernandez2018-10-223-4/+67
| | | | | | Change-Id: I5a79cfc3bab647f9bec29e8b08f9262b211c83b1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Refactor QAbstractHttpServer::servers()Tasuku Suzuki2018-10-222-9/+19
| | | | | Change-Id: I11e7100dd5f25d6c02bef28f4c53ce3acc257390 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
* Fix compile error: "redefinition; different linkage"Mårten Nordheim2018-10-181-1/+1
| | | | | | | | | qhttpserverrequest.cpp(56): error C2375: 'operator <<': redefinition; different linkage Change-Id: I3fa4c058030e9f81f9c914af10cf740a546a90cc Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
* Don't depend on QtGuiMårten Nordheim2018-10-181-1/+1
| | | | | | Change-Id: I1d3f51d6694a4fa050b6e716b814df17b0c39fc9 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
* Refactor QHttpServerResponder::write(QIODevice, ...)Mikhail Svetkin2018-10-044-31/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Introduce QHttpServerResponderJesus Fernandez2018-09-269-2/+865
| | | | | | | | | | 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>
* Fix build error about missing QTcpSocket header fileRyan Chu2018-08-221-0/+1
| | | | | | | | | | | | | | 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>
* Fix build error when SSL configuration is disabledRyan Chu2018-08-221-2/+2
| | | | | | | | | | | | | | | | | 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>
* Reduce project dependenciesJesus Fernandez2018-07-231-1/+1
| | | | | Change-Id: Ic693da5fb70e3352a06ca4f42643ee3b1f7c2625 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Allow build tst_qabstracthttpserver without qtConfig(private_tests)Mikhail Svetkin2018-07-201-1/+0
| | | | | | Change-Id: I6d0c6e9f4bbdf203fb29ae611e064aa284d52ebe Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
* Remove unused QNetworkReplyMikhail Svetkin2018-07-201-2/+1
| | | | | | Change-Id: I536226270db1534b0bda1a2205898c291285721a Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Fix Qt code styleMikhail Svetkin2018-07-201-7/+9
| | | | | Change-Id: Ie2a5eb3cbfce8742ebdd5973078a665463306466 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
* Return the server port in listen()Jesus Fernandez2018-07-192-6/+8
| | | | | | | | | | 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>
* Fix inccorect parsing url with spacesMikhail Svetkin2018-07-182-1/+4
| | | | | Change-Id: I942bd80cf3cefaa9f0194ce3281640a3b5077ed2 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
* Fix compilation warningMikhail Svetkin2018-07-171-1/+1
| | | | | | | | | 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>
* Allow inherits from QAbstractHttpServer with custom private classMikhail Svetkin2018-07-163-2/+9
| | | | | Change-Id: I35ba1c7cf460d51beecad3427976f1e8a710aef0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add Qt namespaceJesus Fernandez2018-07-161-0/+4
| | | | | Change-Id: I0693da9b8d3b71dfc820899b2be5da0697414ade Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add public headerJesus Fernandez2018-07-161-0/+2
| | | | | Change-Id: Id475a420d783008675ac71fd883035682644603d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Introduce Qt HttpServer frameworkJesus Fernandez2018-07-1622-0/+1269
| | | | | | | | | | | | | | | | | | | | 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>
* Initial empty repositoryOswald Buddenhagen2018-02-020-0/+0