I'm confused then by the QT exaple in

http://doc.trolltech.com/4.4/network-http.html

I followed the QT example where they set the password in the slot connected to the QHttp signal authenticationRequired(). I copied the QT example slot function below.

Qt Code:
  1. void HttpWindow::slotAuthenticationRequired(const QString &hostName, quint16, QAuthenticator *authenticator)
  2. {
  3. QDialog dlg;
  4. Ui::Dialog ui;
  5. ui.setupUi(&dlg);
  6. dlg.adjustSize();
  7. ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(hostName));
  8.  
  9. if (dlg.exec() == QDialog::Accepted) {
  10. authenticator->setUser(ui.userEdit->text());
  11. authenticator->setPassword(ui.passwordEdit->text());
  12. }
  13. }
To copy to clipboard, switch view to plain text mode 

When I looked at the example's header response handler below, it does not have any case for authentication required. So perhaps the example is incorrect? Should it have a case 401 Unauthorized? I understand what you are saying about handling the error manually, but I'd sure like to know how QT's example is supposed to work.

Qt Code:
  1. void HttpWindow::readResponseHeader(const QHttpResponseHeader &responseHeader)
  2. {
  3. switch (responseHeader.statusCode()) {
  4. case 200: // Ok
  5. case 301: // Moved Permanently
  6. case 302: // Found
  7. case 303: // See Other
  8. case 307: // Temporary Redirect
  9. // these are not error conditions
  10. break;
  11.  
  12. default:
  13. QMessageBox::information(this, tr("HTTP"),
  14. tr("Download failed: %1.")
  15. .arg(responseHeader.reasonPhrase()));
  16. httpRequestAborted = true;
  17. progressDialog->hide();
  18. http->abort();
  19. }
  20. }
To copy to clipboard, switch view to plain text mode