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 1136
Changed: yurys@chromium.org Tue Jul 21 09:15:13 PDT 2020 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. // Read data from the stream.
let text = undefined; let result = undefined;
try { try {
text = NetUtil.readInputStreamToString(iStream, iStream.available()); const buffer = NetUtil.readInputStream(iStream, iStream.available());
const converter = Cc['@mozilla.org/intl/scriptableunicodeconverter'] const bytes = new Uint8Array(buffer);
.createInstance(Ci.nsIScriptableUnicodeConverter); let binary = '';
converter.charset = 'UTF-8'; for (let i = 0; i < bytes.byteLength; i++)
text = converter.ConvertToUnicode(text); binary += String.fromCharCode(bytes[i]);
result = btoa(binary);
} catch (err) { } catch (err) {
text = undefined; result = '';
} }
// Seek locks the file, so seek to the beginning only if necko hasn't // 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). // not till 459384 is fixed).
if (isSeekableStream && prevOffset == 0) if (isSeekableStream && prevOffset == 0)
iStream.seek(Ci.nsISeekableStream.NS_SEEK_SET, 0); iStream.seek(Ci.nsISeekableStream.NS_SEEK_SET, 0);
return text; return result;
} }
function requestHeaders(httpChannel) { function requestHeaders(httpChannel) {