Using Curl for downloading.

Hello,

I'm using Curl 7.47.1 for downloading some files from internet. But I'm facing a trouble and I do not know how to fix it.
Please kindly help me to take a look my trouble as below.

I'd like to download a file at http://www.foxitsoftware.com/downloads/latest.php?product=Foxit-Reader&platform=Windows.
To do it, I set some following options:

char *url = http://www.foxitsoftware.com/downloads/latest.php?product=Foxit-Reader&platform=Windows;
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, 0L);

CURLcode res = curl_easy_perform(m_curl);

However, it always returns CURLE_UNSUPPORTED_PROTOCOL after calling curl_easy_perform method.

Could you please let me know where my mistake in my source code?

Thanks,
Make our lives easier and use code tags.
You can configure curl to be a bit more verbose with errors. Try something like this and see what it says:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <string>
/**/

int main() {
	curl_global_init(CURL_GLOBAL_ALL);
	CURL* handle = curl_easy_init();
	CURLcode code;

	std::string string_error = "";
	std::string string_url = /**/;

	char error_buffer[CURL_ERROR_SIZE] = {};

	curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, error_buffer);
	/*...*/
	curl_easy_setopt(handle, CURLOPT_URL, string_url.c_str());

	code = curl_easy_perform(handle);
	curl_easy_cleanup(handle);

	string_error = error_buffer;
	std::cout << string_error << std::endl;

	curl_global_cleanup();
	return 0;
}
Hi Xismn,
Thanks for your support.
I got error message "Protocol "https" not supported or disabled in libcurl". I check all of Options in libcurl but not found that method.

Could you please tell me how to enable it?
many thanks
The URL that you are trying to download redirects to another URL that uses the HTTPS protocol.

https://curl.haxx.se/docs/faq.html#Protocol_xxx_not_supported_or_di
https://curl.haxx.se/docs/faq.html#curl_1_SSL_is_disabled_https
Last edited on
Thanks for your help. I fixed it.
Topic archived. No new replies allowed.