void AbstractNetworkJob::slotFinished() { _timer.stop(); if( _reply->error() == QNetworkReply::SslHandshakeFailedError ) { qDebug() << "SslHandshakeFailedError: " << reply()->errorString() << " : can be caused by a webserver wanting SSL client certificates"; } if( _reply->error() != QNetworkReply::NoError ) { qDebug() << Q_FUNC_INFO << _reply->error() << _reply->errorString() << _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) { qDebug() << Q_FUNC_INFO << _reply->rawHeader("Proxy-Authenticate"); } emit networkError(_reply); } // get the Date timestamp from reply _responseTimestamp = _reply->rawHeader("Date"); _duration = _durationTimer.elapsed(); if (_followRedirects) { // ### the qWarnings here should be exported via displayErrors() so they // ### can be presented to the user if the job executor has a GUI QUrl requestedUrl = reply()->request().url(); QUrl redirectUrl = reply()->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (!redirectUrl.isEmpty()) { _redirectCount++; if (requestedUrl.scheme() == QLatin1String("https") && redirectUrl.scheme() == QLatin1String("http")) { qWarning() << this << "HTTPS->HTTP downgrade detected!"; } else if (requestedUrl == redirectUrl || _redirectCount >= maxRedirects()) { qWarning() << this << "Redirect loop detected!"; } else { resetTimeout(); setReply(getRequest(redirectUrl)); setupConnections(reply()); return; } } } AbstractCredentials *creds = _account->credentials(); if (!creds->stillValid(_reply) && ! _ignoreCredentialFailure) { _account->handleInvalidCredentials(); } bool discard = finished(); if (discard) { deleteLater(); } }
void AbstractNetworkJob::slotFinished() { _timer.stop(); if( _reply->error() != QNetworkReply::NoError ) { qDebug() << Q_FUNC_INFO << _reply->error() << _reply->errorString(); if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) { qDebug() << Q_FUNC_INFO << _reply->rawHeader("Proxy-Authenticate"); } emit networkError(_reply); } // get the Date timestamp from reply _responseTimestamp = QString::fromAscii(_reply->rawHeader("Date")); _duration = _durationTimer.elapsed(); bool discard = finished(); AbstractCredentials *creds = _account->credentials(); if (!creds->stillValid(_reply) &&! _ignoreCredentialFailure && _account->state() != Account::InvalidCredidential) { _account->setState(Account::InvalidCredidential); // invalidate & forget token/password // but try to re-sign in. connect( creds, SIGNAL(fetched()), qApp, SLOT(slotCredentialsFetched()), Qt::UniqueConnection); if (creds->ready()) { creds->invalidateAndFetch(_account); } else { creds->fetch(_account); } } if (discard) { deleteLater(); } }
void AbstractNetworkJob::slotFinished() { _timer.stop(); if (_reply->error() == QNetworkReply::SslHandshakeFailedError) { qCWarning(lcNetworkJob) << "SslHandshakeFailedError: " << errorString() << " : can be caused by a webserver wanting SSL client certificates"; } if (_reply->error() != QNetworkReply::NoError) { if (!_ignoreCredentialFailure || _reply->error() != QNetworkReply::AuthenticationRequiredError) { qCWarning(lcNetworkJob) << _reply->error() << errorString() << _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) { qCWarning(lcNetworkJob) << _reply->rawHeader("Proxy-Authenticate"); } } emit networkError(_reply); } // get the Date timestamp from reply _responseTimestamp = _reply->rawHeader("Date"); QUrl requestedUrl = reply()->request().url(); QUrl redirectUrl = reply()->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (_followRedirects && !redirectUrl.isEmpty()) { // Redirects may be relative if (redirectUrl.isRelative()) redirectUrl = requestedUrl.resolved(redirectUrl); // For POST requests where the target url has query arguments, Qt automatically // moves these arguments to the body if no explicit body is specified. // This can cause problems with redirected requests, because the redirect url // will no longer contain these query arguments. if (reply()->operation() == QNetworkAccessManager::PostOperation && requestedUrl.hasQuery() && !redirectUrl.hasQuery() && !_requestBody) { qCWarning(lcNetworkJob) << "Redirecting a POST request with an implicit body loses that body"; } // ### some of the qWarnings here should be exported via displayErrors() so they // ### can be presented to the user if the job executor has a GUI QByteArray verb = requestVerb(*reply()); if (requestedUrl.scheme() == QLatin1String("https") && redirectUrl.scheme() == QLatin1String("http")) { qCWarning(lcNetworkJob) << this << "HTTPS->HTTP downgrade detected!"; } else if (requestedUrl == redirectUrl || _redirectCount + 1 >= maxRedirects()) { qCWarning(lcNetworkJob) << this << "Redirect loop detected!"; } else if (_requestBody && _requestBody->isSequential()) { qCWarning(lcNetworkJob) << this << "cannot redirect request with sequential body"; } else if (verb.isEmpty()) { qCWarning(lcNetworkJob) << this << "cannot redirect request: could not detect original verb"; } else { emit redirected(_reply, redirectUrl, _redirectCount); // The signal emission may have changed this value if (_followRedirects) { _redirectCount++; // Create the redirected request and send it qCInfo(lcNetworkJob) << "Redirecting" << verb << requestedUrl << redirectUrl; resetTimeout(); if (_requestBody) { _requestBody->seek(0); } sendRequest( verb, redirectUrl, reply()->request(), _requestBody); return; } } } AbstractCredentials *creds = _account->credentials(); if (!creds->stillValid(_reply) && !_ignoreCredentialFailure) { _account->handleInvalidCredentials(); } bool discard = finished(); if (discard) { qCDebug(lcNetworkJob) << "Network job" << metaObject()->className() << "finished for" << path(); deleteLater(); } }