mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
fix:return 404 if resource not found
This commit is contained in:
parent
4d648aca09
commit
c74b0bc6cf
|
@ -520,8 +520,10 @@ void ArticleResourceReply::readyReadSlot()
|
|||
|
||||
void ArticleResourceReply::finishedSlot()
|
||||
{
|
||||
if ( req->dataSize() < 0 )
|
||||
errorOccurred( ContentNotFoundError );
|
||||
if (req->dataSize() < 0) {
|
||||
emit error(ContentNotFoundError);
|
||||
setError(ContentNotFoundError, "content not found");
|
||||
}
|
||||
|
||||
emit finished();
|
||||
}
|
||||
|
|
|
@ -10,10 +10,17 @@ void GicoSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
|
|||
QNetworkRequest request;
|
||||
request.setUrl( url );
|
||||
|
||||
QNetworkReply* reply=this->mManager.createRequest(QNetworkAccessManager::GetOperation,request,NULL);
|
||||
QNetworkReply *reply = this->mManager.createRequest(QNetworkAccessManager::GetOperation, request, NULL);
|
||||
|
||||
QMimeType mineType=db.mimeTypeForUrl (url);
|
||||
QString contentType=mineType.name ();
|
||||
// Reply segment
|
||||
requestJob->reply(contentType.toLatin1(), reply);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue