Skip to content

Prevent crash when decoding binary multipart request bodies#9680

Merged
srawlins merged 4 commits intoflutter:masterfrom
rishika0212:fix-multipart-binary-crash
Mar 3, 2026
Merged

Prevent crash when decoding binary multipart request bodies#9680
srawlins merged 4 commits intoflutter:masterfrom
rishika0212:fix-multipart-binary-crash

Conversation

@rishika0212
Copy link
Contributor

Fixes #9626

DevTools previously attempted to decode all request and response
bodies using utf8.decode(), which throws a FormatException when
binary data (e.g., multipart file uploads such as PDFs) is encountered.

This change:

• Adds defensive UTF-8 decoding for UI display
• Caches a descriptive placeholder for non-text binary bodies
• Preserves raw byte buffers for accurate HAR export
• Ensures binary bodies are Base64 encoded in HAR output
with the required encoding: "base64" field (HAR 1.2 spec)

Valid UTF-8 responses are unaffected.

This prevents the Network screen from hanging when viewing
multipart requests containing binary payloads while maintaining
correct export behavior.

@rishika0212 rishika0212 requested review from a team, bkonyi and kenzieschmoll as code owners March 1, 2026 19:49
Copy link
Contributor

@srawlins srawlins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great; thanks much!

@srawlins
Copy link
Contributor

srawlins commented Mar 3, 2026

Thanks again!

@srawlins srawlins merged commit ec07719 into flutter:master Mar 3, 2026
38 checks passed
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.

DevTools has trouble reading multipart requests

2 participants