mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
fix: specify AbortSignal for native http requests (#11126)
This commit is contained in:
parent
e86c1710f4
commit
40b083c540
2 changed files with 6 additions and 1 deletions
|
@ -56,9 +56,12 @@ unitTest({ perms: { net: true } }, async function httpServerBasic() {
|
||||||
const resp = await fetch("http://127.0.0.1:4501/", {
|
const resp = await fetch("http://127.0.0.1:4501/", {
|
||||||
headers: { "connection": "close" },
|
headers: { "connection": "close" },
|
||||||
});
|
});
|
||||||
|
const clone = resp.clone();
|
||||||
const text = await resp.text();
|
const text = await resp.text();
|
||||||
assertEquals(text, "Hello World");
|
assertEquals(text, "Hello World");
|
||||||
assertEquals(resp.headers.get("foo"), "bar");
|
assertEquals(resp.headers.get("foo"), "bar");
|
||||||
|
const cloneText = await clone.text();
|
||||||
|
assertEquals(cloneText, "Hello World");
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
const errors = window.__bootstrap.errors.errors;
|
const errors = window.__bootstrap.errors.errors;
|
||||||
const core = window.Deno.core;
|
const core = window.Deno.core;
|
||||||
const { ReadableStream } = window.__bootstrap.streams;
|
const { ReadableStream } = window.__bootstrap.streams;
|
||||||
|
const abortSignal = window.__bootstrap.abortSignal;
|
||||||
|
|
||||||
function serveHttp(conn) {
|
function serveHttp(conn) {
|
||||||
const rid = Deno.core.opSync("op_http_start", conn.rid);
|
const rid = Deno.core.opSync("op_http_start", conn.rid);
|
||||||
|
@ -72,7 +73,8 @@
|
||||||
headersList,
|
headersList,
|
||||||
body !== null ? new InnerBody(body) : null,
|
body !== null ? new InnerBody(body) : null,
|
||||||
);
|
);
|
||||||
const request = fromInnerRequest(innerRequest, null, "immutable");
|
const signal = abortSignal.newSignal();
|
||||||
|
const request = fromInnerRequest(innerRequest, signal, "immutable");
|
||||||
|
|
||||||
const respondWith = createRespondWith(this, responseSenderRid);
|
const respondWith = createRespondWith(this, responseSenderRid);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue