Skip to content

add Request body methods - #5322

Open
Monti-27 wants to merge 4 commits into
boa-dev:mainfrom
Monti-27:requestbody
Open

add Request body methods#5322
Monti-27 wants to merge 4 commits into
boa-dev:mainfrom
Monti-27:requestbody

Conversation

@Monti-27

Copy link
Copy Markdown
Contributor

Fixes #5321

This adds the Body methods currently supported by Boa to Request, and tracks body usage so Request cloning and transfer behave correctly.

Tests:

  • cargo test -p boa_runtime request -- --nocapture
  • cargo make run-ci

@Monti-27
Monti-27 requested a review from a team as a code owner April 11, 2026 20:46
@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Apr 11, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Apr 11, 2026
@github-actions github-actions Bot added C-Tests Issues and PRs related to the tests. C-Runtime Issues and PRs related to Boa's runtime features labels Apr 11, 2026
@github-actions

github-actions Bot commented Apr 11, 2026

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,125 53,125 0
Passed 51,049 51,049 0
Ignored 1,482 1,482 0
Failed 594 594 0
Panics 0 0 0
Conformance 96.09% 96.09% 0.00%

Tested main commit: da570fd74bb6cd5b0fc01363451eb710b7ab5a0c
Tested PR commit: 0b5b0044d963624f9a77853ed95d1397441633a6
Compare commits: da570fd...0b5b004

@codecov

codecov Bot commented Apr 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.74%. Comparing base (6ddc2b4) to head (0b5b004).
⚠️ Report is 1004 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5322       +/-   ##
===========================================
+ Coverage   47.24%   59.74%   +12.49%     
===========================================
  Files         476      591      +115     
  Lines       46892    63749    +16857     
===========================================
+ Hits        22154    38084    +15930     
- Misses      24738    25665      +927     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread core/runtime/src/fetch/request.rs
Comment thread core/runtime/src/fetch/request.rs
Comment thread core/runtime/src/fetch/request.rs Outdated
Comment thread core/runtime/src/fetch/request.rs
Comment thread core/runtime/src/fetch/request.rs
Comment thread core/runtime/src/fetch/request.rs
Comment thread core/runtime/src/fetch/request.rs
@Monti-27
Monti-27 requested a review from HalidOdat April 14, 2026 19:40
Comment on lines +5 to +35
pub(super) fn bytes(body: Rc<Vec<u8>>, context: &mut Context) -> JsPromise {
JsPromise::from_async_fn(
async move |context| {
JsUint8Array::from_iter(body.iter().copied(), &mut context.borrow_mut()).map(Into::into)
},
context,
)
}

pub(super) fn text(body: Rc<Vec<u8>>, context: &mut Context) -> JsPromise {
JsPromise::from_async_fn(
async move |_| {
let body = String::from_utf8_lossy(body.as_ref());
Ok(JsString::from(body).into())
},
context,
)
}

pub(super) fn json(body: Rc<Vec<u8>>, context: &mut Context) -> JsPromise {
JsPromise::from_async_fn(
async move |context| {
let json_string = String::from_utf8_lossy(body.as_ref());
let json = serde_json::from_str::<serde_json::Value>(&json_string)
.map_err(|e| JsNativeError::syntax().with_message(e.to_string()))?;

JsValue::from_json(&json, &mut context.borrow_mut())
},
context,
)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are you using async functions here? I don't see any awaits in the callbacks, so you could use a plain JsPromise::new

@jedel1043 jedel1043 added Waiting On Author Waiting on PR changes from the author and removed Waiting On Review Waiting on reviews from the maintainers labels Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Runtime Issues and PRs related to Boa's runtime features C-Tests Issues and PRs related to the tests. Waiting On Author Waiting on PR changes from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request is missing Body methods

3 participants