Implement the missing decompression handling. We were advertising an
accepted encoding of GrpcAcceptEncodingValue("identity,deflate,gzip")
but only ever handled identity (i.e. no compression) !
We now check the negotiated content-encoding in the initialMetadata to
set up the appropriate decompression. Since compression can vary per
message, dynamic processing is required.
[ChangeLog][QGrpcHttp2Channel] Added missing decompression handling for
'deflate' and 'gzip'.
Fixes: QTBUG-129286
Pick-to: 6.10 6.9 6.8
Change-Id: I3ed4af7b21b51c52bccc3e6c314ae166e80c94a8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
In case we receive the endStream flag when processing received data, we
now return a non-ok QGrpcStatus if there's still unprocessed data in the
intermediate container.
[ChangeLog][QGrpcHttp2Channel][Important Behavior Changes] finishes the
communication with a non-ok QGrpcStatus (DataLoss) when the stream is
closed with unprocessed trailing data.
Pick-to: 6.10 6.9 6.8
Change-Id: I53d36c012d6cab57f4d8b652518ff5ccd5be24f2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
We are missing functionality! We are omitting any compressed messages.
This patch doesn't add the compression handling but a more structured
and sane way of encapsulating the data parsing. Added the compression
flag extraction to the parsing.
Task-number: QTBUG-129286
Pick-to: 6.10 6.9 6.8
Change-Id: I699fdb6fb0279453a367930e950c2af3e992063d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The initial metadata is received when the call starts, often at a
different time then when the RPC finishes. Interceptors provide a way to
access this globally for all RPC but we should add this signal for our
users who are only interested in specific handlers.
[ChangeLog][QGrpcOperation] Added the serverInitialMetadataReceived
signal.
Change-Id: I362a601675029a21d7721275a1b8174ded07fabf
Fixes: QTBUG-139558
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Our current test strategy relies on having a dedicated server running.
While this tests the most 'accurate' flow of the system, it is really
hard to verify the server behavior due to missing flexibility.
Introduce the mockserver to solve this problem. It wraps the low-level
async gRPC server API and allows for non-blocking processing of
operations. This allows it to run nicely together with the Qt Even Loop,
which is blocking.
Provide the server-handling code by using CallbackTags with Lambdas, or
by subclassing the AbstractRpcTag interface.
Change-Id: I086cbd1d6d8542c717ae036bdf54ba96c55afb58
Fixes: QTBUG-139285
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
It makes sense to provide the equality operators to these classes.
However, omit the otherwise common 'qHash' functionality as it makes no
sense to hash a options class.
[ChangeLog][QGrpcCallOptions/QGrpcChannelOptions] Made the options
classes equality comparable.
Task-number: QTBUG-128338
Change-Id: Idb7ff6946dfef373eba32839ac4b3faf2ff4e5c2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
More structured way of handling the code that complements the
interceptors patch.
Pick-to: 6.10 6.9 6.8
Change-Id: I6660e9a95ff8faef8e50966d912fdf9f1a7967c9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Move the protocolCompilerAvailableToRun check under the
SKIP_COMMAND_LINE_TESTS guard.
Pick-to: 6.8 6.9 6.10
Change-Id: Ibd2ce706e7d73d368a89f9f486f3f2fc0f59e7e4
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
The libraty cannot be built if grpc_testserver is missing.
Pick-to: 6.10 6.9 6.8
Change-Id: I34f6a419e2726ec23ac78f0b95f0974df2080547
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This is a better place then the 'Application Examples' category that
should be reserved for higher-level examples that work out of the box.
Also highlight the example in the Networking category.
Pick-to: 6.8 6.9 6.10
Task-number: QTBUG-137988
Change-Id: I75f630daeba350043f6d0aa3a90b30bee967e6b1
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Our documentation of what the QGrpcHttp2Channel should accept as
metadata was incomplete. Add the missing bits and give readers a link to
the original information, which is coming from RFC 7540.
Task-number: QTBUG-139558
Pick-to: 6.10 6.9 6.8
Change-Id: Ie170fd1f5300597b31dd49d47d5e01c469bf6ec3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
We are constructing 'hostUri' at this point. Don't use it for printing.
Coverity-Id: 894268
Pick-to: 6.10 6.9 6.8
Change-Id: I2b478de2d3865112978202959e1af07b17f7751a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Previously the helper returned early in case no service section was
found in the proto file. If we supply multiple files, this function
should simply skip those. Otherwise it's not possible to process such a
list variable.
Pick-to: 6.10 6.9 6.8
Change-Id: Iab31fa81404f2df2ec4ad628810ff7f948b3eb5f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
For understanding the flow better, if needed. Change the log for failed
cancellations to be a warning. This information is usefull to see
without special logging rules!
Pick-to: 6.10 6.9 6.8
Change-Id: I5e30962381c4f476d8e9e1258f5af10c7586942c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Currently, if TLS or QLocalSocket is explicitly requested but
unavailable, we fall back to TCP. This is not a safe approach.
This patch asserts on that condition and uses qCFatal to indicate the
mismatch instead of silently falling back to another transport.
Given the security aspects of this file, this strengthens guarantees by
ensuring the requested transport is actually used.
Also: Make construction initialization friendly!
Separated concerns by splitting the large constructor into smaller
segments, achieving the same result through helper functions in the
initializer list.
Added a SocketType enum to clearly identify the transport method. Since
m_isLocalSocket was already removed, this provides more detail without
increasing storage.
[ChangeLog][QGrpcHttp2Channel][Important Behavior Changes]
Requesting TLS or QLocalSocket now fails with a fatal error if the
requested transport is unavailable.
Fixes: QTBUG-139597
Pick-to: 6.10 6.9 6.8
Change-Id: I2914d8a5764436d08b4502aa7d8cf6c4fdeb60d0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
-A list of basic security topics when implementing gRPC
-Add links to other modules and relevant pages.
Task-number: QTBUG-138812
Pick-to: 6.9 6.10
Change-Id: I523f07cb516641771eb1457091f381a2e09b0026
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
As part of reviewing the application examples and following a structure, this
change covers:
-Language changes
-Follows the strucutre
-Includes \sa link to All Qt Examples
Fixes: QTBUG-137964
Pick-to: 6.10 6.9 6.8
Change-Id: Ic14d7042e6db277c1584b69ba46f7748f53642ab
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Remove the warning that incorrectly triggers when a second HTTP/2
SETTINGS frame is received.
According to RFC, Section 6.5, a SETTINGS frame "MAY be sent at any
other time by either endpoint over the lifetime of the connection."
Ref: https://www.rfc-editor.org/rfc/rfc7540#section-6.5
Pick-to: 6.10 6.9 6.8
Change-Id: I83b0238405801a853c20f22629b12f67edce26e2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
It's the single point where a RPC finishes and the correct place to stop
the timer.
Pick-to: 6.10 6.9 6.8
Change-Id: I2965a938da32a8d78ccfb48f7f5ad37f63ee4363
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
It's not used anywhere in the code
Pick-to: 6.10 6.9 6.8
Change-Id: I388800f73f67f9f37f008590c9f190aa091d9c6b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Instead of connecting each and every Http2Handler to the socket error,
use QGrpcHttp2ChannelPrivate::handleSocketError to iterate over
alive Http2Handler and send errors right from this handler. This saves
some memory and time on handling errorOccurred signal.
Pick-to: 6.10 6.9 6.8
Change-Id: I907e24425aafe3dccca19100d02fe7adffb1fdaa
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Fixes a compiler warning from implicit conversion by introducing a safe
qsizetype cast. Also improves readability and efficiency by renaming
variables and pre-allocating list storage aswell as adding a missing
move.
Pick-to: 6.10 6.9 6.8
Change-Id: I5eb34621690893e06e68c7b821e93e3462388595
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Repeated enum fields should not ignore the 'packed' protobuf attribute,
so if 'packed' is set to 'false', FieldFlag::NonPacked should land to
the message field attributes, indicating to serializer the expected
output format.
Fixes: QTBUG-138683
Pick-to: 6.8 6.9 6.10
Change-Id: I1c2d2bee32b42f60310307e1f3638ba2b3c236a3
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
The \generatelist command takes an optional argument
that affect how the members are listed, for example,
`classesbymodule` which creates an annotated list of
the classes in a named C++ module.
`groupsbymodule` is not recognized or documented. QDoc
falls back to generating a list of all members of a
group in this case. While the end result is correct,
this relies on an undocumented feature that is likely
to change and break.
Replace these instances with an explicit \annotatedlist
command that produces the same output.
Pick-to: 6.10
Task-number: QTBUG-138901
Change-Id: Iffa5720e53177d1b996d49f9a607e2a1fa91bb0a
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Removed redundant 'QObject::' namespace to streamline code and enhance
readability, especially in lambda handlers.
Due to our formatting, all lambda handlers will be unnecessarily aligned
to the very right side. Given that connections and lambda handlers are
very common in this codebase this improves the readability of those
lambda handlers.
Pick-to: 6.10 6.9 6.8
Change-Id: I178a838c7702382b4b3845c729d7c11eeeb1c8d1
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Easily allows to have a deeper inspection of the system by adding more
debug prints, which can be enabled with the logging category.
Pick-to: 6.10 6.9 6.8
Change-Id: I86d7f6c0c53c412a79a3d66f515fa1cd6757a023
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Given the complexity of the http2channel implementation it comes natural
to extend its logging clarity. This aligns with best practices in Qt
development. Also this makes it easier to debug the system remotely.
Pick-to: 6.10 6.9 6.8
Change-Id: Idf00020408b678fc6b17a25db538abd5a838bced
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
1. Remove nesting by reversing the state check.
2. Split the messageReceived calculation to be outside of the function
call. Given that this is an important calculation it should be easily
understandable.
Pick-to: 6.10 6.9 6.8
Change-Id: Icfaa29a5dc92eb5b1c86469639a3deb90b5aacd0
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Re-order the argument to the Http2Handler ctor. The parent should come
first. Furthermore rename the m_operation to m_context as I think
context is a more fitting name for this important member.
This improves the readability and makes it easier to follow the code.
Pick-to: 6.10 6.9 6.8
Change-Id: I396e205ec345d80a8cf2cfebe43625f72d39ac6e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Implement the filtering of internal and reserved keys for the server
metadata. gRPC over HTTP2 responses are well defined and such
information shouldn't be provided to users. At least not by default.
Ref: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#responses
This patch changes the filtering to be applied by default.
[ChangeLog][QGrpcHttp2Channel/QGrpcOperation][Important Behavior Changes]
QGrpcOperation::serverInitialMetadata() and
QGrpcOperation::serverTrailingMetadata() no longer include any internal
gRPC or HTTP/2 pseudo‑headers by default.
Fixes: QTBUG-138363
Change-Id: I4af9e8abe60799e817f47faa5de4c2d0e41854be
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This option enables to control the filtering of the received server
metadata. Both options provide it as optional<bool>, so that
QAbstractGrpcChannel implementations should choose a reasonable default.
This has not been provided to the QQml*Options, as there is currently no
available API to access the server metadata.
[ChangeLog][QGrpc{Call,Channel}Options] Added the filterServerMetadata
property.
Task-number: QTBUG-138363
Change-Id: I325a3b4f6e68d63f0828a6deb1a7be883247614b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Before, we did a lazy initialization in the deprecated noexcept getters
to provide a way of not storing the metadata twice. There is just no way
to preserve correctness whilst providing this option.
Whilst const-ref return values provide the most efficient way to access
them, it also most tightly constrains the implementation. Let that be a
lesson ...
We also remove the free-standing 'operator==' as we're comparing with
the matching containers now, there is no need for them (They should also
not be provided like this from QtGrpc, even though private).
Amends: 778371b8ea.
Pick-to: 6.10
Change-Id: I05c4a1f7d2eab00f41ebcad54d9a096b2dcdf540
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>