I am trying to write a C++ program to read from a website using cURL. I have started with using the code from the cURL example simple.c. If I use that code exactly, no matter what URL I try to access, I obtain error #52: "empty reply from server". This is for any URL I try. If I use cURL from the command line, it seems to work fine.
The verbose response of my program is:
*About to connect() to www.google.com port 80 (#0)
* Trying 74.125.91.99...* connected
*connected to www.google.com (74.125.91.99) port 80 (#0)
>GET / HTTP/1.1
Host: www.google.com
Accept: */*
* Empty reply from server
* Connection #0 to host www.google.com left intact
* server returned nothing (no headers, no data)
*Closing connection #0
The code is:
CURL *curl;
CURLcode res;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com");
curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
TRUE
wasn't defined, but using1
worked)CURLOPT_VERBOSE
flag. Some versions (I can't remember which exactly) have awful bug using CURLOPT_VERBOSE flag, set to 1. Try without it. Also, which is the curl'a version?