[webkit-gtk] Send HTTP header line for every request

philip.chimento at gmail.com philip.chimento at gmail.com
Mon Jun 27 23:05:41 PDT 2016


On Mon, Jun 27, 2016 at 5:17 AM Adrián Pérez de Castro <aperez at igalia.com>
wrote:

> Hi there,
>
> Quoting Carlos Garcia Campos (2016-06-27 08:21:13)
> > El dom, 26-06-2016 a las 18:53 +0200, Jay Strict escribió:
> > > On 26.06.2016 08:20, Carlos Garcia Campos wrote:
> > > > So, the answer is yes, you need a web extension, and the API you
> > > > want
> > > > is the signal WebKitWebPage::send-request. That signal is emitted
> > > > right
> > > > after the request is created and before it's sent to the network
> > > > process, so that you can modify the request or even block it. The
> > > > problem is how to create a web extension when using the js
> > > > bindings,
> > > > because a web extension is a .so loaded by the web process at
> > > > startup.
> > > > So at this moment I'm afraid it's not possible to do that with js,
> > > > but
> > > > I guess you could write the web extension in C, it will be just a
> > > > few
> > > > lines of code.
> > >
> > > That's a pity, because Gnome shell extensions seem to support only
> > > JS.
> > > You can upload the extensions on extensions.gnome.org, but what .so
> > > file
> > > should I upload? For every platform, there must be a different .so
> > > file.
> > > Furthermore, I suppose the Gnome people wouldn't accept a binary file
> > > uploaded there.
> > >
> > > Is there any other way?
> >
> > I don't think so.
> >
> > > >
> > > > > Fortunately, I think you can get the behavior you want using the
> > > > > UI
> > > > > process API, by connecting to the resource-load-started signal of
> > > > > WebKitWebView; that will give you a WebKitURIRequest that you can
> > > > > modify. I haven't tried this before; hope it works for you.
> > > >
> > > > No, that signal is emitted when the request has already been sent,
> > > > note
> > > > that the signal is named resource-load-started, it has already
> > > > started,
> > > > and the signal is only a notification.
> > >
> > >
> > > I don't know much about WebKitGTK, but do you think there is any
> > > chance
> > > that the authors (is that you?) would consider accepting a feature
> > > request for my use case?
> >
> > Of course, we just need to fully understand the problem and decide how
> > to make it possible. The easiest solution might be to add support for
> > loading JS web extensions. Adri started to work on python web
> > extensions, I don't know if JS support would be very different. See:
> >
> > https://lists.webkit.org/pipermail/webkit-gtk/2015-August/002416.html
> >
> > This would be the ideal solution in my opinion. But we could also add
> > API to the UI process to provide a set of headers to be added to any
> > request, for example, and use that from the web process. This would
> > probably be easier, but we can't add UI process API for every single
> > web extension feature required by JS apps, so adding a way to load JS
> > extensions would be much better.
>
> I do agree with Carlos here, and WebKitGTK+ should provide a way of loading
> JavaScript web extensions. As for Python, I have a working proof of concept
> C WebExtension which is a shim that itself loads the Python extension. You
> can check it here:
>
>   https://github.com/aperezdc/webkit2gtk-python-webextension-example
>
> (I am aware of a couple of people using the code in there as a basis for
> their Python applications which need a web extension, though in the longer
> term we will have something similar shipped with WebKitGTK+.)
>
> Having a similar proof-of-concept for JavaScript extensions would be great.
> Ideally, it would be great to use JavaScriptCore for that, because it is
> part of WebKitGTK+. As tempting as it might be to use GJS, it looks like
> sticking to JSC (via Seed, see https://wiki.gnome.org/Projects/Seed) would
> be better to have less dependencies in the case where one wants to use
> WebKitGTK+ *without* having GNOME Shell installed.
>

I am fairly certain GJS is the more frequently used of the two, in GNOME
applications at least. In any case, GJS is not just used for GNOME Shell,
but also several applications like GNOME Documents (which itself uses
WebKitGTK), GNOME Weather, etc.

And after all, I don't suppose it's a burden to include a dependency on
Python for the Python shim. You might be able to write WebExtension shims
for any number of interpreted languages and make them an optional part of
the build. In package-based distributions, for example, they could be
shipped in separate packages.

Regards,
Philip C
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-gtk/attachments/20160628/99e55bd0/attachment.html>


More information about the webkit-gtk mailing list