FF: this fixes availability of response headers for when item pulled from cache

pull/2/head
gorhill 10 years ago
parent 7cd060a15f
commit 8ae33e9c12

@ -1054,6 +1054,7 @@ var httpObserver = {
register: function() {
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-cached-response', true);
// Guard against stale instances not having been unregistered
if ( this.componentRegistrar.isCIDRegistered(this.classID) ) {
@ -1082,6 +1083,7 @@ var httpObserver = {
unregister: function() {
Services.obs.removeObserver(this, 'http-on-opening-request');
Services.obs.removeObserver(this, 'http-on-examine-response');
Services.obs.removeObserver(this, 'http-on-examine-cached-response');
this.componentRegistrar.unregisterFactory(this.classID, this);
this.categoryManager.deleteCategoryEntry(
@ -1155,6 +1157,8 @@ var httpObserver = {
return false;
},
// https://developer.mozilla.org/en/docs/Observer_Notifications#HTTP_requests
//
observe: function(channel, topic) {
if ( channel instanceof Ci.nsIHttpChannel === false ) {
return;
@ -1163,7 +1167,10 @@ var httpObserver = {
var URI = channel.URI;
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) ) {
return;
}
@ -1606,11 +1613,12 @@ vAPI.toolbarButton.onBeforeCreated = function(doc) {
panel.parentNode.style.maxWidth = 'none';
// We set a limit for height
var height = Math.min(body.clientHeight, 600);
var width = body.clientWidth;
// https://github.com/chrisaljoudi/uBlock/issues/730
// Voodoo programming: this recipe works
panel.style.height = iframe.style.height = height.toString() + 'px';
panel.style.width = iframe.style.width = body.clientWidth.toString() + 'px';
if ( iframe.clientHeight !== height || iframe.clientWidth !== body.clientWidth ) {
panel.style.width = iframe.style.width = width.toString() + 'px';
if ( iframe.clientHeight !== height || iframe.clientWidth !== width ) {
delayedResize();
}
};

@ -497,7 +497,7 @@ var onMainDocHeadersReceived = function(details) {
// https://github.com/gorhill/httpswitchboard/issues/112
// rhill 2014-02-10: Handle all redirects.
// https://github.com/gorhill/httpswitchboard/issues/188
if ( /\b30[12378]\b/.test(details.statusLine) ) {
if ( reStatusRedirect.test(details.statusLine) ) {
var i = headerIndexFromName('location', headers);
if ( i >= 0 ) {
// 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.
// https://github.com/gorhill/httpswitchboard/issues/112
if ( details.statusLine.indexOf(' 200') > 0 ) {
if ( reStatusOK.test(details.statusLine) ) {
var mainFrameStack = [requestURL];
var destinationURL = requestURL;
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) {

Loading…
Cancel
Save