Repository navigation
fix(fetch): reject Request body for GET and HEAD methods - #5201
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aligns Boa’s Request constructor with the Fetch Standard by rejecting request bodies for GET and HEAD methods, addressing issue #5200.
Changes:
- Add a
GET/HEAD+ body validation inRequestInit::into_request_builder, returning aTypeErrorwhen violated. - Add regression tests asserting
new Request(..., { method: "GET"/"HEAD", body: "x" })throws aTypeError.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| core/runtime/src/fetch/request.rs | Adds GET/HEAD body rejection logic during request construction. |
| core/runtime/src/fetch/tests/request.rs | Adds regression tests for GET/HEAD requests with an explicit body. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Test262 conformance changes
Tested main commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5201 +/- ##
===========================================
+ Coverage 47.24% 59.87% +12.63%
===========================================
Files 476 566 +90
Lines 46892 62820 +15928
===========================================
+ Hits 22154 37615 +15461
- Misses 24738 25205 +467 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…move HasBody extension
b99eec4 to
3273766
Compare
jedel1043
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution!
This Pull Request fixes/closes #5200.
It changes the following:
into_request_buildernow checks if the method isGETorHEADand throws aTypeErrorif a body is provided, matching the Fetch Standard.GETandHEADcases.Testing:
cargo test -p boa_runtime request -- --nocaptureSpec reference: https://fetch.spec.whatwg.org/#dom-request