support ping request type explicitly

pull/2/head
gorhill 10 years ago
parent 595de33e83
commit c1314e496b

@ -693,11 +693,18 @@ vAPI.net.registerListeners = function() {
details.tabId = details.tabId.toString(); details.tabId = details.tabId.toString();
details.hostname = µmuri.hostnameFromURI(details.url); details.hostname = µmuri.hostnameFromURI(details.url);
// The rest of the function code is to normalize type // The rest of the function code is to normalize request type
if ( details.type !== 'other' ) { if ( details.type !== 'other' ) {
return; return;
} }
if ( details.requestHeaders instanceof HTTPRequestHeaders ) {
if ( details.requestHeaders.getHeader('ping-to') !== '' ) {
details.type = 'ping';
return;
}
}
var tail = µmuri.path.slice(-6); var tail = µmuri.path.slice(-6);
var pos = tail.lastIndexOf('.'); var pos = tail.lastIndexOf('.');
@ -751,8 +758,8 @@ vAPI.net.registerListeners = function() {
var onBeforeSendHeadersClient = this.onBeforeSendHeaders.callback; var onBeforeSendHeadersClient = this.onBeforeSendHeaders.callback;
var onBeforeSendHeaders = function(details) { var onBeforeSendHeaders = function(details) {
normalizeRequestDetails(details);
details.requestHeaders = httpRequestHeadersFactory(details.requestHeaders); details.requestHeaders = httpRequestHeadersFactory(details.requestHeaders);
normalizeRequestDetails(details);
var result = onBeforeSendHeadersClient(details); var result = onBeforeSendHeadersClient(details);
if ( typeof result === 'object' ) { if ( typeof result === 'object' ) {
return result; return result;

@ -399,7 +399,7 @@ var onBeforeSendHeadersHandler = function(details) {
var requestURL = details.url; var requestURL = details.url;
var requestType = requestTypeNormalizer[details.type] || 'other'; var requestType = requestTypeNormalizer[details.type] || 'other';
if ( requestType === 'other' ) { if ( requestType === 'ping' ) {
var linkAuditor = details.requestHeaders.getHeader('ping-to'); var linkAuditor = details.requestHeaders.getHeader('ping-to');
if ( linkAuditor !== '' ) { if ( linkAuditor !== '' ) {
var block = µm.userSettings.processHyperlinkAuditing; var block = µm.userSettings.processHyperlinkAuditing;
@ -704,15 +704,16 @@ var headerIndexFromName = function(headerName, headers) {
/******************************************************************************/ /******************************************************************************/
var requestTypeNormalizer = { var requestTypeNormalizer = {
'main_frame' : 'doc', 'font' : 'css',
'sub_frame' : 'frame',
'stylesheet' : 'css',
'script' : 'script',
'image' : 'image', 'image' : 'image',
'main_frame' : 'doc',
'object' : 'plugin', 'object' : 'plugin',
'xmlhttprequest': 'xhr',
'other' : 'other', 'other' : 'other',
'font' : 'css' 'ping' : 'ping',
'script' : 'script',
'stylesheet' : 'css',
'sub_frame' : 'frame',
'xmlhttprequest': 'xhr'
}; };
/******************************************************************************/ /******************************************************************************/

Loading…
Cancel
Save