From 58c0320fd2bbe616155a914990b6c1b13e3ef4f2 Mon Sep 17 00:00:00 2001 From: Jordan Christiansen Date: Wed, 2 Jul 2025 14:38:14 -0500 Subject: [PATCH 1/2] Destroy original digest auth request prior to making new one --- lib/needle.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/needle.js b/lib/needle.js index e153b92eb..17d77de5a 100644 --- a/lib/needle.js +++ b/lib/needle.js @@ -572,6 +572,10 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data, if (auth_header) { config.headers['authorization'] = auth_header; + // Destroy the old request to prevent the unauthenticated digest request from causing the needle promise to catch/reject + // This is especially an issue with application/octet-stream request bodies where the server can cause the connection to reset + request.destroy(); + return self.send_request(count, method, uri, config, post_data, out, callback); } } From 2744aed1cb7551eeb31c7cfb2044534633012d05 Mon Sep 17 00:00:00 2001 From: Jordan Christiansen Date: Wed, 2 Jul 2025 14:41:16 -0500 Subject: [PATCH 2/2] fixed spacing --- lib/needle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/needle.js b/lib/needle.js index 17d77de5a..7b64b7782 100644 --- a/lib/needle.js +++ b/lib/needle.js @@ -572,7 +572,7 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data, if (auth_header) { config.headers['authorization'] = auth_header; - // Destroy the old request to prevent the unauthenticated digest request from causing the needle promise to catch/reject + // Destroy the old request to prevent the unauthenticated digest request from causing the needle promise to catch/reject // This is especially an issue with application/octet-stream request bodies where the server can cause the connection to reset request.destroy();