Multipart/form-data implementation update
- There are 2 types of parameters being generated by the
{{FormParams}} block:
'application/x-www-form-urlencoded' (must be percent encoded)
and 'multipart/form-data'.
The 'multipart/form-data' doesn't need to be percent encoded.
It means QUrlQuery doesn't fit for multipart
fields. And even if we try to use it with FullyDecode
option, it will bring the same problem that we had here:
965638584a9ed88d720a23f0c170c4f636839671
(user's input will be changed with data loss)
To solve such problem, I added
'QMap<QString, QString> m_vars;' back,
but only for 'multipart/form-data'.
- Now we save content-type for each field of MediaObject
in the {{FormParams}} block, because according spec 3.1.1
each fiels can have different contentType, see the table of
default types in this chapter (column 'Default contentType'):
https://spec.openapis.org/oas/v3.1.1.html#common-fixed-fields-0
- Add usage of qhttpmultipart and qformdatapartbuilder
to simplify multipart generation.
See:
https://doc.qt.io/qt-6/qhttpmultipart.html
and https://doc.qt.io/qt-6/qformdatapartbuilder.html
NOTE: current update implements only form-data case.
- Add test, see:
tests/auto/mediatype/client/mediatype/MediaType.cpp
- Re-generate all tests clients.
Task-number: QTBUG-133624
Change-Id: I974be7ababa08abd700e80459abfc12747b7986b
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
| commit | 48847d09e464f1701c08cb6312d342ea60ebe421 |
| parent | 9398e1ee7e9523e23281e332514e824aab3b5791 |
| author | Tatiana Borisova <tatiana.borisova@qt.io> |
| committer | Tatiana Borisova <tatiana.borisova@qt.io> |
| commit time | Wed, 20 Aug 2025 09:38:47 +0200 |
- M src/main/resources/cpp-qt6-client/HttpRequest.cpp.mustache
- M src/main/resources/cpp-qt6-client/HttpRequest.h.mustache
- M src/main/resources/cpp-qt6-client/api-base-body.mustache
- M src/main/resources/cpp-qt6-client/api-body.mustache
- M src/main/resources/cpp-qt6-client/helpers-header.mustache
- M tests/auto/colorpalette/client/client/OAIBaseApi.cpp
- M tests/auto/colorpalette/client/client/OAIColorsApi.cpp
- M tests/auto/colorpalette/client/client/OAIDefaultApi.cpp
- M tests/auto/colorpalette/client/client/OAIHelpers.h
- M tests/auto/colorpalette/client/client/OAIHttpRequest.cpp
- M tests/auto/colorpalette/client/client/OAIHttpRequest.h
- M tests/auto/colorpalette/client/client/OAIRegisterApi.cpp
- M tests/auto/colorpalette/client/client/OAIUsersApi.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIBaseApi.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIColorsApi.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIDefaultApi.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIHelpers.h
- M tests/auto/colorpalette/qmlclient/client/OAIHttpRequest.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIHttpRequest.h
- M tests/auto/colorpalette/qmlclient/client/OAIRegisterApi.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIUsersApi.cpp
- M tests/auto/mediatype/client/client/CMakeLists.txt
- M tests/auto/mediatype/client/client/OAIBaseApi.cpp
- M tests/auto/mediatype/client/client/OAIHelpers.h
- M tests/auto/mediatype/client/client/OAIHttpRequest.cpp
- M tests/auto/mediatype/client/client/OAIHttpRequest.h
- A tests/auto/mediatype/client/client/OAIPostMultiPartData_request_formObject.cpp
- A tests/auto/mediatype/client/client/OAIPostMultiPartData_request_formObject.h
- M tests/auto/mediatype/client/client/OAITestApi.cpp
- M tests/auto/mediatype/client/client/OAITestApi.h
- M tests/auto/mediatype/client/client/README.md
- M tests/auto/mediatype/client/client/client.pri
- M tests/auto/mediatype/client/mediatype/MediaType.cpp
- M tests/auto/mediatype/server/api/openapi.yaml
- M tests/auto/mediatype/server/go/api_test_.go
- A tests/auto/mediatype/server/go/model_post_multi_part_data_request_form_object.go
- M tests/auto/mediatype/server/go/routers.go
- M tests/auto/openapi2.0/client/client/OAIBaseApi.cpp
- M tests/auto/openapi2.0/client/client/OAIFakeApi.cpp
- M tests/auto/openapi2.0/client/client/OAIHelpers.h
- M tests/auto/openapi2.0/client/client/OAIHttpRequest.cpp
- M tests/auto/openapi2.0/client/client/OAIHttpRequest.h
- M tests/auto/operation-parameters/client/client/OAIBaseApi.cpp
- M tests/auto/operation-parameters/client/client/OAIHelpers.h
- M tests/auto/operation-parameters/client/client/OAIHttpRequest.cpp
- M tests/auto/operation-parameters/client/client/OAIHttpRequest.h
- M tests/auto/operation-parameters/client/client/OAITestApi.cpp
- M tests/auto/petstore/client/client/OAIBaseApi.cpp
- M tests/auto/petstore/client/client/OAIHelpers.h
- M tests/auto/petstore/client/client/OAIHttpRequest.cpp
- M tests/auto/petstore/client/client/OAIHttpRequest.h
- M tests/auto/petstore/client/client/OAIPetApi.cpp
- M tests/auto/petstore/client/client/OAIStoreApi.cpp
- M tests/auto/petstore/client/client/OAIUserApi.cpp
- M tests/auto/petstore/qmlclient/client/OAIBaseApi.cpp
- M tests/auto/petstore/qmlclient/client/OAIHelpers.h
- M tests/auto/petstore/qmlclient/client/OAIHttpRequest.cpp
- M tests/auto/petstore/qmlclient/client/OAIHttpRequest.h
- M tests/auto/petstore/qmlclient/client/OAIPetApi.cpp
- M tests/auto/petstore/qmlclient/client/OAIStoreApi.cpp
- M tests/auto/petstore/qmlclient/client/OAIUserApi.cpp
- M yaml_files/mediatype.yaml