Use Buffer.bytelenght for calculating the length

Summary:
This diff fixes the bug which showed the length of characters as the byte length when the response headers didn't have `content-length` in it.

This diff uses `Buffer.bytelength` api to calculate the same.

Reviewed By: danielbuechele

Differential Revision: D15899547

fbshipit-source-id: 29f4e8a741f4dd550b9191cc31bf6930065653b3
This commit is contained in:
Pritesh Nandgaonkar
2019-06-20 04:04:32 -07:00
committed by Facebook Github Bot
parent 9e13b90708
commit 3307576cb7

View File

@@ -538,10 +538,7 @@ class SizeColumn extends PureComponent<{
if (lengthString != null && lengthString != '') {
length = parseInt(lengthString, 10);
} else if (response.data) {
// FIXME: T41427687 This is probably not the correct way to determine
// the correct byte size of the response, because String.length returns
// the number of characters, not bytes.
length = atob(response.data).length;
length = Buffer.byteLength(response.data, 'base64');
}
return length;
}