最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

webkitgtk - Transparently redirect URLdomain in WebKit - Stack Overflow

programmeradmin1浏览0评论

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:

  1. Set up a decide-policy signal and handle WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION, then call webkit_uri_request_set_uri if the requested URI is one to be rewritten.
  2. Same as 1. for the resource-load-started signal.
  3. 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.

发布评论

评论列表(0)

  1. 暂无评论