browser(firefox): use base64 to deliver post data (#3063)

This commit is contained in:
Pavel Feldman 2020-07-21 09:55:46 -07:00 committed by GitHub
parent 99658c2d32
commit 7f29275aa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 10 deletions

View file

@ -1,2 +1,2 @@
1135
Changed: yurys@chromium.org Tue Jul 21 09:15:13 PDT 2020
1136
Changed: pavel.feldman@gmail.com Tue Jul 21 09:33:13 PDT 2020

View file

@ -708,15 +708,16 @@ function readRequestPostData(httpChannel) {
}
// Read data from the stream.
let text = undefined;
let result = undefined;
try {
text = NetUtil.readInputStreamToString(iStream, iStream.available());
const converter = Cc['@mozilla.org/intl/scriptableunicodeconverter']
.createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = 'UTF-8';
text = converter.ConvertToUnicode(text);
const buffer = NetUtil.readInputStream(iStream, iStream.available());
const bytes = new Uint8Array(buffer);
let binary = '';
for (let i = 0; i < bytes.byteLength; i++)
binary += String.fromCharCode(bytes[i]);
result = btoa(binary);
} catch (err) {
text = undefined;
result = '';
}
// Seek locks the file, so seek to the beginning only if necko hasn't
@ -724,7 +725,7 @@ function readRequestPostData(httpChannel) {
// not till 459384 is fixed).
if (isSeekableStream && prevOffset == 0)
iStream.seek(Ci.nsISeekableStream.NS_SEEK_SET, 0);
return text;
return result;
}
function requestHeaders(httpChannel) {