What is wrong with my libcurl code for HTTP communication via proxy?

Started by
-1 comments, last by floatingwoods 14 years, 5 months ago
Hello, Since recently I am using libCurl (http://curl.haxx.se/) for HTTP communications. It works fine unless there is a HTTP proxy server in-between. Following code doesn't work somehow (the returned error string is "Couldn't connect to server"):

	curl_global_init(CURL_GLOBAL_ALL);
	CURL *curl;
	CURLcode res;
	curl=curl_easy_init();
	if (curl) 
	{
		curl_easy_setopt(curl,CURLOPT_PROXY,"proxy.noc.titech.ac.jp:3128");
		curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,_curlWriteFunction);
		curl_easy_setopt(curl,CURLOPT_URL,"http://test.dynalias.net?data1=hello&data2=world");
		res=curl_easy_perform(curl);
		curl_easy_cleanup(curl);
	}
	curl_global_cleanup();

The same above code (without the CURL_PROXY line) on a computer not relying on a proxy works fine. Did I miss something important when dealing with a proxy? (the proxy doesn't require any username nor password btw)

This topic is closed to new replies.

Advertisement