Skip to content

Commit 193c27b

Browse files
Thomas Hurstzyc9012
Thomas Hurst
andcommitted
Handle HTTP chunking across multi-byte boundaries
When a response contains multi-byte UTF-8 characters that cross chunk boundaries, appending the two halves to the intermediate string results in two Unicode Replacement Characters being inserted instead of the two halves being joined. Set the response encoding to UTF-8 to ensure it buffers partial characters between chunks. Resolves #22 Co-authored-by: zyc9012 <[email protected]>
1 parent 1cdcf24 commit 193c27b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export function execute(
6363
return new Promise((resolve, reject) => {
6464
let timer: number;
6565
const req = https.get(url, (resp) => {
66+
resp.setEncoding("utf8");
6667
let data = "";
6768

6869
// A chunk of data has been recieved.

0 commit comments

Comments
 (0)