cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: problem with return value of curl_easy_getinfo

From: Miloš Zubal <milos.zubal_at_post.cz>
Date: Tue, 06 Sep 2005 10:22:09 +0200 (CEST)

Today i tried to debug my code.
Problem was with pointer url->BuildURI().GetData()
passing it to curl_easy_setopt(...) was wrong, because pointed
data (or pointer itself) were obviously changed during
downloading header. Program started to have expected behavior
after fixing code to:

wxChar urlres[2048+1];
strcpy(urlres, url->BuildURI().c_str());
curl_easy_setopt(curl, CURLOPT_URL, urlres);

quite a begginers fault (maybe caused by fact i am begginer :D )

hope i helped somebody with problem...

Bye,

Milos Zubal

> On Thu, 1 Sep 2005, Milo? Zubal wrote:
>
> > i am experiencing a problem when getting effective
> > url...
>
> Ok, I converted your program into a fully working
> source snippet. I get no
> problems at all when I run this, neither with 7.14.0 or
> with the latest CVS
> version. I also tried to disable the FOLLOWLOCATION
> (since in my case google
> redirects me to www.google.se when I run this).
>
> Are you getting the same problem with this exact
> program?
>
>
> #include <curl/curl.h>
>
> int main(void)
> {
> CURL *curl;
> CURLcode res;
> curl = curl_easy_init();
> if(curl) {
> curl_easy_setopt(curl, CURLOPT_URL,
> "http://www.google.com");
> curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
> curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 5);
> curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
> res = curl_easy_perform(curl);
> if (res != CURLE_OK) {
> return res;
> }
>
> char* info = NULL;
> res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL,
> &info);
> if((CURLE_OK == res) && info) {
> printf("URL: %s\n", info);
> }
> }
> return 0;
> }
>
>
> --
> Commercial curl and libcurl Technical Support:
> http://haxx.se/curl.html
>
Received on 2005-09-06