QNetworkAccessManager跳转URL处理(使用QNetworkRequest::RedirectionTargetAttribute获得跳转URL)
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*)));
void MainClass::onFinished(QNetworkReply* reply)
{
int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
QString strUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString();
qDebug() << "FINISHED" << statusCode;
switch (statusCode)
{
case 200: // OK
{
// process reply
if (!isLoggedIn())
storeAuthorization(reply);
switch (state)
{
case stGetCalendars:
{
parseCalendarList(reply);
break;
}
case stGetEvents:
{
parseEventList(reply);
break;
}
}
break;
}
case 302: // redirect (Location: [URL])
{
qDebug() << "redirected to" << locationOf(reply);
prepare(locationOf(reply));
manager->get(*lastRequest);
break;
}
case 400: // bad request
{
QMessageBox::warning(this, "Error", "Network error (HTTP400/Bad Request)");
break;
}
case 403: // permission denied
{
QMessageBox::warning(this, "Permission denied", "Username or password invalid");
break;
}
default:
{
QByteArray replyData = reply->readAll();
qDebug() << "Unknown response" << replyData;
break;
}
}
reply->deleteLater();
// do anything afterwards?
after(); // <-- next request via manager->get()
qDebug() << "request done";
}
http://blog.csdn.net/itjobtxq/article/details/8268675
QNetworkAccessManager跳转URL处理(使用QNetworkRequest::RedirectionTargetAttribute获得跳转URL)的更多相关文章
- IIS 7.5 使用URL Rewrite模块简单设置网页跳转
原文 IIS 7.5 使用URL Rewrite模块简单设置网页跳转 我们都知道Apache可以在配置文件里方便的设置针对网页或网站的rewrite,但是最近接手了一组IIS服务器,发现这货简单的没有 ...
- nginx配置url中带问号的rewrite跳转
今天收到一个需求,要将一个带查询参数的url跳转到另外一个静态url,安装常规的rewrite规则,如: rewrite ^/a.html?id=67$ http://zt.epython.cn/20 ...
- IIS问题解决:URL中制表符引起的Bad Request - Invalid URL
昨天处理好了Google网站管理员中的500错误,今天处理了一些400处理,比如下面的以制表符(tab)结尾的URL: http://www.cnblogs.com/me-sa/archive/200 ...
- JS页面跳转和js对iframe进行页面跳转、刷新
一.js方式的页面跳转1.window.location.href方式 <script language="JavaScript" type="text/ja ...
- HTTP 请求方式: GET和POST的比较当发送数据时,GET 方法向 URL 添加数据;URL 的长度是受限制的(URL 的最大长度是 2048 个字符)。
什么是HTTP? 超文本传输协议(HyperText Transfer Protocol -- HTTP)是一个设计来使客户端和服务器顺利进行通讯的协议. HTTP在客户端和服务器之间以request ...
- 转载: js jquery 获取当前页面的url,获取frameset中指定的页面的url(有修改)
转载网址:http://blog.csdn.net/bestlxm/article/details/6800077 js jquery 怎么获取当前页面的url,获取frameset中指定的页面的ur ...
- 编写一个C语言函数,要求输入一个url,输出该url是首页、目录页或者其他url
编写一个C语言函数,要求输入一个url,输出该url是首页.目录页或者其他url 首页.目录页或者其他url 如下形式叫做首页: militia.info/ www.apcnc.com.cn/ htt ...
- ASP.NET 取得 Request URL 的各个部分和通过ASP.NET获取URL地址的方法
网址:http://localhost:1897/News/Press/Content.aspx/123?id=1#toc Request.ApplicationPath / Request.Phys ...
- URL Schemes 不能识别和不能跳转的原因
在app跳转的过程中 需要设置url schemes后,但是设置完后,却不能识别, (测试方式:URL scheme + ://)在浏览器中打开,如果能打开app,就是能跳转 今天遇到了一个坑爹的问题 ...
随机推荐
- How to get the xpath by clicking an html element
How to get the xpath by clicking an html element How to get the xpath by clicking an html element
- java 基本语法元素
单行注释: // 多行注释: /* */ java文档: /**JAVA文档 *注释 */ : : 类似于中文的句号. 语句块:语句块也叫做复合语句 ...
- Android animation学习笔记之view/drawable animation
前一章中总结了android animation中property animation的知识和用法,这一章总结View animation和Drawable animation的有关知识: View ...
- /usr/bin/env: node: no such file or directory
今天在安装gulp的之后,运行gulp命令出现了如下报错: /usr/bin/env: node: no such file or directory 网上找了好久,终于解决了,所以记录一下,便于下次 ...
- UVa1586 Molar mass
#include <stdio.h> int GetQuantity(char* q, char** p){ int quantity = 0; while (*q & ...
- HDOJ 3415 Max Sum of Max-K-sub-sequence(单调队列)
因为是circle sequence,可以在序列最后+序列前n项(或前k项);利用前缀和思想,预处理出前i个数的和为sum[i],则i~j的和就为sum[j]-sum[i-1],对于每个j,取最小的s ...
- Zencart先生成订单后付款,类似淘宝后台修改订单价格
Zencart 使用 Paypal 付款,会出现漏单的情况,即 paypal 已经收到客户的付款,但是网站后台没有客户的订单.导致 paypal 漏单的原因大致会是当客户跳转到Paypal 网站付款完 ...
- 6.PHP 教程_PHP数据类型
PHP数据类型 String(字符串),Integer(整型),Float(浮点型),Boolean(布尔型),Array(数组),Object(对象), NULL(空值). PHP字符串 一个字符串 ...
- [LeetCode]题解(python):126-Word Ladder II
题目来源: https://leetcode.com/problems/word-ladder-ii/ 题意分析: 给定一个beginWord和一个endWord,以及一个字典单词,找出所有从begi ...
- C-重定向
说实话,第一次接触重定向这一个概念,感觉是那么的神奇简洁不可思议…………………… freopen() 本来应该是打开的是文件指针,但是分配了指针,使她(亲切)指向了标准输入.输出.错误流. 用 法: ...