Bug 935873 - MMS retry should handle modified input stream, Part 1 - Implementation, r=vyang

This commit is contained in:
Shao Hang Kao 2013-11-13 17:54:38 +08:00
parent 0735a30605
commit 3d15cffcc6
2 changed files with 14 additions and 5 deletions

View File

@ -1170,6 +1170,7 @@ SendTransaction.prototype = Object.create(CancellableTransaction.prototype, {
if (!this.istreamComposed) {
this.loadBlobs(this.msg.parts, (function () {
this.istream = MMS.PduHelper.compose(null, this.msg);
this.istreamSize = this.istream.available();
this.istreamComposed = true;
if (this.isCancelled) {
this.runCallbackIfValid(_MMS_ERROR_MESSAGE_DELETED, null);
@ -1200,6 +1201,13 @@ SendTransaction.prototype = Object.create(CancellableTransaction.prototype, {
this.retryCount++;
// the input stream may be read in the previous failure request so
// we have to re-compose it.
if (this.istreamSize == null ||
this.istreamSize != this.istream.available()) {
this.istream = MMS.PduHelper.compose(null, this.msg);
}
this.timer.initWithCallback(this.send.bind(this, retryCallback),
PREF_SEND_RETRY_INTERVAL,
Ci.nsITimer.TYPE_ONE_SHOT);

View File

@ -2446,17 +2446,18 @@ this.PduHelper = {
// Encode headersLen, DataLen
let headersLen = data.offset;
let content = part.content;
UintVar.encode(data, headersLen);
if (typeof part.content === "string") {
if (typeof content === "string") {
let charset;
if (contentType && contentType.params && contentType.params.charset &&
contentType.params.charset.charset) {
charset = contentType.params.charset.charset;
}
part.content = this.encodeStringContent(part.content, charset);
UintVar.encode(data, part.content.length);
content = this.encodeStringContent(content, charset);
UintVar.encode(data, content.length);
} else if (part.content instanceof Uint8Array) {
UintVar.encode(data, part.content.length);
UintVar.encode(data, content.length);
} else {
throw new TypeError();
}
@ -2470,7 +2471,7 @@ this.PduHelper = {
// Append per-part header
this.appendArrayToMultiStream(multiStream, data.array, data.offset);
// Append part content
this.appendArrayToMultiStream(multiStream, part.content, part.content.length);
this.appendArrayToMultiStream(multiStream, content, content.length);
}
},
};