Skip to content

Conversation

@hcthakur2004
Copy link

Summary

Fixes a regression where Content-Length is incorrectly calculated for io.StringIO objects containing multi-byte characters (like emojis).

The Issue

When io.StringIO is passed as data, super_len uses character count via len or tell() instead of the UTF-8 encoded byte length. This mismatch causes server errors when the encoded body is larger than the reported length.

The Fix

Updated super_len in utils.py to encode StringIO content to UTF-8 before calculating length, matching the behavior for standard strings and urllib3 expectations.

maxine-yx

This comment was marked as spam.

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.

2 participants