зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
d8bb7d0fa3
Коммит
283ca17883
|
@ -427,48 +427,9 @@ NetworkResponseListener.prototype = {
|
||||||
* @param nsISupports context
|
* @param nsISupports context
|
||||||
*/
|
*/
|
||||||
onStartRequest: function (request) {
|
onStartRequest: function (request) {
|
||||||
// Converter will call this again, we should just ignore that.
|
|
||||||
if (this.request) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
this._getSecurityInfo();
|
this._getSecurityInfo();
|
||||||
this._findOpenResponse();
|
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.
|
// Asynchronously wait for the data coming from the request.
|
||||||
this.setAsyncListener(this.sink.inputStream, this);
|
this.setAsyncListener(this.sink.inputStream, this);
|
||||||
},
|
},
|
||||||
|
@ -634,7 +595,6 @@ NetworkResponseListener.prototype = {
|
||||||
this.httpActivity = null;
|
this.httpActivity = null;
|
||||||
this.sink = null;
|
this.sink = null;
|
||||||
this.inputStream = null;
|
this.inputStream = null;
|
||||||
this.converter = null;
|
|
||||||
this.request = null;
|
this.request = null;
|
||||||
this.owner = null;
|
this.owner = null;
|
||||||
},
|
},
|
||||||
|
@ -662,15 +622,11 @@ NetworkResponseListener.prototype = {
|
||||||
|
|
||||||
if (available != -1) {
|
if (available != -1) {
|
||||||
if (available != 0) {
|
if (available != 0) {
|
||||||
if (this.converter) {
|
// Note that passing 0 as the offset here is wrong, but the
|
||||||
this.converter.onDataAvailable(this.request, null, stream,
|
// onDataAvailable() method does not use the offset, so it does not
|
||||||
this.offset, available);
|
// matter.
|
||||||
} else {
|
this.onDataAvailable(this.request, null, stream, 0, available);
|
||||||
this.onDataAvailable(this.request, null, stream, this.offset,
|
|
||||||
available);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.offset += available;
|
|
||||||
this.setAsyncListener(stream, this);
|
this.setAsyncListener(stream, this);
|
||||||
} else {
|
} else {
|
||||||
this.onStreamClose();
|
this.onStreamClose();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче