Skip to content

Commit 2820b17

Browse files
authored
Add readBodyBuffer method to HttpClientResponse (actions#1475)
* Add readBodyBuffer method to HttpClientResponse * Implement method in other package tests * Make method optional to satisfy the test process
1 parent 7da3ac6 commit 2820b17

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

packages/http-client/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/http-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@actions/http-client",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Actions Http Client",
55
"keywords": [
66
"github",

packages/http-client/src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ export class HttpClientResponse {
102102
})
103103
})
104104
}
105+
106+
async readBodyBuffer?(): Promise<Buffer> {
107+
return new Promise<Buffer>(async resolve => {
108+
const chunks: Buffer[] = []
109+
110+
this.message.on('data', (chunk: Buffer) => {
111+
chunks.push(chunk)
112+
})
113+
114+
this.message.on('end', () => {
115+
resolve(Buffer.concat(chunks))
116+
})
117+
})
118+
}
105119
}
106120

107121
export function isHttps(requestUrl: string): boolean {

0 commit comments

Comments
 (0)