Bypass a proxy on error 502 Bad gateway

717 views
Skip to first unread message

Jerzy

unread,
Feb 13, 2014, 10:56:05 AM2/13/14
to chromium-...@chromium.org
I am using chrome.proxy.settings.set() to pass all HTTP traffic through proxy. However, sometimes the proxy server responds with an error 502 Bad gateway. In such case I would like to bypass the proxy for that particular request and send it directly. How can I achieve this?

Thanks!

Jerzy

unread,
Feb 18, 2014, 5:08:31 PM2/18/14
to chromium-...@chromium.org
I managed to do this by using chrome.webRequest.onHeadersReceived.addListener and a callback:

function(details){
  if(details.statusLine.indexOf('502 Bad gateway') > -1) {
chrome.proxy.settings.set({
value: {mode: 'system'},
scope: 'regular'
});
setTimeout(function(){
  chrome.proxy.settings.set({
value: {mode: 'fixed_servers', ...},
scope: 'regular'
  });
}, 10000);
  }
}
Reply all
Reply to author
Forward
0 new messages