| 451 | } |
| 452 | |
| 453 | void MascotRemoteQuery::readResponse(QNetworkReply* reply) |
| 454 | { |
| 455 | static QString dat_file_path_; |
| 456 | #ifdef MASCOTREMOTEQUERY_DEBUG |
| 457 | cerr << "\nvoid MascotRemoteQuery::readResponse(const QNetworkReply* reply): "; |
| 458 | if (reply->error()) |
| 459 | { |
| 460 | cerr << "'" << reply->errorString().toStdString() << "'" << "\n"; |
| 461 | } |
| 462 | else |
| 463 | { |
| 464 | cerr << "\n"; |
| 465 | } |
| 466 | cerr << " -- got query " << reply << endl; |
| 467 | #endif |
| 468 | |
| 469 | readResponseHeader(reply); // first read and parse the header (also log) |
| 470 | |
| 471 | timeout_.stop(); |
| 472 | |
| 473 | if (reply->error()) |
| 474 | { |
| 475 | error_message_ = String("Mascot Server replied: '") + String(reply->errorString().toStdString()) + "'"; |
| 476 | cerr << " ending run with " + String("Mascot Server replied: '") + String(reply->errorString().toStdString()) + "'\n"; |
| 477 | endRun_(); |
| 478 | return; |
| 479 | } |
| 480 | |
| 481 | QByteArray new_bytes = reply->readAll(); |
| 482 | #ifdef MASCOTREMOTEQUERY_DEBUG_FULL_QUERY |
| 483 | QString str = QString::fromUtf8(new_bytes.data(), new_bytes.size()); |
| 484 | |
| 485 | cerr << "Response of query: " << "\n"; |
| 486 | cerr << "-----------------------------------" << "\n"; |
| 487 | cerr << QString(new_bytes.constData()).toStdString() << "\n"; |
| 488 | cerr << "-----------------------------------" << "\n"; |
| 489 | cerr << str.toStdString() << "\n"; |
| 490 | #endif |
| 491 | |
| 492 | |
| 493 | int status = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt(); |
| 494 | #ifdef MASCOTREMOTEQUERY_DEBUG |
| 495 | cerr << "HTTP status: " << status << "\n"; |
| 496 | cerr << "Response size: " << QString(new_bytes).trimmed().size() << "\n"; |
| 497 | #endif |
| 498 | |
| 499 | // Catch "ghost queries": strange responses that are completely empty and |
| 500 | // have a HTTP status of zero (and we never actually sent out) |
| 501 | if (QString(new_bytes).trimmed().size() == 0 && status == 0) |
| 502 | { |
| 503 | return; |
| 504 | } |
| 505 | |
| 506 | if (QString(new_bytes).trimmed().size() == 0 && status != 303) // status != 303: no redirect |
| 507 | { |
| 508 | error_message_ = "Error: Reply from mascot server is empty! Possible server overload - see the Mascot Admin!"; |
| 509 | endRun_(); |
| 510 | return; |
nothing calls this directly
no test coverage detected