Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

QNetworkReply::ContentAccessDenied



  • Hi, i just know a little english. this is my issue.
    I want to login and I'am using QNetworkAccessManager to connect to web that use https.

    this is my code

    QUrlQuery query;
    query.addQueryItem("user", user->getEmail());
    query.addQueryItem("pass", user->getPass());

    QString strQuery = query.query(QUrl::FullyEncoded);
    QByteArray post = strQuery.toUtf8();

    // Create request and attach ssl configuration to it
    QNetworkRequest request;
    request.setUrl(QUrl("https://myurl/login"));

    request.setHeader(QNetworkRequest::ContentTypeHeader, "text/html; charset=UTF-8");
    request.setHeader(QNetworkRequest::UserAgentHeader, "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0");
    request.setRawHeader("Accept-Encoding","gzip, deflate");
    QSslConfiguration sslConfiguration = QSslConfiguration::defaultConfiguration();
    request.setSslConfiguration(sslConfiguration);

    QNetworkReply *reply = manager->post(request, post);

    but the system always send me this error
    QNetworkReply::ContentAccessDenied
    statusCode: 403 statusName:"Forbidden"

    But when i use the browse and put directly this url:
    https://myurl/login?user=user1&pass=pass1

    works and the user can login

    what i'am doing wrong in my code?



  • what happens if you hardcode the string literals for user and pass into the query.addQueryItem("user", "lteral"); calls?

    Also, HTTP protocol requires <CR><LF> liner terminators, IIRC. Have you verified the format of the headers you are sending?



  • I'am using http header live of mozilla, this is the respond

    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8

    Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3

    Accept-Encoding: gzip, deflate, br

    Connection: keep-alive

    Cookie: __cfduid=d74b1e92b11332b88ec011ff9d4175f1d1553622050; _ga=GA1.3.837904067.1553622282; _pk_id.2.170d=160538fce0b0174f.1553622380.18.1554212685.1554212685.; JSESSIONID=2WhvcjnDDmQZBcVbDcRwGtTCWt1kvrqf2f9whYBS29TZgL2VXTqR!-1646886097!896799599; BIGipServerPool_Citas_Mexitel=!FjhUZgRUHJc23PaxNCpVW2wfI9iVo/K1FHjaCrgGdah6LwnZauCS8WsSdMOTuGKtdFfQMGQj/PvoIQ==; _pk_ses.2.170d=1; _gid=GA1.3.1156628238.1554212693

    Upgrade-Insecure-Requests: 1

    And, this is my header request:

    request.setHeader(QNetworkRequest::ContentTypeHeader, "text/html; charset=UTF-8");
    request.setHeader(QNetworkRequest::UserAgentHeader, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0");
    request.setRawHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8");
    request.setRawHeader("Accept-Language","es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3");
    request.setRawHeader("Accept-Encoding","gzip, deflate, br");
    request.setRawHeader("Connection","keep-alive");
    request.setRawHeader("Cookie","__cfduid=d74b1e92b11332b88ec011ff9d4175f1d1553622050; _ga=GA1.3.837904067.1553622282; _pk_id.2.170d=160538fce0b0174f.1553622380.18.1554212685.1554212685.; JSESSIONID=2WhvcjnDDmQZBcVbDcRwGtTCWt1kvrqf2f9whYBS29TZgL2VXTqR!-1646886097!896799599; BIGipServerPool_Citas_Mexitel=!FjhUZgRUHJc23PaxNCpVW2wfI9iVo/K1FHjaCrgGdah6LwnZauCS8WsSdMOTuGKtdFfQMGQj/PvoIQ==; _pk_ses.2.170d=1; _gid=GA1.3.1156628238.1554212693");
    request.setRawHeader("Upgrade-Insecure-Requests","1");

    Is the same. when i put when i put

    qDebug() << request.rawHeaderList();

    the system recognize the headers

    ("Content-Type", "User-Agent", "Accept", "Accept-Language", "Accept-Encoding", "Connection", "Cookie", "Upgrade-Insecure-Requests")

    But i have the same error

    QNetworkReply::ContentAccessDenied
    403 "Forbidden"


Log in to reply