Check compressed responses
Multiple encoding formats can be applied to data.
Example: Content-Encoding: gzip, deflate
According to RFC2616:
"If multiple encodings have been applied to an entity, the content
codings MUST be listed in the order in which they were applied."
https://datatracker.ietf.org/doc/html/rfc2616#section-14.11
=> Header order = compression order (first listed = first applied)
Which means decoding should reverse that order.
In HttpRequest.cpp.mustache:
*) In parseResponse():
- Iterate over encodings in reverse order and call decompress().
*) Refactor decompress():
- take 'compressionType' as a parameter.
- Add warnings for unsupported encodings (for now).
- Move gzip and deflate decompression logic to a separate function.
*) Add encodingFormatToCompressionType() to get the CompressionType
out of a QString encoding format.
Previously, decompression was applied only for gzip and deflate and
the logic supported only these two encoding formats.
NB: Decompression logic should be revised separately from this change.
TODO:
Add Brotli and Zstandard encodings support. (QTBUG-141056)
In generate.sh:
- Set contentCompression additional property to true for responses
spec.
For test purposes:
- In yaml file: Add Content-Encoding header in a json object response.
- In server: Update ApplicationJsonObjectResponse() to send a
double-compressed json: first gzip, then deflate.
- In Response.cpp tests: Nothing should change because the result
should remain the same. The response is now sent compressed and
decompressed during parsing.
Task-number: QTBUG-139852
Change-Id: Ifefab2989ea9bc5e1ebbcc5d8ccd21d3abb4e9c6
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
| commit | 460d1c5117b9ebca93ac7a79035de7bf1b0cb550 |
| parent | 6be9011c18d7ac554b2706b29efc597c067817f8 |
| author | Rym Bouabid <rym.bouabid@qt.io> |
| committer | Rym Bouabid <rym.bouabid@qt.io> |
| commit time | Thu, 6 Nov 2025 09:52:48 +0100 |
- M generate.sh
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/HttpRequest.cpp.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/HttpRequest.h.mustache
- M tests/auto/colorpalette/client/common/QtOAIHttpRequest.cpp
- M tests/auto/colorpalette/client/common/QtOAIHttpRequest.h
- M tests/auto/colorpalette/qmlclient/common/OAIHttpRequest.cpp
- M tests/auto/colorpalette/qmlclient/common/OAIHttpRequest.h
- M tests/auto/compression/client/common/QtOAIHttpRequest.cpp
- M tests/auto/compression/client/common/QtOAIHttpRequest.h
- M tests/auto/compression/client/tst_compression/tst_compression.cpp
- M tests/auto/linking_several_clients/client1/common/QtOAIHttpRequest.cpp
- M tests/auto/linking_several_clients/client1/common/QtOAIHttpRequest.h
- M tests/auto/mediatype/client/common/QtOAIHttpRequest.cpp
- M tests/auto/mediatype/client/common/QtOAIHttpRequest.h
- M tests/auto/openapi2.0/client/common/QtOAIHttpRequest.cpp
- M tests/auto/openapi2.0/client/common/QtOAIHttpRequest.h
- M tests/auto/operation-parameters/client/common/QtOAIHttpRequest.cpp
- M tests/auto/operation-parameters/client/common/QtOAIHttpRequest.h
- M tests/auto/petstore/client/common/QtOAIHttpRequest.cpp
- M tests/auto/petstore/client/common/QtOAIHttpRequest.h
- M tests/auto/petstore/qmlclient/common/OAIHttpRequest.cpp
- M tests/auto/petstore/qmlclient/common/OAIHttpRequest.h
- M tests/auto/responses/client/Responses/Responses.cpp
- M tests/auto/responses/client/client/CMakeLists.txt
- R055 tests/auto/responses/client/client/QtOAIApplicationJsonObjectResponse_200_response.cpp
- R064 tests/auto/responses/client/client/QtOAIApplicationJsonObjectResponse_200_response.h
- M tests/auto/responses/client/client/QtOAITestApi.cpp
- M tests/auto/responses/client/client/QtOAITestApi.h
- M tests/auto/responses/client/client/README.md
- M tests/auto/responses/client/common/CMakeLists.txt
- M tests/auto/responses/client/common/QtOAIHttpRequest.cpp
- M tests/auto/responses/client/common/QtOAIHttpRequest.h
- M tests/auto/responses/server/go/api_test_.go
- M tests/auto/responses/server/go/routers.go
- M tests/auto/yaml_files/responses.yaml