Skip to content

Commit

Permalink
implemented http(s).ClientRequest.abort()
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Rogg committed Dec 11, 2019
1 parent 6746d03 commit 6b833f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib_js/internal/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ class ClientRequest extends stream.Writable {

let message = new IncomingMessage();
message._httpMain = this;
// this._httpMessage = message;
this._httpMessage = message;

message.connection = message.socket = socket;

Expand Down Expand Up @@ -784,6 +784,20 @@ class ClientRequest extends stream.Writable {

native.httpWriteHead(this.connection._socketFD, headersAsTxt, len, chunked);
}

abort() {
this.aborted = true;
if(this._httpMessage)
this._httpMessage.aborted = true;

this.emit('abort');
if(this._httpMessage)
this._httpMessage.emit('aborted');
if(this._httpMessage)
this._httpMessage.destroy();
else
this.destroy();
}
}

module.exports = {
Expand Down
3 changes: 3 additions & 0 deletions lib_js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"rootDir": "./",
"baseUrl": "./",
"outDir": "./build",
"noStrictGenericChecks": true,
"skipLibCheck": true,
"strictFunctionTypes": false,
"lib": [
"es2015",
"dom"
Expand Down

0 comments on commit 6b833f2

Please sign in to comment.