mirror of
https://github.com/denoland/deno.git
synced 2025-01-22 06:09:25 -05:00
fix(node): http.IncomingMessageForClient.complete (#19302)
Closes https://github.com/denoland/deno/issues/19238
This commit is contained in:
parent
429da4ee2d
commit
cf8b7bb530
2 changed files with 8 additions and 0 deletions
|
@ -190,15 +190,21 @@ Deno.test("[node/http] request default protocol", async () => {
|
||||||
const server = http.createServer((_, res) => {
|
const server = http.createServer((_, res) => {
|
||||||
res.end("ok");
|
res.end("ok");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// @ts-ignore IncomingMessageForClient
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
|
let clientRes: any;
|
||||||
server.listen(() => {
|
server.listen(() => {
|
||||||
const req = http.request(
|
const req = http.request(
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
{ host: "localhost", port: (server.address() as any).port },
|
{ host: "localhost", port: (server.address() as any).port },
|
||||||
(res) => {
|
(res) => {
|
||||||
|
assertEquals(res.complete, false);
|
||||||
res.on("data", () => {});
|
res.on("data", () => {});
|
||||||
res.on("end", () => {
|
res.on("end", () => {
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
|
clientRes = res;
|
||||||
assertEquals(res.statusCode, 200);
|
assertEquals(res.statusCode, 200);
|
||||||
promise2.resolve();
|
promise2.resolve();
|
||||||
},
|
},
|
||||||
|
@ -210,6 +216,7 @@ Deno.test("[node/http] request default protocol", async () => {
|
||||||
});
|
});
|
||||||
await promise;
|
await promise;
|
||||||
await promise2;
|
await promise2;
|
||||||
|
assertEquals(clientRes!.complete, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test("[node/http] request with headers", async () => {
|
Deno.test("[node/http] request with headers", async () => {
|
||||||
|
|
|
@ -970,6 +970,7 @@ export class IncomingMessageForClient extends NodeReadable {
|
||||||
// any messages, before ever calling this. In that case, just skip
|
// any messages, before ever calling this. In that case, just skip
|
||||||
// it, since something else is destroying this connection anyway.
|
// it, since something else is destroying this connection anyway.
|
||||||
_destroy(err, cb) {
|
_destroy(err, cb) {
|
||||||
|
this.complete = true;
|
||||||
if (!this.readableEnded || !this.complete) {
|
if (!this.readableEnded || !this.complete) {
|
||||||
this.aborted = true;
|
this.aborted = true;
|
||||||
this.emit("aborted");
|
this.emit("aborted");
|
||||||
|
|
Loading…
Add table
Reference in a new issue