本文整理汇总了C++中QNetworkReply::hasRawHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkReply::hasRawHeader方法的具体用法?C++ QNetworkReply::hasRawHeader怎么用?C++ QNetworkReply::hasRawHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkReply
的用法示例。
在下文中一共展示了QNetworkReply::hasRawHeader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finishedFetchingGroups
void Groups::finishedFetchingGroups()
{
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
if (reply->hasRawHeader("Backoff"))
d->api->startBackoff(QString::fromLatin1(reply->rawHeader("Backoff").constData()).toInt());
else if (reply->hasRawHeader("Retry-After"))
d->api->startBackoff(QString::fromLatin1(reply->rawHeader("Retry-After").constData()).toInt());
if (reply->error() == QNetworkReply::NoError) {
QString nextPage;
QXmlStreamReader xmlReader(reply);
while (!xmlReader.atEnd() && !xmlReader.hasError()) {
const QXmlStreamReader::TokenType tt = xmlReader.readNext();
if (tt == QXmlStreamReader::StartElement && xmlReader.name() == QStringLiteral("entry")) {
QString label;
int groupId = -1;
while (!xmlReader.atEnd() && !xmlReader.hasError()) {
const QXmlStreamReader::TokenType tt = xmlReader.readNext();
if (tt == QXmlStreamReader::StartElement && xmlReader.name() == QStringLiteral("title"))
label = xmlReader.readElementText(QXmlStreamReader::IncludeChildElements);
else if (tt == QXmlStreamReader::StartElement && xmlReader.name() == QStringLiteral("groupID")) {
bool ok = false;
groupId = xmlReader.readElementText(QXmlStreamReader::IncludeChildElements).toInt(&ok);
if (groupId < 1) groupId = -1;
} else if (tt == QXmlStreamReader::EndElement && xmlReader.name() == QStringLiteral("entry"))
break;
}
if (!label.isEmpty() && groupId > 0)
d->groups.insert(groupId, label);
} else if (tt == QXmlStreamReader::StartElement && xmlReader.name() == QStringLiteral("link")) {
const QXmlStreamAttributes attrs = xmlReader.attributes();
if (attrs.hasAttribute(QStringLiteral("rel")) && attrs.hasAttribute(QStringLiteral("href")) && attrs.value(QStringLiteral("rel")) == QStringLiteral("next"))
nextPage = attrs.value(QStringLiteral("href")).toString();
} else if (tt == QXmlStreamReader::EndElement && xmlReader.name() == QStringLiteral("feed"))
break;
}
if (!nextPage.isEmpty())
d->requestZoteroUrl(nextPage);
else {
d->busy = false;
d->initialized = true;
emit finishedLoading();
}
} else {
qCWarning(LOG_KBIBTEX_NETWORKING) << reply->errorString(); ///< something went wrong
d->busy = false;
d->initialized = false;
emit finishedLoading();
}
}
示例2: replyFinished
void Sound::replyFinished() {
QNetworkReply* reply = reinterpret_cast<QNetworkReply*>(sender());
// replace our byte array with the downloaded data
QByteArray rawAudioByteArray = reply->readAll();
// foreach(QByteArray b, reply->rawHeaderList())
// qDebug() << b.constData() << ": " << reply->rawHeader(b).constData();
if (reply->hasRawHeader("Content-Type")) {
QByteArray headerContentType = reply->rawHeader("Content-Type");
// WAV audio file encountered
if (headerContentType == "audio/x-wav"
|| headerContentType == "audio/wav"
|| headerContentType == "audio/wave") {
QByteArray outputAudioByteArray;
interpretAsWav(rawAudioByteArray, outputAudioByteArray);
downSample(outputAudioByteArray);
} else {
// Process as RAW file
downSample(rawAudioByteArray);
}
} else {
qDebug() << "Network reply without 'Content-Type'.";
}
_hasDownloaded = true;
}
示例3: hasRawHeader
bool QNetworkReplyProto::hasRawHeader(const QByteArray &headerName) const
{
QNetworkReply *item = qscriptvalue_cast<QNetworkReply*>(thisObject());
if (item)
return item->hasRawHeader(headerName);
return false;
}
示例4: requestSuccess
void GetFileDownloadLinkRequest::requestSuccess(QNetworkReply& reply)
{
QString reply_content(reply.readAll());
QString oid;
if (reply.hasRawHeader("oid"))
oid = reply.rawHeader("oid");
do {
if (reply_content.size() <= 2)
break;
reply_content.remove(0, 1);
reply_content.chop(1);
QUrl new_url(reply_content);
if (!new_url.isValid())
break;
file_id_ = oid;
emit success(reply_content);
return;
} while (0);
emit failed(ApiError::fromHttpError(500));
}
示例5: processSubscribeDanmakuResponse
void SubscribeThread::processSubscribeDanmakuResponse()
{
QNetworkReply *reply = (QNetworkReply *)sender();
int statusCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt();
if(reply->hasRawHeader("Location")){
QString strLocation = reply->header(QNetworkRequest::LocationHeader).toString();
this->subscribeDanmaku(strLocation);
}else if(statusCode == 200){
QByteArray responseData = reply->readAll();
// qDebug()<<"response data:"<<responseData;
QJsonDocument jsonDoc = QJsonDocument::fromJson(responseData);
if(jsonDoc.isNull() ||!jsonDoc.isArray())
{// null or not array format
goto out;
}
QJsonArray jsonArray = jsonDoc.array();
for(int i = 0; i < jsonArray.count();i++){
QJsonValue jsonValue = jsonArray[i];
if(jsonValue.isUndefined()||jsonValue.isNull())
{
goto out;
}
QString text = jsonValue.toObject().value("text").toString();
QString position = jsonValue.toObject().value("position").toString();
QString style = jsonValue.toObject().value("style").toString();
if(text.size()>128){
text.resize(128);
}
Danmaku_Msg msg;
msg.msg = text;
if(style=="blue"){
msg.color = QColor("#0000FF");
}else if(style=="white"){
msg.color = QColor("#FFFFFF");
}else if(style=="red"){
msg.color = QColor("#FF0000");
}else if(style=="yellow"){
msg.color = QColor("yellow");
}else if(style=="cyan"){
msg.color = QColor("cyan");
}else if(style=="green"){
msg.color = QColor("#00FF00");
}else if(style=="purple"){
msg.color = QColor("#871F78");
}else{
msg.color = QColor("black");
}
if(position=="top"){
msg.positon = BULLET_TOP;
}else if(position == "bottom")
{
msg.positon = BULLET_BOTTOM;
}else
{
msg.positon = BULLET_FLY;
}
emit this->receivedDamanku(msg);
}
}
out:
qApp->processEvents(QEventLoop::AllEvents);
if(reply->error() == QNetworkReply::NoError){
this->pullDanmaku();
}else
{
QTimer::singleShot(2000,this,SLOT(pullDanmaku()));
}
reply->deleteLater();
return;
}