diff options
author | Daniel Stenberg <daniel@haxx.se> | 2004-10-19 15:30:08 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2004-10-19 15:30:08 +0000 |
commit | f4bef25b5eede9ea17f237ebae52c2f89cc211cd (patch) | |
tree | 35670c54ced8bfe2821af24151fae4c84ad79b84 | |
parent | ebf7d225036bb060402ee6a66988a3de877cdd1a (diff) | |
download | curl-f4bef25b5eede9ea17f237ebae52c2f89cc211cd.tar.gz |
CURLINFO_NUM_CONNECTS and more
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | RELEASE-NOTES | 9 | ||||
-rw-r--r-- | TODO-RELEASE | 4 | ||||
-rw-r--r-- | docs/libcurl/curl_easy_getinfo.3 | 7 | ||||
-rw-r--r-- | include/curl/curl.h | 3 | ||||
-rw-r--r-- | lib/connect.c | 2 | ||||
-rw-r--r-- | lib/getinfo.c | 6 | ||||
-rw-r--r-- | lib/urldata.h | 2 | ||||
-rw-r--r-- | src/writeout.c | 7 | ||||
-rw-r--r-- | tests/data/Makefile.am | 3 | ||||
-rw-r--r-- | tests/data/test192 | 51 | ||||
-rw-r--r-- | tests/data/test193 | 73 |
12 files changed, 164 insertions, 9 deletions
@@ -7,6 +7,12 @@ Changelog Daniel (19 October 2004) +- Guillaume Arluison added CURLINFO_NUM_CONNECTS to allow an app to figure + out how many new connects a previous transfer required. + + I added %{num_connects} to the curl tool and added test case 192 and 193 + to verify the new code. + - Test case 165 modified to use a charset define older iconv versions understand. ISO-8859-1 instead of ISO8859-1. Bug report #1049275 (anonymous) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0717531db..1d8a8a8c9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -10,18 +10,21 @@ Curl and libcurl 7.12.3 This release includes the following changes: - o + o added CURLINFO_NUM_CONNECTS This release includes the following bugfixes: - o + o test 165 works with older iconv versions as well + o use setlocale() for better IDN functionality by default Other curl-related news since the previous public release: - o + o pycurl 7.12.2: http://pycurl.sf.net/ + o TclCurl 0.12.2: http://personal1.iddeo.es/andresgarci/tclcurl/english/ This release would not have looked like this without help, code, reports and advice from friends like these: + Peter Wullinger, Guillaume Arluison Thanks! (and sorry if I forgot to mention someone) diff --git a/TODO-RELEASE b/TODO-RELEASE index 386fcde70..917427362 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -1,11 +1,9 @@ Issues not sorted in any particular order. -To get fixed in 7.12.2 (planned release: mid October 2004) -====================== - To get fixed in 7.12.3 (planned release: December 2004) ====================== 47 - Peter Sylvester's patch for SRP on the TLS layer 48 - MSVC Makefile improvements by Samuel Díaz García + diff --git a/docs/libcurl/curl_easy_getinfo.3 b/docs/libcurl/curl_easy_getinfo.3 index 4176e49ab..ce6bab9b2 100644 --- a/docs/libcurl/curl_easy_getinfo.3 +++ b/docs/libcurl/curl_easy_getinfo.3 @@ -113,6 +113,13 @@ method(s) available for your proxy authentication. (Added in 7.10.8) .IP CURLINFO_OS_ERRNO Pass a pointer to a long to receive the errno variable from a connect failure. (Added in 7.12.2) +.IP CURLINFO_NUM_CONNECTS +Pass a pointer to a long to receive how many new connections libcurl had to +create to achieve the previous transfer (only the successful connects are +counted). Combined with \fICURLINFO_REDIRECT_COUNT\fP you are able to know +how many times libcurl successfully reused existing connection(s) or not. See +the Connection Options of \fIcurl_easy_setopt(3)\fP to see how libcurl tries +to make persistent connections to save time. (Added in 7.12.3) .SH RETURN VALUE If the operation was successful, CURLE_OK is returned. Otherwise an appropriate error code will be returned. diff --git a/include/curl/curl.h b/include/curl/curl.h index 210d0631c..c631fc119 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -1179,9 +1179,10 @@ typedef enum { CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23, CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24, CURLINFO_OS_ERRNO = CURLINFO_LONG + 25, + CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26, /* Fill in new entries below here! */ - CURLINFO_LASTONE = 26 + CURLINFO_LASTONE = 27 } CURLINFO; /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as diff --git a/lib/connect.c b/lib/connect.c index 7343756b9..5d464acbd 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -784,5 +784,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ if(sockconn) *sockconn = sockfd; /* the socket descriptor we've connected */ + data->info.numconnects++; /* to track the number of connections made */ + return CURLE_OK; } diff --git a/lib/getinfo.c b/lib/getinfo.c index 88627d6e4..e554931a9 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -38,7 +38,7 @@ #include "memdebug.h" /* - * This is supposed to be called in the beginning of a permform() session + * This is supposed to be called in the beginning of a perform() session * and should reset all session-info variables */ CURLcode Curl_initinfo(struct SessionHandle *data) @@ -63,6 +63,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data) info->header_size = 0; info->request_size = 0; + info->numconnects = 0; return CURLE_OK; } @@ -170,6 +171,9 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) case CURLINFO_OS_ERRNO: *param_longp = data->state.os_errno; break; + case CURLINFO_NUM_CONNECTS: + *param_longp = data->info.numconnects; + break; default: return CURLE_BAD_FUNCTION_ARGUMENT; } diff --git a/lib/urldata.h b/lib/urldata.h index 08db4d60e..764ca3c51 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -624,6 +624,8 @@ struct PureInfo { long proxyauthavail; long httpauthavail; + long numconnects; /* how many new connection did libcurl created */ + char *contenttype; /* the content type of the object */ }; diff --git a/src/writeout.c b/src/writeout.c index 9ba9c80a8..b60319b48 100644 --- a/src/writeout.c +++ b/src/writeout.c @@ -56,6 +56,7 @@ typedef enum { VAR_REQUEST_SIZE, VAR_EFFECTIVE_URL, VAR_CONTENT_TYPE, + VAR_NUM_CONNECTS, VAR_NUM_OF_VARS /* must be the last */ } replaceid; @@ -80,6 +81,7 @@ static struct variable replacements[]={ {"speed_download", VAR_SPEED_DOWNLOAD}, {"speed_upload", VAR_SPEED_UPLOAD}, {"content_type", VAR_CONTENT_TYPE}, + {"num_connects", VAR_NUM_CONNECTS}, {NULL, VAR_NONE} }; @@ -131,6 +133,11 @@ void ourWriteOut(CURL *curl, char *writeinfo) curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &longinfo)) fprintf(stream, "%ld", longinfo); break; + case VAR_NUM_CONNECTS: + if(CURLE_OK == + curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &longinfo)) + fprintf(stream, "%ld", longinfo); + break; case VAR_TOTAL_TIME: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &doubleinfo)) diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 3a317ea59..0f63d5f6f 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -26,7 +26,8 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \ test512 test165 test166 test167 test168 test169 test170 test171 \ test172 test204 test205 test173 test174 test175 test176 test177 \ test513 test514 test178 test179 test180 test181 test182 test183 \ - test184 test185 test186 test187 test188 test189 test191 + test184 test185 test186 test187 test188 test189 test191 test192 \ + test193 # The following tests have been removed from the dist since they no longer # work. We need to fix the test suite's FTPS server first, then bring them diff --git a/tests/data/test192 b/tests/data/test192 new file mode 100644 index 000000000..0973cdb6d --- /dev/null +++ b/tests/data/test192 @@ -0,0 +1,51 @@ +# +# Server-side +<reply> +<data nocheck=1> +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Content-Length: 8 +Connection: close + +monster +</data> +</reply> + +# +# Client-side +<client> +<server> +http +</server> + <name> +HTTP GET -w num_connects with one simple connect + </name> + <command> +http://%HOSTIP:%HTTPPORT/192 -w '%{num_connects}\n' +</command> +</client> + +# +# Verify data after the test has been "shot" +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol> +GET /192 HTTP/1.1
+Host: 127.0.0.1:%HTTPPORT
+Pragma: no-cache
+Accept: */*
+
+</protocol> + +<stdout> +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Content-Length: 8 +Connection: close + +monster +1 +</stdout> +</verify> diff --git a/tests/data/test193 b/tests/data/test193 new file mode 100644 index 000000000..0d7cbc58e --- /dev/null +++ b/tests/data/test193 @@ -0,0 +1,73 @@ +# +# Server-side +<reply> +<data nocheck=1> +HTTP/1.1 302 OK swsbounce swsclose +Date: Thu, 09 Nov 2010 14:49:00 GMT +Content-Length: 8 +Connection: close +Location: ./193 + +monster +</data> +<data1 nocheck=1> +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Content-Length: 8 +Connection: close + +monster +</data1> + +</reply> + +# +# Client-side +<client> +<server> +http +</server> + <name> +HTTP GET -w num_connects with redirected fetch (2 connects) + </name> + <command> +http://%HOSTIP:%HTTPPORT/193 -w '%{num_connects}\n' -L +</command> +</client> + +# +# Verify data after the test has been "shot" +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol> +GET /193 HTTP/1.1
+Host: 127.0.0.1:%HTTPPORT
+Pragma: no-cache
+Accept: */*
+
+GET /193 HTTP/1.1
+Host: 127.0.0.1:%HTTPPORT
+Pragma: no-cache
+Accept: */*
+
+</protocol> + +<stdout> +HTTP/1.1 302 OK swsbounce swsclose +Date: Thu, 09 Nov 2010 14:49:00 GMT +Content-Length: 8 +Connection: close +Location: ./193 + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Content-Length: 8 +Connection: close + +monster +2 +</stdout> + +</verify> |