cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_perform occasionally responds even though the PC is disconnected from the network

From: Alan Wolfe <alan.wolfe_at_gmail.com>
Date: Mon, 20 Sep 2010 09:03:48 -0700

To expand on that, i'm thinking if you are making a request with the
same URL after disconnecting as you made before disconnecting, the
response could be in the cache and so you are getting the same results
back.

You can fight caching via settings in the http header, but one thing
i've used in the past to fight caching is to add an argument to the
end of each of my requests that had a random number as a value.

http://www.google.com

becomes

http://www.google.com/?r=54637

http://www.mydomain.com/blah/blah.php?arg1=fu&arg2=bar

becomes

http://www.mydomain.com/blah/blah.php?arg1=fu&arg2=bar&r=73829

This helps make each http request look more unique which results in
far less chance of your result being cached when you don't want it to
be.

In your case, it would help make sure that they had to be online to
get an actual response if cacheing is to blame.

Hope that helps, someone else may have some more insight too.

On Mon, Sep 20, 2010 at 8:30 AM, Alan Wolfe <alan.wolfe_at_gmail.com> wrote:
> Do you think you could be seeing a cached response?
>
> On Sep 20, 2010 8:27 AM, "Johnny Beardsmore" <jny0_at_hotmail.com> wrote:
>
> Hi,
>
> I'm using the following (abreviated) code:
>
> //**************************************************
> curl_easy_reset(curl);
> curl_wr_error = curl_wr_index = 0;
>
> // setup curl options
> curl_easy_setopt(curl, CURLOPT_URL, CURL_SERVER);
>
> // Tell curl that we'll receive data to the function write_data, and
> // also provide it with a context pointer for our error return.
> curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &curl_wr_error);
> curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_data);
>
> char send_data[CURL_MAX_POST];
> strcpy(send_data,buffer);
>
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS, send_data);
>
> ret = curl_easy_perform(curl);
>
> printf("\nSEND_DATA REPORT---> Server Response: %s", &curl_wr_buf[1]);
> //**************************************************
>
> I call curl_easy_perform approximatly every 5 seconds.  When I'm connected
> to the network, it works fine.  When I disconnect, curl_easy_perform doesn't
> get a response (which is what you'd expect), but approximately every 80
> calls, it does, i.e. ret contains a value.  What's even more confusing, is
> the value matches the expected MD5 response.  What could be causing this?
> It would seem like a time out to me, it it wasn't for the *valid* reponse.
>
> Regards,
> jny
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html
>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-09-20