fix(fetch): reject Request body for GET and HEAD methods#5201
fix(fetch): reject Request body for GET and HEAD methods#5201HiteshShonak wants to merge 2 commits intoboa-dev:mainfrom
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.81% +12.57%
===========================================
Files 476 582 +106
Lines 46892 63470 +16578
===========================================
+ Hits 22154 37965 +15811
- Misses 24738 25505 +767 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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