mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-10-01 01:26:16 +13:00
FF: this fixes availability of response headers for when item pulled from cache
This commit is contained in:
parent
7cd060a15f
commit
8ae33e9c12
2 changed files with 16 additions and 5 deletions
|
@ -1054,6 +1054,7 @@ var httpObserver = {
|
||||||
register: function() {
|
register: function() {
|
||||||
Services.obs.addObserver(this, 'http-on-opening-request', true);
|
Services.obs.addObserver(this, 'http-on-opening-request', true);
|
||||||
Services.obs.addObserver(this, 'http-on-examine-response', true);
|
Services.obs.addObserver(this, 'http-on-examine-response', true);
|
||||||
|
Services.obs.addObserver(this, 'http-on-examine-cached-response', true);
|
||||||
|
|
||||||
// Guard against stale instances not having been unregistered
|
// Guard against stale instances not having been unregistered
|
||||||
if ( this.componentRegistrar.isCIDRegistered(this.classID) ) {
|
if ( this.componentRegistrar.isCIDRegistered(this.classID) ) {
|
||||||
|
@ -1082,6 +1083,7 @@ var httpObserver = {
|
||||||
unregister: function() {
|
unregister: function() {
|
||||||
Services.obs.removeObserver(this, 'http-on-opening-request');
|
Services.obs.removeObserver(this, 'http-on-opening-request');
|
||||||
Services.obs.removeObserver(this, 'http-on-examine-response');
|
Services.obs.removeObserver(this, 'http-on-examine-response');
|
||||||
|
Services.obs.removeObserver(this, 'http-on-examine-cached-response');
|
||||||
|
|
||||||
this.componentRegistrar.unregisterFactory(this.classID, this);
|
this.componentRegistrar.unregisterFactory(this.classID, this);
|
||||||
this.categoryManager.deleteCategoryEntry(
|
this.categoryManager.deleteCategoryEntry(
|
||||||
|
@ -1155,6 +1157,8 @@ var httpObserver = {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// https://developer.mozilla.org/en/docs/Observer_Notifications#HTTP_requests
|
||||||
|
//
|
||||||
observe: function(channel, topic) {
|
observe: function(channel, topic) {
|
||||||
if ( channel instanceof Ci.nsIHttpChannel === false ) {
|
if ( channel instanceof Ci.nsIHttpChannel === false ) {
|
||||||
return;
|
return;
|
||||||
|
@ -1163,7 +1167,10 @@ var httpObserver = {
|
||||||
var URI = channel.URI;
|
var URI = channel.URI;
|
||||||
var channelData, type, result;
|
var channelData, type, result;
|
||||||
|
|
||||||
if ( topic === 'http-on-examine-response' ) {
|
if (
|
||||||
|
topic === 'http-on-examine-response' ||
|
||||||
|
topic === 'http-on-examine-cached-response'
|
||||||
|
) {
|
||||||
if ( !(channel instanceof Ci.nsIWritablePropertyBag) ) {
|
if ( !(channel instanceof Ci.nsIWritablePropertyBag) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1606,11 +1613,12 @@ vAPI.toolbarButton.onBeforeCreated = function(doc) {
|
||||||
panel.parentNode.style.maxWidth = 'none';
|
panel.parentNode.style.maxWidth = 'none';
|
||||||
// We set a limit for height
|
// We set a limit for height
|
||||||
var height = Math.min(body.clientHeight, 600);
|
var height = Math.min(body.clientHeight, 600);
|
||||||
|
var width = body.clientWidth;
|
||||||
// https://github.com/chrisaljoudi/uBlock/issues/730
|
// https://github.com/chrisaljoudi/uBlock/issues/730
|
||||||
// Voodoo programming: this recipe works
|
// Voodoo programming: this recipe works
|
||||||
panel.style.height = iframe.style.height = height.toString() + 'px';
|
panel.style.height = iframe.style.height = height.toString() + 'px';
|
||||||
panel.style.width = iframe.style.width = body.clientWidth.toString() + 'px';
|
panel.style.width = iframe.style.width = width.toString() + 'px';
|
||||||
if ( iframe.clientHeight !== height || iframe.clientWidth !== body.clientWidth ) {
|
if ( iframe.clientHeight !== height || iframe.clientWidth !== width ) {
|
||||||
delayedResize();
|
delayedResize();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -497,7 +497,7 @@ var onMainDocHeadersReceived = function(details) {
|
||||||
// https://github.com/gorhill/httpswitchboard/issues/112
|
// https://github.com/gorhill/httpswitchboard/issues/112
|
||||||
// rhill 2014-02-10: Handle all redirects.
|
// rhill 2014-02-10: Handle all redirects.
|
||||||
// https://github.com/gorhill/httpswitchboard/issues/188
|
// https://github.com/gorhill/httpswitchboard/issues/188
|
||||||
if ( /\b30[12378]\b/.test(details.statusLine) ) {
|
if ( reStatusRedirect.test(details.statusLine) ) {
|
||||||
var i = headerIndexFromName('location', headers);
|
var i = headerIndexFromName('location', headers);
|
||||||
if ( i >= 0 ) {
|
if ( i >= 0 ) {
|
||||||
// rhill 2014-01-20: Be ready to handle relative URLs.
|
// rhill 2014-01-20: Be ready to handle relative URLs.
|
||||||
|
@ -513,7 +513,7 @@ var onMainDocHeadersReceived = function(details) {
|
||||||
|
|
||||||
// rhill 2014-01-15: Report redirects if any.
|
// rhill 2014-01-15: Report redirects if any.
|
||||||
// https://github.com/gorhill/httpswitchboard/issues/112
|
// https://github.com/gorhill/httpswitchboard/issues/112
|
||||||
if ( details.statusLine.indexOf(' 200') > 0 ) {
|
if ( reStatusOK.test(details.statusLine) ) {
|
||||||
var mainFrameStack = [requestURL];
|
var mainFrameStack = [requestURL];
|
||||||
var destinationURL = requestURL;
|
var destinationURL = requestURL;
|
||||||
var sourceURL;
|
var sourceURL;
|
||||||
|
@ -555,6 +555,9 @@ var onMainDocHeadersReceived = function(details) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var reStatusOK = /\b(?:200|304)\b/;
|
||||||
|
var reStatusRedirect = /\b30[12378]\b/;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var onSubDocHeadersReceived = function(details) {
|
var onSubDocHeadersReceived = function(details) {
|
||||||
|
|
Loading…
Reference in a new issue