summaryrefslogtreecommitdiffstats
path: root/src/network/access/http2
Commit message (Collapse)AuthorAgeFilesLines
* Fix -Wimplicit-fallthrough for clangTim Blechmann2024-03-011-0/+1
| | | | | | | | | | | | | | | | | | | Clang's `-Wimplicit-fallthrough` warnings are a little stricter than gcc's interpretation: switch (i) { case 0: foo(); case 4: break; } While gcc accepts the implicit fallthrough, if the following statement is a trivial `break`, clang will warn about it. Pick-to: 6.7 Change-Id: I38e0817f1bc034fbb552aeac21de1516edcbcbb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Http2: don't barf on > 4GiB cumulative headersMarc Mutz2024-01-291-2/+2
| | | | | | | | | The only user of the vector passes begin()/end() to BitIStream, which appears to be 64-bit-clean. Pick-to: 6.7 Change-Id: I4ad0b9e9547008fecc4c816cc92ff9db4b2066e3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Network: Use QHttpHeaders in QHttpHeaderParserLena Biliaieva2024-01-251-8/+7
| | | | | | | | | | | | | QHttpHeaderParser::headers() method is changed to return QHttpHeaders. QAuthenticatorPrivate::parseHttpResponse() method is changed to work with QHttpHeaders. QHttpNetworkHeader::header() method is updated to return QHttpHeaders. Tests are updated. Task-number: QTBUG-120133 Change-Id: I20a18b509acd7a8b8d93884cff8349519d64293e Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
* QH2Connection: Fix issue with unity-build/odrMårten Nordheim2024-01-182-0/+46
| | | | | | | | | | The static function appeared in two places, and in a unity-build this fails quite visibly. Pick-to: 6.7 Change-Id: I60000d01194a2c79ca9c101f2a6d3f77f469f1a7 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Nodir Temirkhodjaev <nodir.temir@gmail.com>
* Privately introduce QHttp2ConnectionMårten Nordheim2024-01-172-13/+18
| | | | | | | | | | | | | | | For use in QtGRPC. There is some duplication between this code and the code in QHttp2ProtocolHandler. But let's not change the implementation of the protocol handler after the 6.7 beta release. Nor do I think we should do it for 6.8 LTS. So let's just live with the duplication until that has branched. Pick-to: 6.7 Fixes: QTBUG-105491 Change-Id: I69aa38a3c341347e702f9c07c27287aee38a16f2 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Http2: move assemble_hpack_block declaration to headerMårten Nordheim2024-01-082-0/+30
| | | | | | Pick-to: 6.7 Change-Id: I5033d433d2aa499007a6e436dbb70d9c48315e8b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* HPack: fix incorrect integer overflow checkMarc Mutz2023-12-131-1/+3
| | | | | | | | | | | | | | | | | | | | This code never worked: For the comparison with max() - 32 to trigger, on 32-bit platforms (or Qt 5) signed interger overflow would have had to happen in the addition of the two sizes. The compiler can therefore remove the overflow check as dead code. On Qt 6 and 64-bit platforms, the signed integer addition would be very unlikely to overflow, but the following truncation to uint32 would yield the correct result only in a narrow 32-value window just below UINT_MAX, if even that. Fix by using the proper tool, qAddOverflow. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I7599f2e75ff7f488077b0c60b81022591005661c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* HPack: fix a Yoda ConditionMarc Mutz2023-12-131-1/+1
| | | | | | | | | | | | | | | | Putting the variable on the LHS of a relational operation makes the expression easier to read. In this case, we find that the whole expression is nonsensical as an overflow protection, because if name.size() + value.size() overflows, the result will exactly _not_ be > max() - 32, because UB will have happened. To be fixed in a follow-up commit. As a drive-by, add parentheses around the RHS. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I35ce598884c37c51b74756b3bd2734b9aad63c09 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* hpack: use QBAV moreAnton Kudryavtsev2023-08-291-3/+3
| | | | | | | While touching code, use constexpr more Change-Id: I1c5d80f257f742a2999147c12340bba38e8b1e2f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* http2protocol: use QSB to reduce allocationsAnton Kudryavtsev2023-08-241-5/+3
| | | | | Change-Id: I9bc312e6c7e4b7c8f613b88e206a2a23f9e23722 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Long live Q_UNREACHABLE_RETURN()!Marc Mutz2022-10-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a combination of Q_UNREACHABLE() with a return statement. ATM, the return statement is unconditionally included. If we notice that some compilers warn about return after __builtin_unreachable(), then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without having to touch all the code that uses explicit Q_UNREACHABLE() + return. The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that there are compilers that complain about a lack of return after Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as well as compilers that complained about a return being present (Coverity). Take this opportunity to properly adapt to Coverity, by leaving out the return statement on this compiler. Apply the macro around the code base, using a clang-tidy transformer rule: const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule( stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)) ); where nextStmt() is copied from some upstream clang-tidy check's private implementation and subStmt() is a private matcher that gives access to SwitchCase's SubStmt. A.k.a. qt-use-unreachable-return. There were some false positives, suppressed them with NOLINTNEXTLINE. They're not really false positiives, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. I haven't figured out how to remove the empty line left by the deletion of the return statement, if it, indeed, was on a separate line, so post-processed the patch to remove all the lines matching ^\+ *$ from the diff: git commit -am meep git reset --hard HEAD^ git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1 [ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro. Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHttp2Configuration: in QNAM, use old, higher values in flow controlTimur Pocheptsov2022-08-301-1/+2
| | | | | | | | | | | | | | | | | | | | | Initially, stream receive window's size was quite significant. At some point when dealing with a server that did not want our windows' sizes and was closing the connection (they only accept 64K) we reduced this size, which ended in a regression with download speed significantly throttled. We return the old values (or even more, presuming we have 10 multiplexed streams and not 100). And also making QNAM consistent with its documentation (it was not updated). [ChangeLog][QtNetwork] Stream receive window that HTTP/2 protocol in QNAM is using increased to 214748364 octets (from the previous 64K) not to throttle download speed. Clients, working with servers, not accepting such parameters, must set HTTP/2 configuration on their requests accordingly. Fixes: QTBUG-105043 Pick-to: 6.4 6.3 6.2 Change-Id: I252b6b5eefe92a7304dad15c67928d5a57d9597f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1614-532/+28
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtNetwork: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-211-19/+21
| | | | | | Task-number: QTBUG-98434 Change-Id: Ic235b92377203f7a1429ae7fd784c4a1fa893e9f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtNetwork: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERN [2/2]: ↵Marc Mutz2022-04-062-1/+3
| | | | | | | | | | | | | | | private API It's one of our best tools to improve compile times. Can't backport to Qt 6.2 because the macros don't exist there. Pick-to: 6.3 Task-number: QTBUG-102206 Change-Id: Ic8f3870d8eec6211c4be506dc67717cc4e0ff7d6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* HTTP2: port to QByteArrayView where it's trivialMarc Mutz2022-03-116-8/+8
| | | | | | | | | | | | | Nothing serious, just was curious and played around a bit, so might as well merge it. There's much more here that could be done, but I lack the time to do it. Change-Id: Idd4ea09a7a413ed5911ffe16841f3d5c944ec1a5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* HPack: make padding_is_valid static constexprMarc Mutz2022-03-111-0/+1
| | | | | | | | ... because we can. Change-Id: I3a813fa9c33e47d20a00e6a331cbbcf6f85e63e7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Make sure all qtbase private headers include at least one otherThiago Macieira2022-02-244-7/+7
| | | | | | | | | | See script in qtbase/util/includeprivate for the rules. Since these files are being touched anyway, I also ran the updatecopyright.pl script too. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Don't send the default SETTINGS_INITIAL_WINDOW_SIZETimur Pocheptsov2021-10-121-3/+6
| | | | | | | | | | And don't set non-default large value in QNetworkRequest's constructor. Some servers consider those values as 'flow control error'. Pick-to: 6.2 Fixes: QTBUG-97384 Change-Id: I801b7c83fe7e7392a02ba653c36dfa8a22c21d1e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* network: Fix typos in source code commentsJonas Kvinge2021-10-121-1/+1
| | | | | | Change-Id: Iff505451e3f00de2d753de0f1d891a73cf73ef0d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Http/2 - handle PADDED flag correctlyTimur Pocheptsov2021-10-091-2/+3
| | | | | | | | | | | | Previously, when deciding where the actual data is, Frame was calling padding() to test if offset is needed. A curious case with a DATA frame containing compressed body and having 'PADDED' flag set with a padding equal to ... 0, ended in a decompression error (and assert in 6.2 code). Pick-to: 6.2 5.15 Fixes: QTBUG-97179 Change-Id: I9341a4d68510aa4c26f4972afdcd09a530d5a367 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* H2: remove a rather useless limit on the number of streamsTimur Pocheptsov2021-06-141-3/+0
| | | | | | | | | | | | | | | | | | SETTINGS for max concurrect number of streams is 'one direction' - this is how our peer conveys the possible number of streams _we_ can open, not _them_. If they choose to have it unlimited - let it be so. It's possible to send 0 as maximum number, also, it's possible to reduce the maximum compared to initial at some point - then I have to avoid integer overflows. Pick-to: 6.2 Pick-to: 6.1 Pick-to: 5.15 Fixes: QTBUG-94470 Change-Id: Ia02247acbaedd70998a4cab02082ba10f45cf78c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-071-17/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Huffman compression: handle QByteArray's elements as unsigned charTimur Pocheptsov2020-09-071-2/+4
| | | | | | | Fixes: QTBUG-86418 Pick-to: 5.15 Change-Id: Ie57ecad2b1fda7c2fc0de60cbdb4304c00e645d0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Only use one macro per lineLars Schmertmann2020-07-032-3/+6
| | | | | | | | | Also add a ; where it is missing. Task-number: QTBUG-82978 Change-Id: Ic5d2a07363c25ab641d234baca89bc62238458cb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* HTTP/2: use a non-default MAX_FRAME_SIZETimur Pocheptsov2019-08-221-3/+7
| | | | | | | | | | And send it in our 'SETTINGS' frame. Add an auto-test for this and (as a bonus) - fix a bug accidentally introduced by the previous change. Task-number: QTBUG-77412 Change-Id: I4277ff47e8d8d3b6b8666fbcd7dc73c827f349c0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QHttp2Configuration - respect the value returned by huffmanCompressionEnabled()Timur Pocheptsov2019-08-212-0/+6
| | | | | | | | And either compress or not. Task-number: QTBUG-77412 Change-Id: I3b09385d2b3caf4f7de0455ad6e22c0f068c33a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add means to configure HTTP/2 protocol handlerTimur Pocheptsov2019-08-203-143/+39
| | | | | | | | | | | | | | Similar to TLS configuration that we can use on QNetworkRequest, we can configure different options in our HTTP/2 handling by providing QNetworkAccessManager with h2 configuration. Previously, it was only possible internally in our auto-test - a hack with QObject's properties and a private class. Now it's time to provide a public API for this. [ChangeLog][QtNetwork][QNetworkRequest] Add an ability to configure HTTP/2 protocol Change-Id: I80266a74f6dcdfabb7fc05ed1dce17897bcda886 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-08-151-2/+4
|\ | | | | | | Change-Id: Id7954ada1f8658d3b1da5e8241a09f2d201a7c56
| * Make our connection-level window half of a possible maximumTimur Pocheptsov2019-08-141-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some servers seem to be unable to properly calculate our window size from a delta we send via WINDOW_UPDATE frame immediately after our client preface and the SETTINGS frame. The remote replies with a GOAWAY frame blaming flow control error. Guessing what's this magic number they use seems to be not feasible, we now use a half of what we had before. Fixes: QTBUG-77308 Change-Id: I41dacfd25a395a27003f330d01b6d8d60b8f407c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-03-062-99/+121
|\| | | | | | | | | | | | | Conflicts: src/network/access/http2/hpacktable_p.h Change-Id: Ie0c296667dfdebba84f4858056a1ac80c24ee7df
| * Hpack - fix the static lookupTimur Pocheptsov2019-03-042-99/+121
| | | | | | | | | | | | | | | | | | | | | | 'accept' breaks the order, making the static table unsorted and thus std::lower_bound cannot find it and we always index it in a dynamic table. Also, make this static table accessible to auto-test. Plus fix some warnings quite annoyingly visible in qt-creator. Fixes: QTBUG-74161 Change-Id: I47410f2ef974ac92797c9804aa55cb5c36a436c4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Use Q_DISABLE_COPY_MOVE for private classesFriedemann Kleint2018-12-122-2/+2
|/ | | | | Change-Id: I3cfcfba892ff4a0ab4e31f308620b445162bb17b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QByteArray: add compare() with case sensitivity optionsThiago Macieira2018-06-221-1/+2
| | | | | | | | | | | | | Need to do the same for startsWith() and endsWith(). indexOf() is a lot harder. [ChangeLog][QtCore][QByteArray] Added compare(), which takes Qt::CaseSensitivity as one of the parameters. This function is more efficient than using toLower() or toUpper() and then comparing. Change-Id: Ib48364abee9f464c96c6fffd152e69bde4194df7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Fix build for Android with android-clang in r17Liang Qi2018-06-061-2/+0
| | | | | | Task-number: QTBUG-67464 Change-Id: Ib971a5da82b31bce9ac1c9ac623ad7d5302cfaec Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Merge "Merge remote-tracking branch 'origin/5.10' into dev" into ↵Liang Qi2017-11-062-38/+152
|\ | | | | | | refs/staging/dev
| * Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-11-052-38/+152
| |\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/minimum-linux.S src/network/access/qhttpthreaddelegate.cpp src/widgets/kernel/qwidgetwindow.cpp Change-Id: Id2e817e85f85c68f5482c9a12912d35590f9d5f8
| | * HTTP/2 - make protocol settings configurablev5.10.0-beta3Timur Pocheptsov2017-10-262-38/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Recently we have updated our receive window size to a larger value. Unfortunately, this also results in auto-test pumping through more data, which probably takes more time on CI. At the moment we do not have any public API on QNAM's level to customize HTTP/2 parameters (aka 5.10/FF and so on). So we use the fact that QNAM is QObject and we can set a property on it. This property is our Http2::ProtocolParameters object that allows us to configure: - HPACK parameters (in 5.10 - noop) - session receive window size - different SETTINGS as described by RFC 7540, 6.5.2. 2. Undocumented environment variable to set ENABLE_PUSH is not needed anymore. 3. In 5.11 Http2::ProtocolParameter will become a public API and we'll introduce a new setter in QNAM. Change-Id: If08fd5e09e7c0b61cf9700b426b60b5837b6b2e6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Modernize use of 'http' featureUlf Hermann2017-11-061-0/+2
|/ / | | | | | | | | | | | | | | | | | | Exclude QHttp(Multi)Part from being built if http is disabled, and replace the exclusion macros. Use the qmake project files to exclude source files, and QT_REQUIRE_CONFIG(http) in headers. Change-Id: I432fa3c78aa97b5ed2eb1027ac1dc3bdb134f9ba Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | HPACK - remove non-trivial ctorsTimur Pocheptsov2017-10-261-17/+5
| | | | | | | | | | | | | | | | They are not needed actually, found by clazy-non-pod-global-static check. Change-Id: Ice70f5065ffe8a39e2478eacff0ed1826806c8a6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | HPACK - make Huffman 'CodeEntry' into PODTimur Pocheptsov2017-10-261-13/+0
|/ | | | | | | | Found by clazy-non-pod-global-static check. Indeed, it can be a pod, no need in non-trivial ctors. Change-Id: I5f17e322a64f6c8d53b2acd8ea045d8beb1a72f9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* HTTP/2 protocol handler: tweak receive window sizesTimur Pocheptsov2017-10-162-2/+14
| | | | | | | | | | | | | | | | | We were using the default ones, provided by RFC7540. It appears they are way too restrictive and conservative: when downloading something relatively big, a stream keeps spending the whole session/its own 'recv' windows and thus we have to constantly send WINDOW_UPDATE frames. This significantly slows down our HTTP/2 implementation, making it orders of magnitude slower than HTTP/1.1. To fix this: - We send SETTINGS_INITIAL_WINDOW_SIZE in the first SETTINGS frame to inform our peer that per-stream WINDOW is bigger than 64Kb - We increase the session's receive window size. Task-number: QTBUG-63722 Change-Id: I31312fcfd5f0fc0aee6aaa5d3562cc7d1b931adc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* HTTP/2 - implement the proper 'h2c' (protocol upgrade)Timur Pocheptsov2017-08-274-2/+87
| | | | | | | | | | | | | | | | | | | | | | | | | Without TLS (and thus ALPN/NPN negotiation) HTTP/2 requires a protocol upgrade procedure, as described in RFC 7540, 3.2. We start as HTTP/1.1 (and thus we create QHttpProtocolHandler first), augmenting the headers we send with 'Upgrade: h2c'. In case we receive HTTP/1.1 response with status code 101 ('Switching Protocols'), we continue as HTTP/2 session, creating QHttp2ProtocolHandler and pretending the first request we sent was HTTP/2 request on a real HTTP/2 stream. If the first response is something different from 101, we continue as HTTP/1.1. This change also required auto-test update: our toy-server now has to respond to the initial HTTP/1.1 request on a platform without ALPN/NPN. As a bonus a subtle flakyness in 'goaway' auto-test went away (well, it was fixed). [ChangeLog][QtNetwork][HTTP/2] In case of clear text HTTP/2 we now initiate a required protocol upgrade procedure instead of 'H2Direct' connection. Task-number: QTBUG-61397 Change-Id: I573fa304fdaf661490159037dc47775d97c8ea5b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* HTTP/2 - fix the handling of PUSH_PROMISETimur Pocheptsov2016-10-215-20/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | HTTP/2 allows a server to pre-emptively send (or "push") responses (along with corresponding "promised" requests) to a client in association with a previous client-initiated request. This can be useful when the server knows the client will need to have those responses available in order to fully process the response to the original request. Server push is semantically equivalent to a server responding to a request; however, in this case, that request is also sent by the server, as a PUSH_PROMISE frame. The PUSH_PROMISE frame includes a header block that contains a complete set of request header fields that the server attributes to the request. After sending the PUSH_PROMISE frame, the server can begin delivering the pushed response as a response on a server-initiated stream that uses the promised stream identifier. This patch: - fixes the HPACK decompression of PUSH_PROMISE frames; - allows a user to enable PUSH_PROMISE; - processes and caches pushed data for promised streams; - updates auto-test - emulates a simple PUSH_PROMISE scenario. Change-Id: Ic4850863a5e3895320baac3871a723fc091b4aca Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Refactor Http2::FrameReader/Http2::FrameWriterTimur Pocheptsov2016-08-194-320/+255
| | | | | | | | | | | | | | Introduce new entity: class Http2::Frame with accessors like payloadSize/type/flags/streamID etc. (they actually read /interpret raw bytes from a frame's buffer) instead of duplicating this functionality in reader/writer classes. Delete defaulted members and remove explicitly defined move ctors/operators (not needed actually). Update auto-test ('HTTP/2 server') to use these new classes. Change-Id: Ie3516efbd095704e212142eef9e792323678ccfa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* HTTP/2 - do not set END_HEADERS if we have CONTINUATIONsTimur Pocheptsov2016-08-171-0/+1
| | | | | | | | | Setting END_HEADERS flag on a HEADERS frame means we do not have CONTINUATION frame(s). So do NOT set it too early, only if we fit into a single frame. Change-Id: I891a2db227cee59e4eacfe7c2f18b431cd85fe47 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* http2frame - do not rely on a socket's bufferTimur Pocheptsov2016-08-112-30/+64
| | | | | | | | | | | | | | | - Whenever we have a read notification, read this data, even if it's not enough for a frame's header - otherwise, QNAM can use a socket in an Ubuffered mode and FrameReader can potentially fail to read anything correctly. - Do not call/rely on bytesAvailable and do not try to invoke _q_receiveReply in Qt::QueuedConnection mode, instead try to read until we end up in an incomplete frame or some error. Change-Id: I7f44ba9e34bc64f3e26bd29080f0050da635b3ae Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Revert "Implement protocol upgrade for HTTP/2 enabled requests"Timur Pocheptsov2016-08-042-52/+0
| | | | | | | | | This reverts commit 12d71f4ea20415ff2274e1e90f9e4d5a8b935d7f. This change is breaking a build + incomplete as my test revealed. Will have to re-try later. Change-Id: I7ea089093a832aa5822caaaac56e62f5fda4df17 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Implement protocol upgrade for HTTP/2 enabled requestsTimur Pocheptsov2016-08-032-0/+52
| | | | | | | | | | | | | | Without ALPN/NPN (== without OpenSSL) we can negotiate HTTP/2 using the protocol upgrade procedure as described by RFC7540. Since there is no TLS handshake, after our http channel was connected we first send an 'augmented' HTTP/1.1 request - its header contains additional 'HTTP2-Settings' and 'Upgrade' (to 'h2c') fields. If we receive reponse 101 (switch protocol) we re-create a protocol handler and switch to HTTP/2. Task-number: QTBUG-50955 Change-Id: I36e9985e06ba76edaf7fdb22bb43770f8d593c61 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* HTTP/2 - fix 'GOAWAY' frame size validationTimur Pocheptsov2016-07-251-2/+6
| | | | | | | | | Found while implementing cleartext http2 (and sending some erroneous frames) - GOAWAY can have some 'opaque debug information payload' so the frame's size is at least 8 bytes, but can be more. Change-Id: I90fb8a3df22768673c4f40ba3bf6a3f5ffe33058 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>