| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Generated endpoints set Content-Type to multipart/form-data with the fixed boundary +++, so a file containing "\r\n--+++" was split at that point. Leave Content-Type unset for multipart bodies and let httpx2 add it with a random boundary, which also covers endpoints with several body types (openapi-generators#947). Fixes openapi-generators#1509
There was a problem hiding this comment.
Thanks for the fix!
Sorry, something went wrong.
> [!IMPORTANT] > Merging this pull request will create this release ## ❗️Breaking ❗ ### Switch from `httpx` to `httpx2` in generated clients [`httpx2`](https://pydantic.dev/docs/httpx2/get-started/) is largely compatible with `httpx` and should only be a breaking change for users who customize the internal `Client`. Thanks to @s-sajid-ali and @johnthagen for making this one happen in PR openapi-generators#1461 and discussion openapi-generators#1455! ## 🚀 Features - Update `uv_build` to 0.13 when using `--meta=uv` (openapi-generators#1507) ## 🐛 Fixes - Let httpx2 choose the multipart/form-data boundary (openapi-generators#1511) ### Let httpx2 choose the boundary for `multipart/form-data` requests Since 0.29.0, generated endpoints sent every `multipart/form-data` body with the fixed boundary `+++`, so an uploaded file containing `\r\n--+++` was cut short at that point (openapi-generators#1509). These bodies no longer set `Content-Type`, so httpx2 sets it with a random boundary for each request, as single-body endpoints did before 0.29.0. Endpoints with several body types still get a boundary (openapi-generators#947). Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Fixes #1509
Since #1005 every generated multipart/form-data request sets Content-Type: multipart/form-data; boundary=+++. httpx2 builds the body with that boundary, so a file that contains \r\n--+++ is split there and the server gets a truncated file plus a stray part.
This stops setting Content-Type for multipart/form-data bodies. httpx2 then adds the header with its own random boundary, the same way single-body endpoints worked before 0.29.0. For endpoints with several body types, the multipart branch no longer sets the header either, so #947 stays fixed: httpx2 still writes a boundary because the header isn't set. The other content types still set their header explicitly.
Changes:
Testing:
I didn't run the integration job locally because it needs the openapi-test-server container.