1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

CURLINFO_NUM_CONNECTS and more

This commit is contained in:
Daniel Stenberg 2004-10-19 15:30:08 +00:00
parent ebf7d22503
commit f4bef25b5e
12 changed files with 164 additions and 9 deletions

View File

@ -7,6 +7,12 @@
Changelog Changelog
Daniel (19 October 2004) 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 - Test case 165 modified to use a charset define older iconv versions
understand. ISO-8859-1 instead of ISO8859-1. Bug report #1049275 (anonymous) understand. ISO-8859-1 instead of ISO8859-1. Bug report #1049275 (anonymous)

View File

@ -10,18 +10,21 @@ Curl and libcurl 7.12.3
This release includes the following changes: This release includes the following changes:
o o added CURLINFO_NUM_CONNECTS
This release includes the following bugfixes: 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: 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 This release would not have looked like this without help, code, reports and
advice from friends like these: advice from friends like these:
Peter Wullinger, Guillaume Arluison
Thanks! (and sorry if I forgot to mention someone) Thanks! (and sorry if I forgot to mention someone)

View File

@ -1,11 +1,9 @@
Issues not sorted in any particular order. 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) To get fixed in 7.12.3 (planned release: December 2004)
====================== ======================
47 - Peter Sylvester's patch for SRP on the TLS layer 47 - Peter Sylvester's patch for SRP on the TLS layer
48 - MSVC Makefile improvements by Samuel Díaz García 48 - MSVC Makefile improvements by Samuel Díaz García

View File

@ -113,6 +113,13 @@ method(s) available for your proxy authentication. (Added in 7.10.8)
.IP CURLINFO_OS_ERRNO .IP CURLINFO_OS_ERRNO
Pass a pointer to a long to receive the errno variable from a connect failure. Pass a pointer to a long to receive the errno variable from a connect failure.
(Added in 7.12.2) (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 .SH RETURN VALUE
If the operation was successful, CURLE_OK is returned. Otherwise an If the operation was successful, CURLE_OK is returned. Otherwise an
appropriate error code will be returned. appropriate error code will be returned.

View File

@ -1179,9 +1179,10 @@ typedef enum {
CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23, CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23,
CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24, CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24,
CURLINFO_OS_ERRNO = CURLINFO_LONG + 25, CURLINFO_OS_ERRNO = CURLINFO_LONG + 25,
CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26,
/* Fill in new entries below here! */ /* Fill in new entries below here! */
CURLINFO_LASTONE = 26 CURLINFO_LASTONE = 27
} CURLINFO; } CURLINFO;
/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as

View File

@ -784,5 +784,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
if(sockconn) if(sockconn)
*sockconn = sockfd; /* the socket descriptor we've connected */ *sockconn = sockfd; /* the socket descriptor we've connected */
data->info.numconnects++; /* to track the number of connections made */
return CURLE_OK; return CURLE_OK;
} }

View File

@ -38,7 +38,7 @@
#include "memdebug.h" #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 * and should reset all session-info variables
*/ */
CURLcode Curl_initinfo(struct SessionHandle *data) CURLcode Curl_initinfo(struct SessionHandle *data)
@ -63,6 +63,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data)
info->header_size = 0; info->header_size = 0;
info->request_size = 0; info->request_size = 0;
info->numconnects = 0;
return CURLE_OK; return CURLE_OK;
} }
@ -170,6 +171,9 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
case CURLINFO_OS_ERRNO: case CURLINFO_OS_ERRNO:
*param_longp = data->state.os_errno; *param_longp = data->state.os_errno;
break; break;
case CURLINFO_NUM_CONNECTS:
*param_longp = data->info.numconnects;
break;
default: default:
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_BAD_FUNCTION_ARGUMENT;
} }

View File

@ -624,6 +624,8 @@ struct PureInfo {
long proxyauthavail; long proxyauthavail;
long httpauthavail; long httpauthavail;
long numconnects; /* how many new connection did libcurl created */
char *contenttype; /* the content type of the object */ char *contenttype; /* the content type of the object */
}; };

View File

@ -56,6 +56,7 @@ typedef enum {
VAR_REQUEST_SIZE, VAR_REQUEST_SIZE,
VAR_EFFECTIVE_URL, VAR_EFFECTIVE_URL,
VAR_CONTENT_TYPE, VAR_CONTENT_TYPE,
VAR_NUM_CONNECTS,
VAR_NUM_OF_VARS /* must be the last */ VAR_NUM_OF_VARS /* must be the last */
} replaceid; } replaceid;
@ -80,6 +81,7 @@ static struct variable replacements[]={
{"speed_download", VAR_SPEED_DOWNLOAD}, {"speed_download", VAR_SPEED_DOWNLOAD},
{"speed_upload", VAR_SPEED_UPLOAD}, {"speed_upload", VAR_SPEED_UPLOAD},
{"content_type", VAR_CONTENT_TYPE}, {"content_type", VAR_CONTENT_TYPE},
{"num_connects", VAR_NUM_CONNECTS},
{NULL, VAR_NONE} {NULL, VAR_NONE}
}; };
@ -131,6 +133,11 @@ void ourWriteOut(CURL *curl, char *writeinfo)
curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &longinfo)) curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &longinfo))
fprintf(stream, "%ld", longinfo); fprintf(stream, "%ld", longinfo);
break; 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: case VAR_TOTAL_TIME:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &doubleinfo)) curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &doubleinfo))

View File

@ -26,7 +26,8 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
test512 test165 test166 test167 test168 test169 test170 test171 \ test512 test165 test166 test167 test168 test169 test170 test171 \
test172 test204 test205 test173 test174 test175 test176 test177 \ test172 test204 test205 test173 test174 test175 test176 test177 \
test513 test514 test178 test179 test180 test181 test182 test183 \ 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 # 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 # work. We need to fix the test suite's FTPS server first, then bring them

51
tests/data/test192 Normal file
View File

@ -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>

73
tests/data/test193 Normal file
View File

@ -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>