i have simple request method inside simple http client , that QRunnble worker is invoking all the returners of the request are status 0 , what more i spotted after few tests is, when i give the app to run with 1 thread that is
only 1 url to process its working fine and i get status 200 . i suspect something in my http client code is worng and does not support multi thread mode here is my full httpclient code:

this is the code of the request :
Qt Code:
  1. #ifndef _HttpClient_
  2. #define _HttpClient_
  3. #include <QNetworkAccessManager>
  4. #include <QtNetwork>
  5. #include <QUrl>
  6.  
  7. QT_BEGIN_NAMESPACE
  8. class QSslError;
  9. class QAuthenticator;
  10. class QNetworkReply;
  11. QT_END_NAMESPACE
  12.  
  13. class HttpClient : public QObject
  14. {
  15. Q_OBJECT
  16. public:
  17. HttpClient(QFile* file,QMutex* mutex);
  18. ~HttpClient();
  19. void startRequest(QString& url);
  20. public slots:
  21. #ifndef QT_NO_OPENSSL
  22. void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
  23. #endif
  24. private:
  25. QString m_sUrl;
  26. QUrl m_url;
  27. QNetworkAccessManager* m_networkManager;
  28. QNetworkReply *reply;
  29. int httpGetId;
  30. void HandleNetworkError(QNetworkReply::NetworkError& networkError,
  31. QNetworkReply *networkReply);
  32. };
  33.  
  34. #endif
  35.  
  36. ------------------------------------
  37.  
  38. #include "HttpClient.h"
  39. #include <QMutexLocker>
  40. #include <QTextStream>
  41.  
  42. HttpClient::HttpClient()
  43. {
  44. m_networkManager = new QNetworkAccessManager(this);
  45. }
  46. HttpClient::~HttpClient()
  47. {
  48. ;
  49. }
  50.  
  51. void HttpClient::startRequest(QString& url)
  52. {
  53. QNetworkRequest request;
  54. request.setUrl(QUrl(url));
  55. QEventLoop loop;
  56. reply = m_networkManager->get(request);
  57. connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
  58. loop.exec(&#41;;
  59. LOG_MSG("Is UrlAlive?:"+url.toStdString(&#41;)
  60. QString ApiResponse;
  61. QByteArray data=reply->readAll();
  62. ApiResponse.append(QString::fromUtf8(data));
  63. int iStatusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
  64. if (reply->error()) {
  65. QNetworkReply::NetworkError networkError = reply->error();
  66. HandleNetworkError(networkError,reply);
  67. }
  68. QString s = QString::number(iStatusCodeV);
  69. reply->deleteLater();
  70. reply = 0;
  71.  
  72. }
  73. void HttpClient::HandleNetworkError(QNetworkReply::NetworkError& networkError,QNetworkReply *networkReply)
  74. {
  75. if(networkError != QNetworkReply::NoError)
  76. {
  77. QString err = networkReply->errorString();
  78. LOG_MSG("HttpClient::HandleNetworkError:"+err.toStdString());
  79. }
  80. }
  81. #ifndef QT_NO_OPENSSL
  82. void HttpClient::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
  83. {
  84.  
  85. reply->ignoreSslErrors();
  86. }
  87. #endif
To copy to clipboard, switch view to plain text mode 


all of this called from QRunnble method that looks like this :

Qt Code:
  1. void ThreadWorker::run()
  2. {
  3. QMutexLocker lock(_m);
  4. startwork();
  5. lock.unlock();
  6.  
  7.  
  8. }
  9.  
  10. void ThreadWorker::startwork()
  11. {
  12. m_pHttpClient = new HttpClient();
  13. //each thread gets unique url
  14. m_pHttpClient->startRequest(m_url);
  15.  
  16. }
To copy to clipboard, switch view to plain text mode 

why its failing all the time?