Hi!

I'm a beginner to Network programming and I'm trying to write a simple console application which return html source from server.

this is the code

Qt Code:
  1. void Downloader::doDownload()
  2. {
  3. QHttp *http = new QHttp(this);
  4.  
  5. http->setHost("c-studios.host56.com");
  6. http->get("/index.html");
  7.  
  8. connect(http, SIGNAL(stateChanged(int)), this, SLOT(stateChanged(int)));
  9. connect(http, SIGNAL(responseHeaderReceived(QHttpResponseHeader)), this, SLOT(responseHeaderReceived(QHttpResponseHeader)));
  10. connect(http, SIGNAL(requestFinished(int,bool)), this, SLOT(requestFinished(int,bool)));
  11. connect(http, SIGNAL(readyRead(QHttpResponseHeader)), this, SLOT(showHtml()));
  12.  
  13.  
  14. }
  15.  
  16. // ....
  17.  
  18. void Downloader::responseHeaderReceived(const QHttpResponseHeader &resp)
  19. {
  20. qDebug() << "Size: " << resp.contentLength(); //works fine. show correct length
  21. qDebug() << "Type: " << resp.contentType(); // works fine
  22. qDebug() << "Status: " << resp.statusCode(); // fine return 200
  23. }
  24.  
  25. void Downloader::requestFinished(int id, bool error)
  26. {
  27. if(error)
  28. {
  29. qDebug() << "Error!";
  30. }
  31. else
  32. {
  33. qDebug() << "Ok!";
  34. }
  35. }
  36.  
  37. void Downloader::showHtml()
  38. {
  39. QString html(http->readAll()); //this is the problem. QString is empty
  40. qDebug() << html;
  41. }
To copy to clipboard, switch view to plain text mode 

when i call http->readAll() it's return empty byte array. I can't fugure out what is the problem. someone help please. thanks