I want to use WebKitGTK in my application to render a site served from a local server. My problem is that the web application expects to run on a specific domain, and it will not run properly if it's served from somewhere else. Thus I'd like to rewrite all URLs that are attempted to be loaded (or alternatively, domains that are being resolved) in a way that is completely transparent to the web application.
So far I tried the following ways to achieve this:
- Set up a
decide-policy
signal and handleWEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION
, then callwebkit_uri_request_set_uri
if the requested URI is one to be rewritten. - Same as 1. for the
resource-load-started
signal. - Set up an URI scheme handler for https and fetch the resource from somewhere else if applicable.
Attempts 1 and 2 failed because I assume they are either fired too late or WebKit does not expect modifications to the request object.
Attempt 3 failed because registering a handler for https is no longer permitted.
I understand my use case is a bit unusual, but perhaps someone knows a way to get there?
Back on Win32 my approach of dealing with this was hooking InternetConnectW
and swapping out the server parameter, but if possible I'd like to avoid such drastic measures. Running a proxy server or modifying the OS configuration (hosts file) is also undesirable.