[Rust][Reqwest] Utilise percent-encoding for path params when using reqwest
Merged
GL
1mo ago+227+227+012345678901234567890123456789-25-25-01234567890123456789
This PR fixes path parameter space encoding by modifying the urlencode fn to use percent-encoding in reqwest and reqwest-trait. They were originally sent as + as opposed to %20.
To more closely match previous behaviour, everything except unreserved characters is encoded, RFC3986 refers.
I've also added percent-encoding to Cargo.toml (incl. manually maintained ones), a codegen test and regenerated the samples.
Fixes #25257.
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*.
IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed. - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
@frol @farcaller @richardwhiuk @paladinzh @jacob-pro @dsteeley
Summary by cubic
Fixes a bug in the generated Rust reqwest and reqwest-trait clients where spaces in path parameters were encoded as + instead of %20, breaking URL paths with spaces.
- Replaces the
urlencodehelper'sform_urlencoded::byte_serializeimplementation withpercent_encoding::utf8_percent_encode, using aPATH_ENCODING_SETthat percent-encodes all reserved characters per RFC3986 while keeping unreserved characters (-,.,_,~) untouched. This preserves the previous encoding behavior for other reserved characters while fixing spaces. - Adds the
percent-encodingdependency to generatedCargo.tomlfiles, a codegen test covering both libraries, and regenerated samples.