[webkit-qt] patching QtNetworkAccessManager::createRequest
lottaviano at develer.com
Thu Oct 17 09:05:10 PDT 2013
On 17/10/2013 17:27, Olivier Tilloy wrote:
> Hi all,
> I’m looking into patching QtNetworkAccessManager::createRequest(…) to
> dynamically set a custom user agent on every outgoing HTTP request
> (setting the experimental.userAgent property on the QML webview is not
> enough, I need per-domain overrides).
> I know that with the multi-process architecture the qnam cannot be
> easily replaced on the application side, and I’m fine with having to
> minimally patch QtWebKit to achieve my goal (although of course being
> able to set a custom qnam at runtime would be ideal!).
> I’m wondering how feasible it would be to have a signal emitted on the
> webview from createRequest(…) so that I can easily override the UA
> header dynamically, something similar to the onNavigationRequested
> signal, and how I would go about implementing such a hook?
> Any help/pointers/suggestions of an alternative approach much appreciated!
I've also looked at WebKit2 internals and I don't think there's an easy
way to add what you want...
Maybe you can just change the userAgent in the slot onNavigationRequest
depending on the target URL, or if that fails because loading is already
started, you can define a myUrl as a "proxy" for WebView.url.
Luca Ottaviano - lottaviano at develer.com
Tel.: +39 055 3986627 - ext.: 218
My blog - http://lucaotta.tumblr.com/
Develer S.r.l. - http://www.develer.com/
BeRTOS - http://www.bertos.org
More information about the webkit-qt