首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

珍藏 熟悉libcurl的请进

2013-04-09 
收藏 熟悉libcurl的请进!问个问题啊,发现有几个https居然不能正常访问,比如下面这个curl_easy_setopt(curl

收藏 熟悉libcurl的请进!
问个问题啊,发现有几个https居然不能正常访问,比如下面这个
curl_easy_setopt(curl, CURLOPT_URL, "https://loginchina.alibaba.com/member/signin.htm");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);打开调试,发现一直会跳转,一直跳转到127.0.0.1,返回Couldn't connect to server。
苦逼啊,其他https正常,大牛帮看看啊。

附上调试信息:
* About to connect() to loginchina.alibaba.com port 443 (#0)
*   Trying 110.75.196.32... * connected
* Connected to loginchina.alibaba.com (110.75.196.32) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
*       subject: CN=*.alibaba.com,OU=Terms of use at www.verisign.com/rpa (c)05,OU=Research & Develop Center,O="Taobao(China) Software Co., Ltd",L=Hangzhou,ST=Zhejiang,C=CN
*       start date: Nov 18 00:00:00 2012 GMT
*       expire date: Dec 12 23:59:59 2013 GMT
*       common name: *.alibaba.com
*       issuer: CN=VeriSign Class 3 Secure Server CA - G3,OU=Terms of use at https://www.verisign.com/rpa (c)10,OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US
> GET / HTTP/1.1
Host: loginchina.alibaba.com
Accept: */*

< HTTP/1.1 301 Moved Permanently
< Date: Mon, 01 Apr 2013 01:23:01 GMT
< Server: Apache
< Location: https://loginchina.alibaba.com:443/member/signin.htm
< Cache-Control: max-age=0
< Expires: Mon, 01 Apr 2013 01:23:01 GMT
< Vary: Accept-Encoding
< Content-Length: 260
< Content-Type: text/html; charset=iso-8859-1
<
* Ignoring the response-body
* Connection #0 to host loginchina.alibaba.com left intact
* Issue another request to this URL: 'https://loginchina.alibaba.com:443/member/signin.htm'
* Re-using existing connection! (#0) with host loginchina.alibaba.com
* Connected to loginchina.alibaba.com (110.75.196.32) port 443 (#0)
> GET /member/signin.htm HTTP/1.1
Host: loginchina.alibaba.com
Accept: */*

< HTTP/1.1 302 Found
< Date: Mon, 01 Apr 2013 01:23:01 GMT
< Server: Apache
< Location: http://127.0.0.1/
< Cache-Control: max-age=0
< Expires: Mon, 01 Apr 2013 01:23:01 GMT
< Vary: Accept-Encoding
< Content-Length: 201
< Content-Type: text/html; charset=iso-8859-1
< X-Pad: avoid browser bug
<
* Ignoring the response-body
* Connection #0 to host loginchina.alibaba.com left intact
* Issue another request to this URL: 'http://127.0.0.1/'


* About to connect() to 127.0.0.1 port 80 (#1)
*   Trying 127.0.0.1... * Connection refused
* couldn't connect to host
* Closing connection #1
* Couldn't connect to server
curl_easy_perform() failed: Couldn't connect to server
* Closing connection #0
[解决办法]
HTTP 301, 302? 重定向?
楼主没有设置"User-Agent", 这是网站的防攻击措施。

curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0");

热点排行