зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1305162: Part 1b - Properly serialize nsIMIMEInputStream in RemoteWebNavigation. r=dragana
MozReview-Commit-ID: 6PePVAEL1Px --HG-- extra : rebase_source : e7c010b030e2751e3d6fffe420c608a6e4d5e303
This commit is contained in:
Родитель
6587016b11
Коммит
48c15c9915
|
@ -18,8 +18,19 @@ function makeURI(url) {
|
|||
return Services.io.newURI(url);
|
||||
}
|
||||
|
||||
function readInputStreamToString(aStream) {
|
||||
return NetUtil.readInputStreamToString(aStream, aStream.available());
|
||||
function serializeInputStream(aStream) {
|
||||
let data = {
|
||||
content: NetUtil.readInputStreamToString(aStream, aStream.available()),
|
||||
};
|
||||
|
||||
if (aStream instanceof Ci.nsIMIMEInputStream) {
|
||||
data.headers = new Map();
|
||||
aStream.visitHeaders((name, value) => {
|
||||
data.headers.set(name, value);
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function RemoteWebNavigation() {
|
||||
|
@ -81,8 +92,8 @@ RemoteWebNavigation.prototype = {
|
|||
flags: aLoadFlags,
|
||||
referrer: aReferrer ? aReferrer.spec : null,
|
||||
referrerPolicy: aReferrerPolicy,
|
||||
postData: aPostData ? readInputStreamToString(aPostData) : null,
|
||||
headers: aHeaders ? readInputStreamToString(aHeaders) : null,
|
||||
postData: aPostData ? serializeInputStream(aPostData) : null,
|
||||
headers: aHeaders ? serializeInputStream(aHeaders) : null,
|
||||
baseURI: aBaseURI ? aBaseURI.spec : null,
|
||||
triggeringPrincipal: aTriggeringPrincipal
|
||||
? Utils.serializePrincipal(aTriggeringPrincipal)
|
||||
|
|
|
@ -26,10 +26,22 @@ if (AppConstants.MOZ_CRASHREPORTER) {
|
|||
"nsICrashReporter");
|
||||
}
|
||||
|
||||
function makeInputStream(aString) {
|
||||
function makeInputStream(data) {
|
||||
let stream = Cc["@mozilla.org/io/string-input-stream;1"].
|
||||
createInstance(Ci.nsISupportsCString);
|
||||
stream.data = aString;
|
||||
stream.data = data.content;
|
||||
|
||||
if (data.headers) {
|
||||
let mimeStream = Cc["@mozilla.org/network/mime-input-stream;1"]
|
||||
.createInstance(Ci.nsIMIMEInputStream);
|
||||
|
||||
mimeStream.setData(stream);
|
||||
for (let [name, value] of data.headers) {
|
||||
mimeStream.addHeader(name, value);
|
||||
}
|
||||
return mimeStream;
|
||||
}
|
||||
|
||||
return stream; // XPConnect will QI this to nsIInputStream for us.
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче