Browse Source

support ping request type explicitly

pull/2/head
gorhill 10 years ago
parent
commit
c1314e496b
  1. 11
      platform/chromium/vapi-background.js
  2. 15
      src/js/traffic.js

11
platform/chromium/vapi-background.js

@ -693,11 +693,18 @@ vAPI.net.registerListeners = function() {
details.tabId = details.tabId.toString();
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' ) {
return;
}
if ( details.requestHeaders instanceof HTTPRequestHeaders ) {
if ( details.requestHeaders.getHeader('ping-to') !== '' ) {
details.type = 'ping';
return;
}
}
var tail = µmuri.path.slice(-6);
var pos = tail.lastIndexOf('.');
@ -751,8 +758,8 @@ vAPI.net.registerListeners = function() {
var onBeforeSendHeadersClient = this.onBeforeSendHeaders.callback;
var onBeforeSendHeaders = function(details) {
normalizeRequestDetails(details);
details.requestHeaders = httpRequestHeadersFactory(details.requestHeaders);
normalizeRequestDetails(details);
var result = onBeforeSendHeadersClient(details);
if ( typeof result === 'object' ) {
return result;

15
src/js/traffic.js

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

Loading…
Cancel
Save