1
0
Fork 0

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
pull/1483/head
Chad Kimes 2023-08-04 14:35:26 -04:00 committed by GitHub
parent 7da3ac6eda
commit 2820b17d9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -1,12 +1,12 @@
{ {
"name": "@actions/http-client", "name": "@actions/http-client",
"version": "2.1.0", "version": "2.1.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@actions/http-client", "name": "@actions/http-client",
"version": "2.1.0", "version": "2.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"tunnel": "^0.0.6" "tunnel": "^0.0.6"

View File

@ -1,6 +1,6 @@
{ {
"name": "@actions/http-client", "name": "@actions/http-client",
"version": "2.1.0", "version": "2.1.1",
"description": "Actions Http Client", "description": "Actions Http Client",
"keywords": [ "keywords": [
"github", "github",

View File

@ -102,6 +102,20 @@ export class HttpClientResponse {
}) })
}) })
} }
async readBodyBuffer?(): Promise<Buffer> {
return new Promise<Buffer>(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 { export function isHttps(requestUrl: string): boolean {