gorhill 2016-09-01 08:29:24 -04:00
parent 05adf750be
commit 2c925ff5ee
1 changed files with 17 additions and 13 deletions

View File

@ -2102,6 +2102,13 @@ var httpObserver = {
return false; return false;
} }
// https://github.com/uBlockOrigin/uAssets/issues/123#issuecomment-244055243
// Need special handling for websocket requests: http-based websocket
// requests will be evaluated as ws-based websocket requests.
if ( details.rawtype === 16 && URI.asciiSpec.startsWith('http') ) {
URI = Services.io.newURI(URI.asciiSpec.replace(/^http(s)?:/, 'ws$1:'), null, null);
}
var result = this.onBeforeRequest({ var result = this.onBeforeRequest({
frameId: details.frameId, frameId: details.frameId,
parentFrameId: details.parentFrameId, parentFrameId: details.parentFrameId,
@ -2110,20 +2117,17 @@ var httpObserver = {
url: URI.asciiSpec url: URI.asciiSpec
}); });
if ( !result || typeof result !== 'object' ) { if ( result && typeof result === 'object' ) {
return false;
}
if ( 'cancel' in result && result.cancel === true ) { if ( 'cancel' in result && result.cancel === true ) {
channel.cancel(this.ABORT); channel.cancel(this.ABORT);
return true; return true;
} }
if ( 'redirectUrl' in result ) { if ( 'redirectUrl' in result ) {
channel.redirectionLimit = 1; channel.redirectionLimit = 1;
channel.redirectTo(Services.io.newURI(result.redirectUrl, null, null)); channel.redirectTo(Services.io.newURI(result.redirectUrl, null, null));
return true; return true;
} }
}
return false; return false;
}, },