curl-library
Re: Flag to know if the curl object used a previously openedconnection
Date: Tue, 12 Oct 2004 15:54:49 +0100
Ok. I didnt code in C for a loooooong time, I hope my memories are not too
bad.
Thereafter a proposition :
Instead of a boolean (which btw is not a type used for CURLINFO), I finally
used 3 cases ("FALSE", "TRUE" and
It_was_true_but_you_asked_to_follow_the_location_and_this_location_needed_a_
new_connection).
curl_reused_info reused_conn;
res = curl_easy_getinfo(curl, CURLINFO_REUSED_CONNECTION, &reused_conn);
So if reused_conn == CURL_REUSED_TRUE: yes, re-used an already open
connection
else : no, it had to reconnect. (either directly or followed a location that
needed it)
I'm new to libcurl so I dont know where you want to put the information, ->
I used the struct PureInfo (could be in any other struct in data)
Tell me what you think ?
Note : I'm not sure but I expect that enum (int in theory) are long and not
short ?
Index: include/curl/curl.h
===================================================================
RCS file: /cvsroot/curl/curl/include/curl/curl.h,v
retrieving revision 1.265
diff -r1.265 curl.h
1182a1183
> CURLINFO_REUSED_CONNECTION= CURLINFO_LONG + 26,
1184c1185
< CURLINFO_LASTONE = 26
--- > CURLINFO_LASTONE = 27 1190a1192,1198 > > typedef enum { > CURL_REUSED_FALSE, > CURL_REUSED_TRUE, > CURL_REUSED_TRUE_BUT_FOLLOW_AND_RECONNECT > } curl_reused_info; > Index: lib/getinfo.c =================================================================== RCS file: /cvsroot/curl/curl/lib/getinfo.c,v retrieving revision 1.38 diff -r1.38 getinfo.c 65a66 > info->reusedconnection = 0; 172a174,177 > case CURLINFO_REUSED_CONNECTION: > *param_longp = data->info.reusedconnection; > break; > Index: lib/transfer.c =================================================================== RCS file: /cvsroot/curl/curl/lib/transfer.c,v retrieving revision 1.250 diff -r1.250 transfer.c 1888a1889,1893 > /* update the reused info to follow_and_reconnect, if the connection is > finally reused (like a location to the same domain) this info will be > updated to CURL_REUSED_TRUE and if a new connection is made, it will keep > this value */ > data->info.reusedconnection = CURL_REUSED_TRUE_BUT_FOLLOW_AND_RECONNECT; Index: lib/url.c =================================================================== RCS file: /cvsroot/curl/curl/lib/url.c,v retrieving revision 1.418 diff -r1.418 url.c 3164a3165 > data->info.reusedconnection = CURL_REUSED_TRUE; /* so we tell the user */ 3598c3599,3600 < --- > data->info.reusedconnection = CURL_REUSED_FALSE; /* so erase this infp */ > Index: lib/urldata.h =================================================================== RCS file: /cvsroot/curl/curl/lib/urldata.h,v retrieving revision 1.240 diff -r1.240 urldata.h 627a628,629 > curl_reused_info reusedconnection; /* did it re-use an existing > connection ? */ ____________________ Guillaume ----- Original Message ----- From: "Daniel Stenberg" <daniel-curl_at_haxx.se> To: "libcurl development" <curl-library_at_cool.haxx.se> Sent: Monday, October 11, 2004 6:30 PM Subject: Re: Flag to know if the curl object used a previously openedconnection > On Mon, 11 Oct 2004, Guillaume Arluison wrote: > > > And well if there is no easy way to do this, may I kindly ask to add a > > boolean CURLINFO_REUSED_CONNECTION in curl_easy_getinfo that returns if it > > uses or not a previously opened connection ? > > I think this sounds like the only sane and reliable way to retrieve this info. > And yes, I would accept a patch that introduces this. > > > I can try to spend some time on the code to propose a patch if you need. > > Please do! > > -- > Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se > Dedicated custom curl help for hire: http://haxx.se/curl.html > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.764 / Virus Database: 511 - Release Date: 16/09/2004Received on 2004-10-12