Commit 24d2ba92 authored by Dawit Alemayehu's avatar Dawit Alemayehu
Browse files

When the server responds with a '204 No Content' status, disregard any

content-type header it may have included in the response header.

Make KRun treat a KIO::ERR_NO_CONTENT error message as an indicator that
no further action needs to be taken instead of an actual error.

CCBUG: 30667

(cherry picked from commit 3d2d3998)
parent 97447fa1
......@@ -224,6 +224,7 @@ int AccessManagerReply::jobError(KJob* kJob)
switch (errCode)
{
case 0:
case KIO::ERR_NO_CONTENT: // Sent by a 204 response is not an error condition.
setError(QNetworkReply::NoError, kJob->errorText());
//kDebug(7044) << "0 -> QNetworkReply::NoError";
break;
......@@ -262,7 +263,6 @@ int AccessManagerReply::jobError(KJob* kJob)
setError(QNetworkReply::ContentOperationNotPermittedError, kJob->errorText());
kDebug(7044) << "KIO::ERR_WRITE_ACCESS_DENIED -> QNetworkReply::ContentOperationNotPermittedError";
break;
case KIO::ERR_NO_CONTENT:
case KIO::ERR_DOES_NOT_EXIST:
setError(QNetworkReply::ContentNotFoundError, kJob->errorText());
kDebug(7044) << "KIO::ERR_DOES_NOT_EXIST -> QNetworkReply::ContentNotFoundError";
......@@ -316,7 +316,7 @@ void AccessManagerReply::slotResult(KJob *kJob)
readHttpResponseHeaders(qobject_cast<KIO::Job*>(kJob));
} else {
setAttribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::KioError), errcode);
if (errcode)
if (errcode && errcode != KIO::ERR_NO_CONTENT)
emit error(error());
}
......
......@@ -1333,19 +1333,23 @@ void KRun::slotTimeout()
void KRun::slotStatResult(KJob * job)
{
d->m_job = 0L;
if (job->error()) {
d->m_showingDialog = true;
kError(7010) << this << "ERROR" << job->error() << job->errorString();
job->uiDelegate()->showErrorMessage();
//kDebug(7010) << this << " KRun returning from showErrorDialog, starting timer to delete us";
d->m_showingDialog = false;
const int errCode = job->error();
if (errCode) {
// ERR_NO_CONTENT is not an error, but an indication no further
// actions needs to be taken.
if (errCode != KIO::ERR_NO_CONTENT) {
d->m_showingDialog = true;
kError(7010) << this << "ERROR" << job->error() << job->errorString();
job->uiDelegate()->showErrorMessage();
//kDebug(7010) << this << " KRun returning from showErrorDialog, starting timer to delete us";
d->m_showingDialog = false;
d->m_bFault = true;
}
d->m_bFault = true;
d->m_bFinished = true;
// will emit the error and autodelete this
d->startTimer();
}
else {
kDebug(7010) << "Finished";
......@@ -1399,16 +1403,21 @@ void KRun::slotScanMimeType(KIO::Job *, const QString &mimetype)
void KRun::slotScanFinished(KJob *job)
{
d->m_job = 0;
if (job->error()) {
d->m_showingDialog = true;
kError(7010) << this << "ERROR (stat):" << job->error() << ' ' << job->errorString();
job->uiDelegate()->showErrorMessage();
//kDebug(7010) << this << " KRun returning from showErrorDialog, starting timer to delete us";
d->m_showingDialog = false;
const int errCode = job->error();
if (errCode) {
// ERR_NO_CONTENT is not an error, but an indication no further
// actions needs to be taken.
if (errCode != KIO::ERR_NO_CONTENT) {
d->m_showingDialog = true;
kError(7010) << this << "ERROR (stat):" << job->error() << ' ' << job->errorString();
job->uiDelegate()->showErrorMessage();
//kDebug(7010) << this << " KRun returning from showErrorDialog, starting timer to delete us";
d->m_showingDialog = false;
d->m_bFault = true;
}
d->m_bFault = true;
d->m_bFinished = true;
// will emit the error and autodelete this
d->startTimer();
}
......
......@@ -628,14 +628,18 @@ void HTTPProtocol::proceedUntilResponseContent( bool dataInternal /* = false */
// if data is required internally, don't finish,
// it is processed before we finish()
if (!dataInternal) {
if ((m_request.responseCode == 204) &&
((m_request.method == HTTP_GET) || (m_request.method == HTTP_POST))) {
error(ERR_NO_CONTENT, QString());
} else {
finished();
}
if (dataInternal) {
return;
}
if (m_request.responseCode == 204 &&
(m_request.method == HTTP_GET || m_request.method == HTTP_POST)) {
infoMessage(QLatin1String(""));
error(ERR_NO_CONTENT, QString());
return;
}
finished();
}
bool HTTPProtocol::proceedUntilResponseHeader()
......@@ -3582,7 +3586,7 @@ endParsing:
// Let the app know about the mime-type iff this is not a redirection and
// the mime-type string is not empty.
if (!m_isRedirection &&
if (!m_isRedirection && m_request.responseCode != 204 &&
(!m_mimeType.isEmpty() || m_request.method == HTTP_HEAD) &&
(m_isLoadingErrorPage || !authRequiresAnotherRoundtrip)) {
kDebug(7113) << "Emitting mimetype " << m_mimeType;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment