Skip to content

Preserve mixed-encoding multipart form data - #354

Open
sjh9714 wants to merge 1 commit into
ruby:masterfrom
sjh9714:codex/20261012-187-multipart-mixed-encodings
Open

sjh9714 wants to merge 1 commit into
ruby:masterfrom
sjh9714:codex/20261012-187-multipart-mixed-encodings

Conversation

@sjh9714

@sjh9714 sjh9714 commented Oct 12, 2026

Copy link
Copy Markdown

Summary

Fixes #187.

Multipart requests containing both UTF-8 text and binary data can raise Encoding::CompatibilityError while building the body. Append buffered multipart pieces as binary strings, preserving their bytes without transcoding or changing the caller's strings.

Changes

  • Keep buffered multipart headers and values compatible across encodings.
  • Add a local HTTP round-trip regression for mixed-encoding streams and inline file values, including non-ASCII names, with both Content-Length and chunked requests.

Testing

On macOS with Ruby 4.0.6:

  • bundle exec ruby -Ilib -Itest/lib -rhelper test/net/http/test_http.rb --name /test_set_form/ (8 tests)
  • bundle exec rake test (209 tests)
  • bundle exec rake rbs:test (29 tests)
  • bundle exec rake build

The new regression raises the reported encoding error before the fix. The other Ruby versions and operating systems in CI were not run locally.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generation of multipart post fail if inconsistent encodings given as input

1 participant