2021-08-28 02:35:23 +00:00
|
|
|
#include "gico_schemahandler.h"
|
|
|
|
|
|
|
|
GicoSchemeHandler::GicoSchemeHandler(ArticleNetworkAccessManager& articleNetMgr):mManager(articleNetMgr){
|
|
|
|
|
|
|
|
}
|
|
|
|
void GicoSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
|
|
|
|
{
|
|
|
|
QUrl url = requestJob->requestUrl();
|
|
|
|
|
|
|
|
QNetworkRequest request;
|
|
|
|
request.setUrl( url );
|
|
|
|
|
2022-01-08 04:22:41 +00:00
|
|
|
QNetworkReply *reply = this->mManager.createRequest(QNetworkAccessManager::GetOperation, request, NULL);
|
2021-08-28 02:35:23 +00:00
|
|
|
|
2022-01-08 04:22:41 +00:00
|
|
|
connect(reply, &QNetworkReply::finished, requestJob, [=]() {
|
|
|
|
if (reply->error() == QNetworkReply::ContentNotFoundError) {
|
|
|
|
requestJob->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType mineType = db.mimeTypeForUrl(url);
|
|
|
|
QString contentType = mineType.name();
|
|
|
|
// Reply segment
|
|
|
|
requestJob->reply(contentType.toLatin1(), reply);
|
|
|
|
});
|
2021-08-28 02:35:23 +00:00
|
|
|
}
|