Rewrite the request interceptor.

It seems that there are request in the form
"blob://foo.zim/<uuid>".
I don't know where it come from, we cannot handle it and even Qt is parsing
it wrongly (scheme and host are empty, path is the full url request).

By using a string to handle the url, it is simpler to change "http://" to
"zim://".
This commit is contained in:
Matthieu Gautier 2018-07-17 11:19:43 +02:00
parent fab22ab909
commit 4849b5e364

View File

@ -14,10 +14,12 @@ void KiwixRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{ {
std::cout << "Intercept request" << std::endl; std::cout << "Intercept request" << std::endl;
auto url = info.requestUrl(); auto url = info.requestUrl();
std::cout << " - " << url.toString().toUtf8().constData() << std::endl; auto urlString = url.toString();
url.setScheme("zim"); std::cout << " - " << urlString.toUtf8().constData() << std::endl;
std::cout << " + " << url.toString().toUtf8().constData() << std::endl; if (urlString.startsWith("http://")) {
info.redirect(url); urlString.replace(0, 7, "zim://");
}
std::cout << " + " << urlString.toUtf8().constData() << std::endl;
info.redirect(QUrl(urlString));
} }