[webkit-gtk] Set proxy for webprocess
Mario Sanchez Prada
mario.prada at samsung.com
Tue Oct 1 01:39:59 PDT 2013
Hi Egor,
> Hello.
>
> How do I set network proxy in WebProcess?
>
> I have tried to set SOUP_SESSION_PROXY_URI for
> WebCore::ResourceHandle::defaultSession() both in
> WebProcess::initializeWebProcess() and in WebProcessMainGtk() and yet
> it did not work. I ended up doing setenv("http_proxy", "...") in
> initializeWebProcess() which seems to work, but not that I am
> completely comfortable with that solution.
>
> And yes, I need to set proxy in WebProcess, because I am spawning a few
> of them, all with different proxies.
The WebProcess should pick up already the proxy settings that you have in
your system since that's handled at the libsoup/glib-networking level,
through libproxy IIRC.
That said I found some issues recently when working with the development
environment, based in JHBuild, that is setup by when using the build-webkit
script with the --update-gtk parameter (or by running update-webkitgtk-libs
script before):
The problem in that case is that you can't read the proxy settings from the
system since you'll be using the Gsettings memory backend from there, so
anything you launch with run-launcher --gtk won't work, since he will see
"none" as the proxy mode selected, no matter what you have set in your
system.
If that's your case, you simply do this to fix the issue related to
Gsettings, as documented in [1]:
$ ./Tools/jhbuild/jhbuild-wrapper --gtk build dconf
Also, please check that you are using a version of libsoup between 2.42.0
and 2.43.5 (check WebKitBuild/Dependencies/Sources if you're using jhbuild),
since there was an issue in that range that I believe makes libproxy not to
work properly with a proxy resolver.
If that still does not work for you, check if you're using a autoconfig URL
with a PAC file in your proxy settings. In that case, check that you have
the libproxy's webkit plugin installed (libproxy1-plugin-webkit, in ubuntu),
since that's the one that handles the parsing of PAC files.
If the resolution and usage of PAC files work correctly, you should be able
to see D-Bus messages flying in your system over the session bus, between
your app and the PACRunner service, asking for the right proxy settings for
a given URL. Something like this:
========================
$ dbus-monitor --session --monitor # Keep this running while launching
run-launcher --gtk
method call sender=:1.2116 -> dest=:1.105 serial=16
path=/org/gtk/GLib/PACRunner; interface=org.gtk.GLib.PACRunner;
member=Lookup
string "http://192.168.0.10:8080/proxy.pac"
string "http://www.google.com/"
method return sender=:1.105 -> dest=:1.2116 reply_serial=16
array [
string "http://192.168.0.50:8080"
]
method call sender=:1.2116 -> dest=:1.105 serial=17
path=/org/gtk/GLib/PACRunner; interface=org.gtk.GLib.PACRunner;
member=Lookup
string "http://192.168.0.10:8080/proxy.pac"
string "http://127.0.0.1:80/"
method return sender=:1.105 -> dest=:1.2116 reply_serial=17
array [
string "direct://"
]
========================
Last, updating the packages in your system + rebooting can also help if you
give it a chance :)
Hope this helps,
Mario
[1] http://trac.webkit.org/wiki/WebKitGTK/StartHacking#Workingbehindaproxy
More information about the webkit-gtk
mailing list