Bug 1261585 - Necko does content conversions for TracableChannel so devtool does not need to do it separately. r=ochameau

--HG--
extra : histedit_source : 636c4eb4f6c0b9e12327adae8745071de62b512d
This commit is contained in:
Dragana Damjanovic 2016-12-20 06:45:00 -05:00
Родитель d8bb7d0fa3
Коммит 283ca17883
1 изменённых файлов: 4 добавлений и 48 удалений

Просмотреть файл

@ -427,48 +427,9 @@ NetworkResponseListener.prototype = {
* @param nsISupports context
*/
onStartRequest: function (request) {
// Converter will call this again, we should just ignore that.
if (this.request) {
return;
}
this.request = request;
this._getSecurityInfo();
this._findOpenResponse();
// We need to track the offset for the onDataAvailable calls where
// we pass the data from our pipe to the converter.
this.offset = 0;
// In the multi-process mode, the conversion happens on the child
// side while we can only monitor the channel on the parent
// side. If the content is gzipped, we have to unzip it
// ourself. For that we use the stream converter services. Do not
// do that for Service workers as they are run in the child
// process.
let channel = this.request;
if (!this.httpActivity.fromServiceWorker &&
channel instanceof Ci.nsIEncodedChannel &&
channel.contentEncodings &&
!channel.applyConversion) {
let encodingHeader = channel.getResponseHeader("Content-Encoding");
let scs = Cc["@mozilla.org/streamConverters;1"]
.getService(Ci.nsIStreamConverterService);
let encodings = encodingHeader.split(/\s*\t*,\s*\t*/);
let nextListener = this;
let acceptedEncodings = ["gzip", "deflate", "br", "x-gzip", "x-deflate"];
for (let i in encodings) {
// There can be multiple conversions applied
let enc = encodings[i].toLowerCase();
if (acceptedEncodings.indexOf(enc) > -1) {
this.converter = scs.asyncConvertData(enc, "uncompressed",
nextListener, null);
nextListener = this.converter;
}
}
if (this.converter) {
this.converter.onStartRequest(this.request, null);
}
}
// Asynchronously wait for the data coming from the request.
this.setAsyncListener(this.sink.inputStream, this);
},
@ -634,7 +595,6 @@ NetworkResponseListener.prototype = {
this.httpActivity = null;
this.sink = null;
this.inputStream = null;
this.converter = null;
this.request = null;
this.owner = null;
},
@ -662,15 +622,11 @@ NetworkResponseListener.prototype = {
if (available != -1) {
if (available != 0) {
if (this.converter) {
this.converter.onDataAvailable(this.request, null, stream,
this.offset, available);
} else {
this.onDataAvailable(this.request, null, stream, this.offset,
available);
}
// Note that passing 0 as the offset here is wrong, but the
// onDataAvailable() method does not use the offset, so it does not
// matter.
this.onDataAvailable(this.request, null, stream, 0, available);
}
this.offset += available;
this.setAsyncListener(stream, this);
} else {
this.onStreamClose();