Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /fetch/api/request/request-stream-methods.h2.any.html - WPT Dashboard Interop Dashboard
- /fetch/api/request/request-stream-methods.h2.any.serviceworker.html - WPT Dashboard Interop Dashboard
- /fetch/api/request/request-stream-methods.h2.any.sharedworker.html - WPT Dashboard Interop Dashboard
- /fetch/api/request/request-stream-methods.h2.any.worker.html - WPT Dashboard Interop Dashboard
// META: global=window,worker
for (const method of ["POST", "PUT", "PATCH", "DELETE", "CUSTOM"]) {
for (const empty of [false, true]) {
promise_test(async t => {
const body = empty ? "" : "streamed request body";
const response = await fetch("/fetch/api/resources/echo-content.h2.py", {
method,
body: new ReadableStream({
async start(controller) {
await new Promise(resolve => t.step_timeout(resolve, 0));
if (!empty) {
controller.enqueue(new TextEncoder().encode(body));
}
controller.close();
},
}),
duplex: "half",
});
assert_equals(response.status, 200);
assert_equals(await response.text(), body);
}, `HTTP/2 ${method} with an ${empty ? "empty" : "asynchronously produced"} streaming body`);
}
}