if and elxe blocks are executed

Hi!
I'm having a strange behaviour, so i must be something really stupid.
The code :

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
28
29
30
31
32
33
34
#include <curl/curl.h>

#include <iostream>

/****************************************************************/
/*!
 * Notifier application for new releases of used libraries
*****************************************************************/


int main(int argc, char**argv){

	void *buffer=calloc(20480,1);
	size_t readBytes=0;
	CURL* request=curl_easy_init();
	curl_easy_setopt(request,CURLOPT_URL,"http://icl.cs.utk.edu/projectsfiles/plasma/pubs/ReleaseNotes");
	curl_easy_setopt(request, CURLOPT_HEADER, true);
	curl_easy_perform(request);
	CURLcode result = curl_easy_recv(request,buffer,20480,&readBytes);

	if (result==CURLE_OK)
	{
		std::cout<<buffer<<std::endl;
		std::cout<<readBytes<<" bytes received"<<std::endl;		
	}else
	{
		std::cout<<"Request failed!"<<std::endl;
	}
	std::cin>>readBytes;
	curl_easy_cleanup(request);
	free(buffer);

	return 0;
}

It compiles fines, but at runtime, i get in output the first cout of the if block, and the cout of the else statement. How can it not run the complete if block? And run the if AND the else block?
(The downloaded file is smaller than the buffer, in case you ywould suspect a buffer overflow there)
It is line 18 that prints the content of the file.
Ah ok hehe, it's my first cURL program
Would you know how to disable the output in the console, and why it says the operation failed even though i see the full content of the file?
http://curl.haxx.se/libcurl/c/curl_easy_recv.html

The docs says you should set the CURLOPT_CONNECT_ONLY option before calling curl_easy_perform.

curl_easy_setopt(request, CURLOPT_CONNECT_ONLY, true);
Topic archived. No new replies allowed.