From bd99b1a330c0d378a3dae227c5685c9b8473eedb Mon Sep 17 00:00:00 2001 From: Sebastian Germesin <633833+neogermi@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:06:51 +0200 Subject: [PATCH] Update HttpClient.ts support both headers for digestAuth: www-authenticate and x-www-authenticate --- src/HttpClient.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HttpClient.ts b/src/HttpClient.ts index 02cd4962..3feebeb5 100644 --- a/src/HttpClient.ts +++ b/src/HttpClient.ts @@ -546,10 +546,10 @@ export class HttpClient extends EventEmitter { } let response = await undiciRequest(requestUrl, requestOptions as UndiciRequestOption); - if (response.statusCode === 401 && response.headers['www-authenticate'] && + if (response.statusCode === 401 && (response.headers['www-authenticate'] || response.headers['x-www-authenticate']) && !requestOptions.headers.authorization && args.digestAuth) { // handle digest auth - const authenticateHeaders = response.headers['www-authenticate']; + const authenticateHeaders = response.headers['www-authenticate'] ?? response.headers['x-www-authenticate']; const authenticate = Array.isArray(authenticateHeaders) ? authenticateHeaders.find(authHeader => authHeader.startsWith('Digest ')) : authenticateHeaders;