summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/access/http2/http2srv.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add means to configure HTTP/2 protocol handlerTimur Pocheptsov2019-08-201-3/+3
| | | | | | | | | | | | | | 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>
* tst_http2 - extend 'singleRequest' test caseTimur Pocheptsov2019-04-091-24/+31
| | | | | | | | | | | | to test different h2 modes: "h2c" (clear text with protocol upgrade), "h2" (encrypted, negotiating via ALPN extension), "h2-direct" (encrypted, no ALPN), "h2c-direct" (plain text, no protocol upgrade). This patch-set is an amendment to the recent fix in the protocol handler where we were crashing in "h2c-direct" mode. Change-Id: I3ff5ed1396a59b72b59a95f927d404ccd202d0b8 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tst_http2::earlyResponse - fix a flaky and somewhat broken testTimur Pocheptsov2019-02-201-0/+14
| | | | | | | | | | | | | | 1. Fix erroneous logic, which was triggered in 'h2' mode (non-TLS connection) - after the initial protocol upgrade/POST request was handled, the server (on Windows specifically) was erroneously handling upcoming DATA frames by replying with another redirect response. 2. Make the test less heavy by sending 1 MB of Qt::Uninitialize instead of 10 MB - theoretically this could cause a timeout before the redirected request finished successfully. Task-number: QTBUG-73873 Change-Id: I961e0a5f50252988edd46d0e73baf96ee22eef3f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_Http2 auto-test: stop sending DATA frames if test failedTimur Pocheptsov2018-06-041-5/+27
| | | | | | | | | | | | | | Unlike QNAM, our toy http2 server sends payload as one big chunk as soon as it fits in the receive window's size. Internally, 'frame writer' splits this payload into many DATA frames of the appropriate size (imposed either by the default value or the one from the client's SETTINGS frame). If some test fails, we can end up with a server waiting for the writer to send all the DATA frames though it is not needed anymore - there is nobody to receive them after a failure. This patch moves such a loop into the test server instead and stops the loop early if needed. Change-Id: Iea2dcd718d8f83386fd16004807f6447bf999435 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* HTTP/2 - reset uploadByteDevice if necessaryTimur Pocheptsov2018-04-121-2/+26
| | | | | | | | | | | | | | | | 1. If a request was redirected or some error was encountered, we try to reset the uploading byte-device. 2. Disconnecting from the byte-device is not enough, since we have a queued connection, _q_uploadDataReadyRead() gets called even if byte-device was deleted and thus sender() can return null - we have to check this condition. 3. Update auto-test with a case where our server immediately replies with a redirect status code. Task-number: QTBUG-67469 Task-number: QTBUG-66913 Change-Id: I9b364cf3dee1717940ddbe50cba37c3398cc9c95 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* HTTP/2 - make protocol settings configurablev5.10.0-beta3Timur Pocheptsov2017-10-261-12/+10
| | | | | | | | | | | | | | | | | | | | | | 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>
* HTTP/2 - implement the proper 'h2c' (protocol upgrade)Timur Pocheptsov2017-08-271-14/+181
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix some MSVC warnings in testsFriedemann Kleint2017-06-281-1/+1
| | | | | | | | | | | | tst_qvariant.cpp(80): warning C4309: 'initializing': truncation of constant value tst_qvariant.cpp(4635): warning C4309: 'initializing': truncation of constant value tst_qbytearray.cpp(1438): warning C4267: 'argument': conversion from 'size_t' to 'uint', possible loss of data tst_qbytearray.cpp(1440): warning C4267: 'argument': conversion from 'size_t' to 'uint', possible loss of data http2srv.cpp(64): warning C4018: '<=': signed/unsigned mismatch tst_qinputdialog.cpp(352): warning C4804: '<=': unsafe use of type 'bool' in operation Change-Id: Id012d88b7b20c5c9f128f2ef53753cc1d479f358 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* HTTP/2 - fix handling of GOAWAY frameTimur Pocheptsov2017-01-111-0/+18
| | | | | | | | | | | | | | | | | | | - Fix the case when we erroneously handled stream ID == 0 in a GOAWAY frame as an invalid stream ID. - _q_receivedReply: convert do{}while() loop into to while(){} to prevent it from handling any frames after GOAWAY frame received and all active frame finished. - sendRequest - if we received GOAWAY, also clear spdyRequests in the connection channel, otherwise it keeps re-trying to send requests! - Http network connection channel never resets a protocolHandler in _q_encrypted/ _q_connected, which is BAD for HTTP/2, since HTTP/2 has unique per-connection compression context and must be reset - now we recreate the protocol handler in _q_encrypted or _q_connected (https/http). - Update autotest. Task-number: QTBUG-57600 Change-Id: Ib864ce52287bab23334ff43a83ba4b0b7cb52c60 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* HTTP/2 - fix the handling of PUSH_PROMISETimur Pocheptsov2016-10-211-4/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* HTTP/2 tests: Remove execute permissions from source filesEdward Welbourne2016-09-061-0/+0
| | | | | | | Source (.cpp and .h) files should not be executable. Change-Id: I021d8733185d73d071fcaf3df7e529862a490b63 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
* Refactor Http2::FrameReader/Http2::FrameWriterTimur Pocheptsov2016-08-191-42/+46
| | | | | | | | | | | | | | 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 - fix invalid read (auto-test)Timur Pocheptsov2016-08-171-1/+1
| | | | | | | | | Since headersFrame is a reference to a vector's element, clearing this vector before accessing headersFrame.flags is not a good idea, must be done later. Change-Id: I80eee0761ac1cad580e979be9371ec7588a694ac Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* HTTP/2 - fix QT_NO_SSL buildTimur Pocheptsov2016-08-151-1/+2
| | | | | | | | Recently enabled cleartext fails to build with QT_NO_SSL - fix test and QNAM. Change-Id: I467edab8e4eb5113715ad2d3b3022e0d8c027de8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Enable cleartext HTTP/2 and bring the auto-test back to lifeTimur Pocheptsov2016-08-111-36/+60
| | | | | | | | | | | | | | HTTP/2 does not require TLS connection, it can work in a cleartext mode. Plus at the moment only OpenSSL backend allows HTTP/2 negotiation via ALPN/NPN (and none of our CI configurations with OpenSSL supports these extensions, rendering HTTP/2 auto-test useless). This patch implements cleartext HTTP/2 ('h2c') in 'direct' mode - this is allowed if a client has a prior knowledge that HTTP/2 is supported by a server. Change-Id: I4978775e9732c40bc77f549b83bb4a5d1761887e Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* HTTP2 - autotestTimur Pocheptsov2016-07-141-0/+611
Add autotest for QHttp2ProtocolHandler. This patch contains a very simplistic "in-process HTTP2 server" for testing the protocol's basic logic/flow control/error handling and emulating possible scenarios. Task-number: QTBUG-50956 Change-Id: Ie02d3329c5182277a3c7c84f1bae8d02308e945d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>