summaryrefslogtreecommitdiffstats
path: root/src/network/access/qformdatabuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move the variant header from qformdatabuilder.h to the .cpp fileMate Barany6 days1-0/+1
| | | | | | | | | Having it in the header file triggers a clangd warning in Qt creator. Pick-to: 6.11 Change-Id: I69803380831374de9db0d30e17467b381b5921ba Reviewed-by: Mårten Nordheim <[email protected]>
* CRA[network/access]: Mark the rest significantMårten Nordheim2025-07-281-0/+1
| | | | | | | | | The rest was handled separately. Fixes: QTBUG-135582 Pick-to: 6.10 6.9 6.8 Change-Id: Ibabde62b1e66e364c9ba508a5a97d4830d7fcc69 Reviewed-by: Edward Welbourne <[email protected]>
* QFormDataBuilder: add optionsMarc Mutz2024-07-121-10/+84
| | | | | | | | | | | | | | | | | | There are (at least) three RFCs, all non-obsolete, purporting to guard the formatting of multipart/form-data filename parameters, and they all disagree: RFC 6266, RFC 7578 and RFC 8187. There is also considerable implementation divergence. So, to not have to hard-code any one of the different strategies, add Options controlling the formatting. Found to be required in implementation review. Pick-to: 6.8 Task-number: QTBUG-125985 Change-Id: Ibc82ff8a3460580ee70eafcaf9b88de36751940d Reviewed-by: Marc Mutz <[email protected]> Reviewed-by: Mate Barany <[email protected]>
* Apply the PIMPL idiom to QFormDataPartBuilderMate Barany2024-07-041-37/+109
| | | | | | | | | | | | | | | | | Change QFormDataBuilderPrivate to store a vector of QFormDataPartBuilderPrivates and pimplify QFormDataPartBuilder such that it stores a pointer to the QFormDataBuilderPrivate and an index into the vector. This makes it robust against QFDP::m_parts reallocations and we can make QFDBP copyable which has the benefit that if the user wants to "go back" to an earlier part, she can do so by storing the result of the original part() call by value. Found in API review. Task-number: QTBUG-125985 Pick-to: 6.8 Change-Id: I56e9018e539457e9494751bdb62509f84a680889 Reviewed-by: Marc Mutz <[email protected]>
* QFormDataPartBuilder: delay encoding of the part's name to build() timeMarc Mutz2024-06-271-29/+29
| | | | | | | | | | | This is a prerequisite for making QFormDataBuilder::part() return an existing part instead of creating new parts with the same name (idempotence), which was pointed out in API review. Pick-to: 6.8 Task-number: QTBUG-125985 Change-Id: I642e56cc7cb3562304573930a01aa1aafa817f36 Reviewed-by: Mate Barany <[email protected]>
* Add a note to QFormDataPartBuilder::setBodyDeviceMate Barany2024-06-251-0/+4
| | | | | | | | | | | | | | | If the body is sequential, QNAM::post should be called after body has emitted finished. As this is already mentioned in the documentation of QHttpPart::setBodyDevice it probably won't hurt to mention it here as well. Task-number: QTBUG-125985 Pick-to: 6.8 Change-Id: Iaa29c45b8da41a9af893523ff140afa9a0945f95 Reviewed-by: Paul Wicking <[email protected]> Reviewed-by: Mårten Nordheim <[email protected]>
* Add missing variable to code snippetMate Barany2024-06-211-1/+1
| | | | | | | | Task-number: QTBUG-125985 Pick-to: 6.8 Change-Id: I841339818a31253c6c7d444cd4ba2e66e965f3fa Reviewed-by: Marc Mutz <[email protected]> Reviewed-by: Mårten Nordheim <[email protected]>
* Pimplify QFormDataBuilderMate Barany2024-06-201-6/+20
| | | | | | | | | | Same will be done with QFormDataPartBuilder in a follow-up patch. Found in API review. Pick-to: 6.8 Change-Id: I863faad8b59ba16ef35b10afd9990c1b82c8634b Reviewed-by: Marc Mutz <[email protected]>
* [doc] QFormDataPartBuilder: mark private build() as \internalMarc Mutz2024-06-201-0/+2
| | | | | | | | It makes no sense to document (non-virtual) private functions. Pick-to: 6.8 Change-Id: Ifeed52ea5e9a5b8e358277140419c8d68204a45b Reviewed-by: Juha Vuolle <[email protected]>
* [doc] QFormDataBuilder: don't state the obviousMarc Mutz2024-06-201-2/+1
| | | | | | | | | If a function returns a unique_ptr by value, the caller cannot but take ownership of the payload object. Pick-to: 6.8 Change-Id: I0465e4daf42b57aa33203d66fdc3231ae9a88751 Reviewed-by: Juha Vuolle <[email protected]>
* Extract Method for escaping name/filename multipart parametersJuha Vuolle2024-06-201-10/+11
| | | | | | | Pick-to: 6.8 Task-number: QTBUG-125985 Change-Id: Iab10e7a198d883d66c9862073c737f7e703eddb6 Reviewed-by: Marc Mutz <[email protected]>
* Accept QASV for multipart 'name' fieldJuha Vuolle2024-06-181-3/+27
| | | | | | | | | | | | And adjust the encoding of 'name' parameter to always use UTF-8 / ASCII. This aligns with how other frameworks behave. Also amended docs to recommend ASCII for 'name'. Found in API review. Pick-to: 6.8 Change-Id: I54d1148bf95dece54b75c76914c49985da05e0b2 Reviewed-by: Marc Mutz <[email protected]>
* Adjust multipart 'filename' parameter encodingJuha Vuolle2024-06-181-24/+17
| | | | | | | | | | | | | | | | | | | | | | | | | The RFCs around these encodings are loose and allow several ways for dealing with non-ASCII characters. The encoding introduced in this commit should be interoperable and aligns with other frameworks (checked Curl, JS FormData, Postman, and Python requests). This consists of several adjustments: 1. Enclose the filename attribute in double quotes 2. If filename contains only ASCII characters, use them as-is 3. If filename contains characters beyond ASCII: 3.1. Encode them directly as raw UTF-8 to filename= 3.2. Set an additional filename*= parameter with percent encoded UTF-8. This is a legacy encoding for compatibility. Task-number: QTBUG-125985 Pick-to: 6.8 Change-Id: I5a6ad5388e4bb69e142caa7f6de7127526f441ad Reviewed-by: Marc Mutz <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* Add a simple example snippet to QFormDataBuilderMate Barany2024-06-041-0/+17
| | | | | | | | | | Add a small snippet that demonstrates how to create a multipart message with qformdatabuilder Pick-to: 6.8 Task-number: QTBUG-114647 Change-Id: Ie85cdcf40bd4333d06ead3f5b8dfabd799d2a9ab Reviewed-by: Marc Mutz <[email protected]>
* QFormDataPartBuilder: allow to override mime-type autodetectionMarc Mutz2024-06-011-12/+52
| | | | | | | | | If QT_CONFIG(mimetype) isn't set, this class was silently creating invalid output. If no mimetype is specified by the user and the type cannot be deduced then omit the content-type header. Change-Id: Iff15462b94fa1e992369df26f74b2bd64d523f31 Reviewed-by: Mårten Nordheim <[email protected]>
* QFormData(Part)Builder: simplify filename formattingMarc Mutz2024-05-301-59/+8
| | | | | | | | | | | | | | | | | | | | | | We don't need the bodyName member, because it's the same as originalBodyName, just encoded, and we can delay the encoding to build() time. This is not worse than the old code, since we anyway toString() the QAnyStringView unconditionally. So we don't need to visit the QASV and implement RFC2232 encoding for all three view types, we can just use the QString version, after toString(). This not only has the advantage of less code and not storing duplicate data, but we now also encode u8"ä.txt" the same as "ä.txt"_L1 and u"ä.txt", ie. using latin1, as required by Postel's Law, and not as UTF-8, as the old code did. Change-Id: If82a33a1cd09b859b3a4450a60083b1d3aedf7bc Reviewed-by: Mårten Nordheim <[email protected]> Reviewed-by: Marc Mutz <[email protected]>
* Add convenience classes to generate QHttpMultipart messagesMate Barany2024-05-301-0/+324
Constructing and composing a QHttpMultipart contains some aspects that are possible candidates for automating, such as setting the headers manually for each included part. As a reference, when issuing a default multipart with CURL, one does not need to manually set the headers. Add the class QFormDataPartBuilder to simplify the construction of QHttpPart objects. Add the class QFormDataBuilder to simplify the construction of QHttpMultiPart objects. [ChangeLog][QtNetwork][QFormDataBuilder] New class to help constructing multipart/form-data QHttpMultiParts. Fixes: QTBUG-114647 Change-Id: Ie035dabc01a9818d65a67c239807b50001fd984a Reviewed-by: Marc Mutz <[email protected]>