From 60aa4167608a8d20135b3682baed250c06e4eb64 Mon Sep 17 00:00:00 2001 From: Chad Kimes <1936066+chkimes@users.noreply.github.com> Date: Fri, 4 Aug 2023 14:35:26 -0400 Subject: [PATCH] Add readBodyBuffer method to HttpClientResponse (#1475) * Add readBodyBuffer method to HttpClientResponse * Implement method in other package tests * Make method optional to satisfy the test process --- package-lock.json | 4 ++-- package.json | 2 +- src/index.ts | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 333acf7..503a680 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@actions/http-client", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@actions/http-client", - "version": "2.1.0", + "version": "2.1.1", "license": "MIT", "dependencies": { "tunnel": "^0.0.6" diff --git a/package.json b/package.json index 61af4ee..f0c747b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@actions/http-client", - "version": "2.1.0", + "version": "2.1.1", "description": "Actions Http Client", "keywords": [ "github", diff --git a/src/index.ts b/src/index.ts index ebea203..a63e61b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -102,6 +102,20 @@ export class HttpClientResponse { }) }) } + + async readBodyBuffer?(): Promise { + return new Promise(async resolve => { + const chunks: Buffer[] = [] + + this.message.on('data', (chunk: Buffer) => { + chunks.push(chunk) + }) + + this.message.on('end', () => { + resolve(Buffer.concat(chunks)) + }) + }) + } } export function isHttps(requestUrl: string): boolean {