c++qtqnetworkaccessmanagerqnetworkrequestqnetworkreply

Can't get url by QNetworkAccessManager (result differs what I see in my browser)


I use QT 4.8.2 for my project. My problem is what QTNetworkAccess can't get my url (or decode it) correctly. If I paste my url to browser, I see what result in browser differs what I see in result (QNetworkreply).

This is example url I need to get: * https://myhost/folder/folder/rss?cn1%5B0%5D=Web%2C+Mobile+%26+Software+Dev&cn2%5B0%5D=Web+Development

or, without urlencode: ** https://myhost/folder/folder/rss?cn1[]=Web%2C+Mobile+%26+Software+Dev&cn2[]=Web+Development

I try to pass QUrl as * and **.

This is my code to get:

networkAccess = new QNetworkAccessManager();
connect (networkAccess, SIGNAL (finished(QNetworkReply*)), this, SLOT (h_networkAccess(QNetworkReply*)));

request = new QNetworkRequest(QUrl(settings->get()->rss_link));
request->setRawHeader("User-Agent",      "Mozilla/5.0 (Windows NT 5.1; rv:37.0) Gecko/20100101 Firefox/37.0");
request->setRawHeader("Accept",          "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
request->setRawHeader("Accept-Encoding", "deflate");
request->setRawHeader("Connection",      "keep-alive");
if (settings->get()->cookie != "")
    request->setRawHeader("Cookie",      settings->get()->cookie.toAscii()); 

networkAccess->get(*request);

Maybe, my problem is "+" symbol in url ... But I don't know. I can provide full link what I need to test.

Please, help.


Solution

  • If your url is already encoded, use QUrl::fromEncoded From the doc:

    Parses input and returns the corresponding QUrl. input is assumed to be in encoded form, containing only ASCII characters.