Commit Graph

22 Commits

Author SHA1 Message Date
Ievgenii Meshcheriakov 2cd9c66a25 tests: Use _ba instead of QByteArrayLiteral
Pick-to: 6.4
Change-Id: I8d41e169cd3dd489d8de54aeed052ff6a9e3edc3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-08-08 18:01:00 +02:00
Ievgenii Meshcheriakov 6d6bc92207 QAbstractHttpServer: Return unique_ptr from nextPendingWebSocketConnection()
This makes the ownership transfer visible from the API.

Task-number: QTBUG-100868
Pick-to: 6.4
Change-Id: Ie07dd3fd442837c87b6612da8a094bd880b6574f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-07-29 13:08:51 +00:00
André Klitzing 04803095e5 Use handleRequest and missingHandler for WebSockets, too
This allows to deny a websocket upgrade with e.g.
a HTTP error ServiceUnavailable instead of hard
disconnection if the application has some special
logic.

Also fire missingHandler for WebSockets for
better application integration.

Pick-to: 6.4
Change-Id: I31f4b66f9a9a7873a46d0eaba6b6121b1a9ac953
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2022-07-08 13:47:01 +02:00
Lucie Gérard 57b0db0896 Use SPDX license identifiers
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>
2022-06-22 17:35:22 +02:00
Marc Mutz 6fa185164a Fix QLatin1String usage
- 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>
2022-06-22 10:15:24 +02:00
Maurice Kalinowski 51734cd595 Fix build against 6.0
Fixes: QTBUG-89381
Change-Id: I79d0329f06005434c691416f92fbdac0d7252385
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
2020-12-16 19:10:36 +01:00
Mikhail Svetkin 4b2790aa6d Add cmake support for Qt6/dev branch
Change-Id: Icca0edab01d6028d786b76f99fba388565bd6e76
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-05-05 19:43:56 +02:00
Mikhail Svetkin a65cc1fa6e Do not disconnect on HTTP CONNECT method
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>
2020-02-26 12:53:15 +01:00
Mikhail Svetkin 68a4458a7b Fix memory leak in test
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>
2020-02-20 08:26:05 +01:00
Mårten Nordheim 93ff67a3fc Make QAbstractHttpServer::listen return 0 on fail
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>
2020-02-18 12:17:22 +01:00
Tasuku Suzuki 4b87afbbe6 Fix crash when CONNECT method is used
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>
2020-02-13 20:37:43 +09:00
Mikhail Svetkin fb551f9845 QAbstractHttpServer: Simplify handleNewConection/handleReadyRead
Remove usage of QObjectUserData.
Remove usage of QHash of QHttpServerRequest.

Change-Id: I8a6c44bcfefc12c841ae67562e9bbec10f6ab9bf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-07-09 20:33:56 +02:00
Jesus Fernandez d542f7e13d Add a fork() test
Change-Id: Ic7c797f9757ad14803154f6125298bfc8fe03baa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2019-04-29 13:00:23 +00:00
Jesus Fernandez 11fb154a84 Fix several build issues and fix the unit tests
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>
2019-02-28 09:47:48 +00:00
Jesus Fernandez db45e5a9fa Use QStringLiteral
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>
2019-02-12 08:42:09 +00:00
Jesus Fernandez fe96330ca0 Fix license headers
Change-Id: Ie15244adb917e2938fe7897c30d4616218d26ac0
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-01-31 11:31:21 +00:00
Mikhail Svetkin 9a41ddd648 Fix tst_QAbstractHttpServer::request
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>
2018-12-20 14:08:08 +00:00
Mikhail Svetkin 0763423618 Fix build the test without the websocket support
Change-Id: If32f6a7a42258f9a5a8bed15c776ffa18240da24
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2018-12-20 14:08:00 +00:00
Tasuku Suzuki 7df45b8ea6 Refactor QAbstractHttpServer::servers()
Change-Id: I11e7100dd5f25d6c02bef28f4c53ce3acc257390
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
2018-10-22 01:26:44 +00:00
Mikhail Svetkin 232a3047f5 Remove unused QNetworkReply
Change-Id: I536226270db1534b0bda1a2205898c291285721a
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-07-20 08:46:07 +00:00
Mikhail Svetkin cccece0a61 Fix inccorect parsing url with spaces
Change-Id: I942bd80cf3cefaa9f0194ce3281640a3b5077ed2
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
2018-07-18 11:03:33 +00:00
Jesus Fernandez b24745265d Introduce Qt HttpServer framework
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>
2018-07-16 14:36:08 +00:00