[webkit-help] can not set proxy for webkit Gtk version.

Nayan nayankk at gmail.com
Mon Dec 7 09:03:25 PST 2009


You could also do following minor code changes to browse with proxy. Below
is the patch which does the same.

Index: WebKit/gtk/webkit/
webkitprivate.cpp
===================================================================
--- WebKit/gtk/webkit/webkitprivate.cpp (revision 51017)
+++ WebKit/gtk/webkit/webkitprivate.cpp (working copy)
@@ -39,6 +39,7 @@
 #include "ResourceHandleInternal.h"
 #include <runtime/InitializeThreading.h>
 #include "SecurityOrigin.h"
+#include "libsoup/soup-auth.h"

 #if ENABLE(DATABASE)
 #include "DatabaseTracker.h"
@@ -254,5 +255,16 @@

     SoupSessionFeature* sniffer =
static_cast<SoupSessionFeature*>(g_object_new(SOUP_TYPE_CONTENT_SNIFFER,
NULL));
     soup_session_add_feature(session, sniffer);
+
+    /* Add proxy support */
+    char* proxy;
+    if(proxy=getenv("http_proxy")) {
+       printf("Setting proxy as %s\n", proxy);
+       SoupURI* pURI = soup_uri_new(proxy);
+       g_object_set(session, "proxy-uri", pURI, NULL );
+    } else {
+       printf("Proxy is not set\n");
+    }
+
     g_object_unref(sniffer);
 }

This makes WebKit to use proxy address specified in 'http_proxy' enviorment
variable for default browsing.


On Fri, Dec 4, 2009 at 6:18 AM, Fern Moon <fernmoon at gmail.com> wrote:

> I found the patch in the following  links and applied it to version
> 48647.  But the GTK built version still can not recognize proxy
> settings from the environment variable http_proxy.
>
> http://trac.webkit.org/changeset/44479
> http://lists.macosforge.org/pipermail/webkit-reviews/2009-May/037426.html
>
>
> On Wed, Dec 2, 2009 at 5:13 PM, Christophe Gillette
> <christophe.public at gmail.com> wrote:
> > The GTK version is now using libsoup for the networking layer. If the
> > libsoup copy you are using is built --without-gnome, it won't retrieve
> the
> > information from the environment variable.
> >
> > In your application (or GtkLauncher), you can read the environment
> variable
> > and set the proxy using the libsoup API by getting the default session
> > created by WebKit. For exmaple:
> >
> > void setProxy(const char *szUri)
> > {
> >     SoupURI *soupUri = szUri ? soup_uri_new(szUri) : 0;
> >     g_object_set(webkit_get_default_session(), SOUP_SESSION_PROXY_URI,
> > soupUri, NULL);
> >     if (soupUri)
> >         soup_uri_free(soupUri);
> > }
> >
> > Christophe
> >
> > On Tue, Dec 1, 2009 at 10:02 PM, Fern Moon <fernmoon at gmail.com> wrote:
> >>
> >> I google the method to set http proxy for webkit.
> >>
> >> I  try the follows, but the webkit can still access internet directly.
> >>
> >> export http_proxy="127.0.0.1:8081"
> >> export http_proxy="127.0.0.1:8081"
> >>
> >> I verified that there is no such proxy in my machine.
> >>
> >> Thanks for help.
> >>
> >> Fern
> >> _______________________________________________
> >> webkit-help mailing list
> >> webkit-help at lists.webkit.org
> >> http://lists.webkit.org/mailman/listinfo.cgi/webkit-help
> >
> >
> _______________________________________________
> webkit-help mailing list
> webkit-help at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-help
>



-- 
Regards,
_Nayan_
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20091207/563e12a1/attachment.html>


More information about the webkit-help mailing list