Ok, I rewrote everything. If you check in the code below, you'll see the output I get.
Code:
#include <iostream>
#include "curl/curl.h"
using namespace std;
int main()
{
CURL *curl_handle;
CURLcode result;
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, "http://www.google.com/");
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, true);
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, true);
curl_easy_setopt(curl_handle, CURLOPT_AUTOREFERER, true);
curl_easy_perform(curl_handle);
char *lasturl = NULL;
result = curl_easy_getinfo(curl_handle, CURLINFO_EFFECTIVE_URL, &lasturl);
/*
here is the output:
LastURL: http://www.google.co.nz/
* <url> malformed
* URL using bad/illegal format or missing URL
* Closing connection #0
* Closing connection #1
*/
if ((result == CURLE_OK) && lasturl) {
cout << "LastURL: " << lasturl << endl;
curl_easy_setopt(curl_handle, CURLOPT_URL, lasturl);
curl_easy_perform(curl_handle);
}
curl_easy_cleanup(curl_handle);
return 0;
}
Now if I set lasturl manually, like so:
Code:
lasturl = "http://www.google.co.nz/";
It works perfectly? I still think this is a syntax issue though?