node-digest-auth
Advanced tools
+1
-1
| { | ||
| "name": "node-digest-auth", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "Digest Auth Package", | ||
@@ -5,0 +5,0 @@ "main": "dist/digestClient.js", |
+25
-13
@@ -44,14 +44,24 @@ import * as crypto from "crypto"; | ||
| callback: (res: http.IncomingMessage) => void, | ||
| ) { | ||
| ): { request: http.ClientRequest; getSocket: () => any } { | ||
| // Create the request but don't end it immediately | ||
| const req = this.httpRequest.request(options, (res) => { | ||
| this._handleResponse(options, res, callback); | ||
| }); | ||
| // Listen for the socket event to capture the underlying socket | ||
| let socket: any = null; | ||
| req.on("socket", (sock: any) => { | ||
| socket = sock; | ||
| }); | ||
| // If shouldEnd is true, end the request | ||
| if (this.shouldEnd) { | ||
| return this.httpRequest | ||
| .request(options, (res) => { | ||
| this._handleResponse(options, res, callback); | ||
| }) | ||
| .end(); | ||
| } else { | ||
| return this.httpRequest.request(options, (res) => { | ||
| this._handleResponse(options, res, callback); | ||
| }); | ||
| req.end(); | ||
| } | ||
| // Return the request and the captured socket | ||
| return { | ||
| request: req, | ||
| getSocket: () => socket, | ||
| }; | ||
| } | ||
@@ -116,7 +126,9 @@ | ||
| const req = http.request(options, callback); | ||
| if (this.shouldEnd) { | ||
| return http.request(options, callback).end(); | ||
| } else { | ||
| return http.request(options, callback); | ||
| req.end(); | ||
| } | ||
| return req; | ||
| } | ||
@@ -123,0 +135,0 @@ |
13242
2.13%311
2.3%