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
This commit is contained in:
Chad Kimes authored and GitHub committed 2023-08-04 14:35:26 -04:00
1 parent 159e42038d
commit 60aa416760
3 files changed
+17 -3

No files matched your search

+14
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 {