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
2023-08-04 14:35:26 -04:00
committed by GitHub
parent 7da3ac6eda
commit 2820b17d9d
3 changed files with 17 additions and 3 deletions

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 {