当前位置: 首页>>代码示例>>C++>>正文


C++ QNetworkCookieJar::setCookiesFromUrl方法代码示例

本文整理汇总了C++中QNetworkCookieJar::setCookiesFromUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkCookieJar::setCookiesFromUrl方法的具体用法?C++ QNetworkCookieJar::setCookiesFromUrl怎么用?C++ QNetworkCookieJar::setCookiesFromUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QNetworkCookieJar的用法示例。


在下文中一共展示了QNetworkCookieJar::setCookiesFromUrl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setRawCookie

void AccessManager::setRawCookie(const QByteArray &rawCookie, const  QUrl &url)
{
    QNetworkCookie cookie(rawCookie.left(rawCookie.indexOf('=')),
                          rawCookie.mid(rawCookie.indexOf('=')+1));
    qDebug() << Q_FUNC_INFO << cookie.name() << cookie.value();
    QList<QNetworkCookie> cookieList;
    cookieList.append(cookie);

    QNetworkCookieJar *jar = cookieJar();
    jar->setCookiesFromUrl(cookieList, url);
}
开发者ID:24killen,项目名称:client,代码行数:11,代码来源:accessmanager.cpp

示例2: testCorrectHttpHeader

    void testCorrectHttpHeader()
    {
        HttpServerThread server(countryResponse(), HttpServerThread::Public);
        KDSoapClientInterface client(server.endPoint(), countryMessageNamespace());
        KDSoapAuthentication auth;

        auth.setUser(QLatin1String("kdab"));
        auth.setPassword(QLatin1String("unused"));
        client.setAuthentication(auth); // unused...

        QNetworkCookieJar myJar;
        QList<QNetworkCookie> myCookies;
        myCookies.append(QNetworkCookie("biscuits", "are good"));
        myJar.setCookiesFromUrl(myCookies, QUrl(server.endPoint()));
        client.setCookieJar(&myJar);

        QByteArray expectedRequestXml = expectedCountryRequest();
        client.setSoapVersion(KDSoapClientInterface::SOAP1_1);
        {
            KDSoapMessage ret = client.call(QLatin1String("getEmployeeCountry"), countryMessage());
            // Check what we sent
            QVERIFY(xmlBufferCompare(server.receivedData(), expectedRequestXml));
            QVERIFY(!ret.isFault());

            QCOMPARE(server.header("Content-Type").constData(), "text/xml;charset=utf-8");
            QCOMPARE(server.header("SoapAction").constData(), "\"http://www.kdab.com/xml/MyWsdl/getEmployeeCountry\"");
#if QT_VERSION >= 0x040800
            QCOMPARE(server.header("Cookie").constData(), "biscuits=are good");
#elif QT_VERSION >= 0x040700
            QCOMPARE(server.header("Cookie").constData(), "biscuits=\"are good\"");
#endif
            QCOMPARE(ret.arguments().child(QLatin1String("employeeCountry")).value().toString(), QString::fromLatin1("France"));

        }
        client.setSoapVersion(KDSoapClientInterface::SOAP1_2);
        {
            KDSoapMessage ret = client.call(QLatin1String("getEmployeeCountry"), countryMessage());
            // Check what we sent
            QByteArray expectedRequestXml12 = expectedRequestXml;
            expectedRequestXml12.replace("http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/2003/05/soap-envelope");
            expectedRequestXml12.replace("http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/2003/05/soap-encoding");
            QVERIFY(xmlBufferCompare(server.receivedData(), expectedRequestXml12));
            QVERIFY(!ret.isFault());
            QCOMPARE(server.header("Content-Type").constData(), "application/soap+xml;charset=utf-8;action=http://www.kdab.com/xml/MyWsdl/getEmployeeCountry");
            QCOMPARE(ret.arguments().child(QLatin1String("employeeCountry")).value().toString(), QString::fromLatin1("France"));
#if QT_VERSION >= 0x040800
            QCOMPARE(server.header("Cookie").constData(), "biscuits=are good");
#elif QT_VERSION >= 0x040700
            QCOMPARE(server.header("Cookie").constData(), "biscuits=\"are good\"");
#endif
        }
    }
开发者ID:cjh1,项目名称:KDSoap,代码行数:52,代码来源:builtinhttp.cpp

示例3: setCookies

void setCookies(Document* document, const KURL& url, const KURL& policyURL, const String& value)
{
    QUrl u(url);
    QUrl p(policyURL);
#if QT_VERSION >= 0x040400
    QNetworkCookieJar* jar = cookieJar(document);
    if (!jar)
        return;

    QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toAscii());
    jar->setCookiesFromUrl(cookies, p);
#else
    QCookieJar::cookieJar()->setCookies(u, p, (QString)value);
#endif
}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:15,代码来源:CookieJarQt.cpp

示例4: cookie

InfoExtractor::InfoExtractor(QObject *parent) :
    QObject(parent), m_queue(), m_url(), m_replyTimer(new QTimer(this)),
    m_accessManager(new QNetworkAccessManager(this)), m_reply(NULL)
{
    //Définition du cookie pour avoir la page en anglais
    QNetworkCookieJar *jar = new QNetworkCookieJar(this);
    QNetworkCookie cookie("l", "en");
    QList<QNetworkCookie> liste;
    liste << cookie;
    jar->setCookiesFromUrl(liste, MEGAUPLOAD);
    m_accessManager->setCookieJar(jar);

    m_replyTimer->setSingleShot(true);
    m_replyTimer->setInterval(INFO_EXTRACTION_TIMEOUT);
    connect(m_replyTimer, SIGNAL(timeout()), this, SLOT(replyTimeout()));
}
开发者ID:Zxb12,项目名称:DownStream,代码行数:16,代码来源:infoextractor.cpp

示例5: setCookies

void setCookies(Document* document, const KURL& url, const KURL& policyURL, const String& value)
{
    QUrl u(url);
    QUrl p(policyURL);
#if QT_VERSION >= 0x040400
    QNetworkCookieJar* jar = cookieJar(document);
    if (!jar)
        return;

    QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toAscii());
#if QT_VERSION >= 0x040500
    QList<QNetworkCookie>::Iterator it = cookies.begin();
    while (it != cookies.end()) {
        if (it->isHttpOnly())
            it = cookies.erase(it);
        else
            ++it;
    }
#endif
    jar->setCookiesFromUrl(cookies, p);
#else
    QCookieJar::cookieJar()->setCookies(u, p, (QString)value);
#endif
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:24,代码来源:BCCookieJarQt.cpp


注:本文中的QNetworkCookieJar::setCookiesFromUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。