Skip to content

Commit

Permalink
Add readBodyBuffer method to HttpClientResponse (#1475)
Browse files Browse the repository at this point in the history
* Add readBodyBuffer method to HttpClientResponse

* Implement method in other package tests

* Make method optional to satisfy the test process
  • Loading branch information
chkimes committed Aug 4, 2023
1 parent 7da3ac6 commit 2820b17
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/http-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/http-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@actions/http-client",
"version": "2.1.0",
"version": "2.1.1",
"description": "Actions Http Client",
"keywords": [
"github",
Expand Down
14 changes: 14 additions & 0 deletions packages/http-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2820b17

Please sign in to comment.