Page 1 of 2

An API for adding custom browser proxy bypass rules

PostPosted: Thu Mar 21, 2013 5:02 am
by mihait
When a system proxy is set, loading an html file from localhost (assuming a local web server is up) via LoadURL actually dispatches the localhost address through the proxy, resulting in the webpage not being displayed.
Currently, I have a workaround for this problem which implies adding a Chromium patch in the net third party project, namely, I've added a proxy rule for local addresses to bypass the system proxy configuration.
However, from a first look, the browser proxy settings are also accessible at browser creation time (cef3/libcef/browser/browser_main.cc#100) so I was wondering, what's your opinion about adding a method that could set custom proxy rules? It would certaintly solve this problem in a much cleaner way than adding modifications to the net project and it would also eliminate the need of maintaing the custom patch.

Re: An API for adding custom browser proxy bypass rules

PostPosted: Thu Mar 21, 2013 9:45 am
by magreenblatt
You can set proxy settings via the command line: http://dev.chromium.org/developers/desi ... y-settings. See the section about proxy bypass list.

Re: An API for adding custom browser proxy bypass rules

PostPosted: Thu Mar 21, 2013 10:22 am
by mihait
I remember I tried this when actually doing the fix for a CEF1 embedding app a while ago and it didn't seem to work. I'll try this solution with CEF3, hopefully we won't have the same problems here, nevertheless, thanks a lot for the suggestion!

Re: An API for adding custom browser proxy bypass rules

PostPosted: Thu Mar 21, 2013 10:41 am
by magreenblatt
mihait wrote:I remember I tried this when actually doing the fix for a CEF1 embedding app a while ago and it didn't seem to work. I'll try this solution with CEF3, hopefully we won't have the same problems here, nevertheless, thanks a lot for the suggestion!

These command line flags are not implemented in CEF1 so that will definitely make a difference ;-).

Re: An API for adding custom browser proxy bypass rules

PostPosted: Thu Mar 21, 2013 11:19 am
by mihait
Sadly, I've tested the --proxy-bypass-list with CEF3, and as the docs state, it only has effect when specifying a custom proxy via the --proxy-server flag. This means that unfortunately, it won't solve our problem, since we would like to use the system proxy, but only bypass it for <local> addresses.

Re: An API for adding custom browser proxy bypass rules

PostPosted: Thu Mar 21, 2013 11:43 am
by magreenblatt
mihait wrote:Sadly, I've tested the --proxy-bypass-list with CEF3, and as the docs state, it only has effect when specifying a custom proxy via the --proxy-server flag. This means that unfortunately, it won't solve our problem, since we would like to use the system proxy, but only bypass it for <local> addresses.

Ah, sorry, I didn't inspect the docs closely enough to see that requirement. If you're only using localhost (and don't need external proxy-resolved resources) then you could use the "--no-proxy-server" flag.

How does Chrome behave? Do you have an entry for localhost in your HOSTS file (assuming Windows)? I'm somewhat surprised that localhost requests are sent to the proxy.

Re: An API for adding custom browser proxy bypass rules

PostPosted: Thu Mar 21, 2013 12:01 pm
by fddima
magreenblatt wrote:How does Chrome behave? Do you have an entry for localhost in your HOSTS file (assuming Windows)? I'm somewhat surprised that localhost requests are sent to the proxy.

Default Windows 7 configuration did not have localhost entry in hosts file (they are commented out).
Code: Select all
# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

Re: An API for adding custom browser proxy bypass rules

PostPosted: Mon Mar 25, 2013 1:24 am
by mihait
By default, the proxy bypass lists on both mac and win (I haven't tested linux) don't include an entry for localhost. This means that Chromium aswell as CEF dispatch localhost requests through the proxy.
Regarding the --no-proxy flag, unfortunately, it wouldn't be an option, as I'd also like to load some external resources in the CEF view.

Re: An API for adding custom browser proxy bypass rules

PostPosted: Thu Mar 28, 2013 10:09 am
by magreenblatt
Is this only for local testing or are you planning to develop a product that uses a local web server? If it's only for local testing then editing your HOSTS file should be an option. If you're developing a product you might want to consider using a custom scheme handler or CefRequestHandler::GetResourceHandler() to avoid any issues loading local resources.

Re: An API for adding custom browser proxy bypass rules

PostPosted: Thu Mar 28, 2013 11:17 am
by mihait
The change is intended for a product that loads files from a local server, as well as from some remote resources, so adding the localhost entry isn't probably an option.
Adding a custom scheme handler doesn't sound so clear, could you please provide more info on this?