customnetworkaccessmanager.cpp 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #include "customnetworkaccessmanager.h"
  2. #include "useragentprovider.h"
  3. #include <QNetworkReply>
  4. #include <QSslSocket>
  5. #include <QSslConfiguration>
  6. CustomNetworkAccessManager::CustomNetworkAccessManager(QString p_userAgent, QObject *parent) :
  7. QNetworkAccessManager(parent), __userAgent(p_userAgent)
  8. {
  9. }
  10. QNetworkReply *CustomNetworkAccessManager::createRequest( Operation op,
  11. const QNetworkRequest &req,
  12. QIODevice * outgoingData )
  13. {
  14. QSslConfiguration config = req.sslConfiguration();
  15. config.setPeerVerifyMode(QSslSocket::VerifyNone);
  16. config.setProtocol(QSsl::TlsV1);
  17. QNetworkRequest new_req(req);
  18. new_req.setSslConfiguration(config);
  19. new_req.setRawHeader("User-Agent", __userAgent.toAscii());
  20. //new_req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
  21. QNetworkReply *reply = QNetworkAccessManager::createRequest( op, new_req, outgoingData );
  22. return reply;
  23. }