简体   繁体   English

在C ++中使用Curl 7.47.1重定向URL

[英]Redirect url with Curl 7.47.1 in C++

I'm using Curl 7.47.1 to download a Redirect url. 我正在使用Curl 7.47.1下载重定向URL。 However, it always returns 但是,它总是返回

CURLE_UNSUPPORTED_PROTOCOL CURLE_UNSUPPORTED_PROTOCOL

char *url = "http://www.foxitsoftware.com/downloads/latest.php?product=Foxit-Reader&platform=Windows";

CURL * m_curl;

FILE pFile = fopen(outfilename,"wb");


m_curl = curl_easy_init();

curl_easy_setopt(m_curl, CURLOPT_URL, url);

curl_easy_setopt(m_curl, CURLOPT_FOLLOWLOCATION, 1);

curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, write_data);

curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, pFile);

curl_easy_setopt(m_curl, CURLOPT_HEADER, 1L);

curl_easy_setopt(m_curl, CURLOPT_HEADERFUNCTION, HeaderCallback);

CURLcode res =  curl_easy_perform(m_curl);
  1. Add CURLOPT_VERBOSE set to 1L to get some additional information. 添加CURLOPT_VERBOSE设置为1L以获得一些其他信息。
  2. The error code CURLE_UNSUPPORTED_PROTOCOL means you're asking for a resource/URL over a protocol that your libcurl build doesn't support. 错误代码CURLE_UNSUPPORTED_PROTOCOL表示您正在通过libcurl构建不支持的协议请求资源/ URL。 As you're following redirects, that could mean that the first server redirects you over to an non-supported protocol. 当您进行重定向时,这可能意味着第一台服务器会将您重定向到不受支持的协议。 You may need to rebuild libcurl to make it support the protocol, or you're using a rarer protocol that libcurl doesn't support at all. 您可能需要重建libcurl以使其支持该协议,或者您使用的是libcurl根本不支持的稀有协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM