本文整理汇总了C++中QNetworkReply::rawHeaderList方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkReply::rawHeaderList方法的具体用法?C++ QNetworkReply::rawHeaderList怎么用?C++ QNetworkReply::rawHeaderList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkReply
的用法示例。
在下文中一共展示了QNetworkReply::rawHeaderList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void RequestModel::update()
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
if (!reply)
return;
int offset;
for (offset = m_requests.count() - 1; offset >= 0; --offset) {
if (m_requests[offset].reply == reply)
break;
}
if (offset < 0)
return;
// Save reply headers
foreach (const QByteArray &header, reply->rawHeaderList() ) {
QPair<QByteArray, QByteArray> pair(header, reply->rawHeader(header));
m_requests[offset].replyHeaders.append(pair);
}
// Save reply info to be displayed
int status = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt();
QString reason = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
m_requests[offset].response = QString(QLatin1String("%1 %2")).arg(status).arg(reason);
m_requests[offset].length = reply->header(QNetworkRequest::ContentLengthHeader).toInt();
m_requests[offset].contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString();
if (status == 302) {
QUrl target = reply->attribute( QNetworkRequest::RedirectionTargetAttribute ).toUrl();
m_requests[offset].info = tr("Redirect: %1").arg(target.toString());
}
}
示例2:
QList<QByteArray> QNetworkReplyProto::rawHeaderList() const
{
QNetworkReply *item = qscriptvalue_cast<QNetworkReply*>(thisObject());
if (item)
return item->rawHeaderList();
return QList<QByteArray>();
}
示例3: main
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QNetworkAccessManager manager;
if (argc != 2) {
std::cout << "usage: " << argv[0] << " <url>" << std::endl;
return 0;
}
QUrl url(app.arguments().value(1));
QNetworkRequest request(url);
QNetworkReply *reply = manager.get(request);
app.connect(reply, SIGNAL(finished()), SLOT(quit()));
app.exec();
QFile outfile("request.header");
if (outfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream stream(&outfile);
QList<QByteArray> list = reply->rawHeaderList();
foreach (QByteArray name, list) {
stream << name << ": " << reply->rawHeader(name) << endl;
}
示例4: uploadReply
void YandexNarodUploadJob::uploadReply()
{
m_timer.stop();
debug() << "uploadReply";
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
Q_ASSERT(reply);
if (!processReply(reply))
return;
QByteArray data = reply->readAll();
QVariantMap map = Json::parse(data).toMap();
debug() << "upload" << data << map;
debug() << reply->rawHeaderList();
debug() << "upload" << reply->rawHeader("Set-Cookie");
someStrangeSlot();
}