-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: content-type parsing should handle charset and boundary params #6917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis PR fixes a bug where Content-Type headers containing additional parameters (charset, boundary) were causing incorrect form-encoded POST body formatting. A media type parsing improvement enables proper detection of form-encoded and multipart requests regardless of header parameters, with comprehensive test coverage added for various scenarios. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-electron/src/ipc/network/index.js (1)
517-531: NormalizemediaTypeto handle case-insensitive header values.
HTTP media types are case-insensitive; a mixed-case value would skip the encoding branch. Consider lowercasing when extracting.💡 Suggested adjustment
- if (contentTypeHeader && request.headers[contentTypeHeader]) { - mediaType = request.headers[contentTypeHeader].split(';')[0].trim(); - } + if (contentTypeHeader && request.headers[contentTypeHeader]) { + mediaType = request.headers[contentTypeHeader].split(';')[0].trim().toLowerCase(); + }
🧹 Nitpick comments (1)
tests/request/encoding/form-url-encoding.spec.ts (1)
16-186: Factor repeated UI steps into helpers/locators for maintainability.
The three tests repeat method selection, body-mode selection, and send/wait steps. Extracting small helpers makes updates safer if selectors change.♻️ Example helper extraction
test.describe('Form URL Encoding with Content-Type Parameters', () => { + const selectPostMethod = async (page) => { + await page.locator('.method-selector').click(); + await page.locator('.dropdown-item').filter({ hasText: 'POST' }).click(); + }; + + const sendRequest = async (page) => { + await page.getByTestId('send-arrow-icon').click(); + await page.getByTestId('response-status-code').waitFor({ state: 'visible', timeout: 15000 }); + };Apply similarly across the three tests to replace the repeated steps.
Description
Fixes #6916 by parsing the Content-Type value to extract the
media-typecomponent and use that for determining whether or not to form-urlencode parameters.Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Note:
I wasn't quite sure how to answer the first question in the Contribution Checklist (whether I used AI "significantly"). I answered "no", but I'm unsure what the threshold for "significantly" is.
In full disclosure, while I authored most of this change myself, I used Windsurf/Cascade editor for the following:
In my opinion, this isn't "significant" use, as it's using an AI-enhanced editor as a tool rather than a vibe-coding style code generator, but I want to be as transparent as possible due to lack of a definition of what "significant" entails in this case. I'm willing to update my answer to "yes" if my use does meet that threshold.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.