docs: mention issues with buffer encoding (#12141)

This commit is contained in:
Alex Rudenko 2024-03-25 09:30:56 +01:00 committed by GitHub
parent 168856ec87
commit 00fa75ec9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 3 deletions

View File

@ -17,3 +17,7 @@ class HTTPResponse {
**Returns:**
Promise<Buffer>
## Remarks
The buffer might be re-encoded by the browser based on HTTP-headers or other heuristics. If the browser failed to detect the correct encoding, the buffer might be encoded incorrectly. See https://github.com/puppeteer/puppeteer/issues/6478.

View File

@ -171,7 +171,7 @@ The status text of the response (e.g. usually an "OK" for a success).
</td><td>
Promise which resolves to a text representation of response body.
Promise which resolves to a text (utf8) representation of response body.
</td></tr>
<tr><td>

View File

@ -4,7 +4,7 @@ sidebar_label: HTTPResponse.text
# HTTPResponse.text() method
Promise which resolves to a text representation of response body.
Promise which resolves to a text (utf8) representation of response body.
#### Signature:

View File

@ -81,11 +81,18 @@ export abstract class HTTPResponse {
/**
* Promise which resolves to a buffer with response body.
*
* @remarks
*
* The buffer might be re-encoded by the browser
* based on HTTP-headers or other heuristics. If the browser
* failed to detect the correct encoding, the buffer might
* be encoded incorrectly. See https://github.com/puppeteer/puppeteer/issues/6478.
*/
abstract buffer(): Promise<Buffer>;
/**
* Promise which resolves to a text representation of response body.
* Promise which resolves to a text (utf8) representation of response body.
*/
async text(): Promise<string> {
const content = await this.buffer();