让 cocos2d-x 的 CCHttpRequest 支持https
由于游戏用到了网络头像, 今天发现换成facebook登陆后头像下载失败, 2dx默认的没有支持https, 于是找到 network/HttpClient.cpp
[cpp]
[cpp]
int processGetTask(CCHttpRequest *request, write_callback callback, void *stream, int *responseCode)
{
CURLcode code = CURL_LAST;
CURL *curl = curl_easy_init();
do {
if (!configureCURL(curl))
{
break;
}
/* handle custom header data */
/* create curl linked list */
struct curl_slist *cHeaders=NULL;
/* get custom header data (if set) */
std::vector<std::string> headers=request->getHeaders();
if(!headers.empty())
{
for(std::vector<std::string>::iterator it=headers.begin();it!=headers.end();it++)
{
/* append custom headers one by one */
cHeaders=curl_slist_append(cHeaders,it->c_str());
}
/* set custom headers for curl */
code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, cHeaders);
if (code != CURLE_OK) {
break;
}
}
code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl());
if (code != CURLE_OK)
{
break;
}
code = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, request->getUrl());
if (code != CURLE_OK)
{
break;
}
code = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback);
if (code != CURLE_OK)
{
break;
}
code = curl_easy_setopt(curl, CURLOPT_WRITEDATA, stream);
if (code != CURLE_OK)
{
break;
}
code = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
if (code != CURLE_OK) {
break;
}
code = curl_easy_perform(curl);
if (code != CURLE_OK)
{
break;
}
/* free the linked list for header data */
curl_slist_free_all(cHeaders);
code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode);
if (code != CURLE_OK || *responseCode != 200)
{
code = CURLE_HTTP_RETURNED_ERROR;
}
} while (0);
if (curl) {
curl_easy_cleanup(curl);
}
return (code == CURLE_OK ? 0 : 1);
}
//Process POST Request
int processPostTask(CCHttpRequest *request, write_callback callback, void *stream, int32_t *responseCode)
{
CURLcode code = CURL_LAST;
CURL *curl = curl_easy_init();
do {
if (!configureCURL(curl)) {
break;
}
/* handle custom header data */
/* create curl linked list */
struct curl_slist *cHeaders=NULL;
/* get custom header data (if set) */
std::vector<std::string> headers=request->getHeaders();
if(!headers.empty())
{
for(std::vector<std::string>::iterator it=headers.begin();it!=headers.end();it++)
{
/* append custom headers one by one */
cHeaders=curl_slist_append(cHeaders,it->c_str());
}
/* set
补充:移动开发 , 其他 ,
- 更多wap疑问解答:
- 新人求助QPainter
- 为什么程序都退出了还可以收到推送?如果大多设备都可以推送那运营商怎么办?
- qt 4.7 sqlserver2000 存储过程调用
- 关于ANDROID4.0.1编译问题!
- Android FrameBuffer读屏幕30秒后mmap失败
- 联通粗定位用java程序如何来请求和接受数据
- 为什么QT运行Android平台的程序时,mouseMoveEvent事件响应的间隔时间很长??????????
- android与PC蓝牙通讯
- 指定大小的label 内容可变,如果内容超出label的宽度,将未能显示的部分显示在另一个label上
- Android调试
- android如何通过wifi连接无线打印机
- 运行程序,release目录下产生一个乱码文件夹
- 分享个某机构最新安卓资料,自己验证了
- service启动不起来,掉不了service connection
- 求助:QT5.0 没有QPrinter吗