Add json(), text() and other missing methods to JsRequest#5341
Add json(), text() and other missing methods to JsRequest#5341tomasol wants to merge 4 commits intoboa-dev:mainfrom
json(), text() and other missing methods to JsRequest#5341Conversation
Test262 conformance changes
Tested main commit: |
b690a67 to
30715ff
Compare
Since the inner request does not contain body anymore, add a way to obtain the body. If the body future is not resolved yet, return `None`.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5341 +/- ##
===========================================
+ Coverage 47.24% 59.63% +12.38%
===========================================
Files 476 590 +114
Lines 46892 63811 +16919
===========================================
+ Hits 22154 38053 +15899
- Misses 24738 25758 +1020 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I don't think this is the correct approach to enable fetching the body of a request. From what I investigated, |
| /// duplicating or double-reading it. | ||
| #[unsafe_ignore_trace] | ||
| body: Rc<RefCell<BodyState>>, |
There was a problem hiding this comment.
Also this will leak, because BodyState could be a future with Gc'd objects in it, making it possible to leak objects using this since the GC won't trace through the body.
|
The responsibility of fetching the body should be lifted to the |
The JS-facing body getter returning a proper
The concern is technically valid at the type level, |
Then we are just implementing something that will be removed in the future, right? Seems like a waste to hack around this instead of offering a proper API for readable streams.
We generally don't assume how users interact with APIs, because we have seen so many weird usages that we just go with the safest option. Leaking here is not the safest option. |
|
Adding Ad Gc object leak: |
Uh not really. Offering a
That does not work, because Rust does not understand the concept of implementing |
|
I did not propose passing async blocks but an implementation of |
Are you suggesting that we force every user to manually implement
Not necessarily. We have an API to convert a Future into a JsPromise, so users can just enqueue an async job that eventually resolves a promise without having to deal with storing |
Adds request methods
method,url,headers, and allows reading the request body withtext,json,form_data. Host can supply the body asynchronously.