curl-library
header bytes not being reset on each perform
Date: Tue, 23 Jan 2001 17:07:19 -0800
the attached test program seems to imply that the header bytes from
curl_easy_getinfo() are not being reset on each request:
# ./curl_test2
total time 0.00914, bytes 1048766 connect 0.008059
header bytes 190 download size 1048576.000000 request_bytes 129
total time 0.00914, bytes 2097532 connect 0.013123
header bytes 380 download size 1048576.000000 request_bytes 129
total time 0.00914, bytes 3146298 connect 0.018558
header bytes 570 download size 1048576.000000 request_bytes 129
the revision of curl is:
$ swlist | grep -i curl
TWWcurl75 T.7.5.1.1 cURL URL grabber
running on an HP-UX 11.0 system.
is this a known problem, or is it supposed to behave that way? (seems
inconsistent with the request bytes and the download bytes
rick jones
-- ftp://ftp.cup.hp.com/dist/networking/misc/rachel/ these opinions are mine, all mine; HP might not want them anyway... :) feel free to email, OR post, but please do NOT do BOTH... my email address is raj in the cup.hp.com domain...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
unsigned long total_bytes = 0;
double total_time = 0.0;
double connect_time = 0.0;
double download_size = 0.0;
unsigned long header_bytes = 0L;
unsigned long request_size = 0L;
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
{
/* printf("pretended to write %d bytes\n",size*nmemb); */
total_bytes += (size * nmemb);
return size*nmemb;
}
int main(int argc, char **argv)
{
CURL *curl_handle;
char *headerfilename = "head.out";
FILE *headerfile;
char *bodyfilename = "body.out";
FILE *bodyfile;
/* init the curl session */
curl_handle = curl_easy_init();
/* set URL to get */
curl_easy_setopt(curl_handle, CURLOPT_URL, "http://tardy.cup.hp.com/foo");
/* no progress meter please */
curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1);
/* shut up completely */
curl_easy_setopt(curl_handle, CURLOPT_MUTE, 1);
/* send all data to this function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
/* open the files */
headerfile = fopen(headerfilename,"w");
if (headerfile == NULL) {
curl_easy_cleanup(curl_handle);
return -1;
}
bodyfile = fopen(bodyfilename,"w");
if (bodyfile == NULL) {
curl_easy_cleanup(curl_handle);
return -1;
}
/* we want the headers to this file handle */
curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, headerfile);
/* pass the actually download file to this file handle */
curl_easy_setopt(curl_handle, CURLOPT_FILE, bodyfile);
/* get it! */
curl_easy_perform(curl_handle);
/* retrieve some stats */
curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME, &total_time);
curl_easy_getinfo(curl_handle, CURLINFO_CONNECT_TIME, &connect_time);
curl_easy_getinfo(curl_handle, CURLINFO_HEADER_SIZE, &header_bytes);
curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD, &download_size);
printf("total time %g, bytes %d connect %g\n",
total_time, total_bytes, connect_time);
curl_easy_getinfo(curl_handle, CURLINFO_REQUEST_SIZE, &request_size);
printf("header bytes %d download size %f request_bytes %d\n",
header_bytes,download_size,request_size);
/* get it! */
curl_easy_perform(curl_handle);
/* retrieve some stats */
curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME, &total_time);
curl_easy_getinfo(curl_handle, CURLINFO_CONNECT_TIME, &connect_time);
curl_easy_getinfo(curl_handle, CURLINFO_HEADER_SIZE, &header_bytes);
curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD, &download_size);
printf("total time %g, bytes %d connect %g\n",
total_time, total_bytes, connect_time);
curl_easy_getinfo(curl_handle, CURLINFO_REQUEST_SIZE, &request_size);
printf("header bytes %d download size %f request_bytes %d\n",
header_bytes,download_size,request_size);
/* get it! */
curl_easy_perform(curl_handle);
/* retrieve some stats */
curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME, &total_time);
curl_easy_getinfo(curl_handle, CURLINFO_CONNECT_TIME, &connect_time);
curl_easy_getinfo(curl_handle, CURLINFO_HEADER_SIZE, &header_bytes);
curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD, &download_size);
printf("total time %g, bytes %d connect %g\n",
total_time, total_bytes, connect_time);
curl_easy_getinfo(curl_handle, CURLINFO_REQUEST_SIZE, &request_size);
printf("header bytes %d download size %f request_bytes %d\n",
header_bytes,download_size,request_size);
/* close the header file */
fclose(headerfile);
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);
return 0;
}
_______________________________________________
Curl-library mailing list
Curl-library_at_lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/curl-library
Received on 2001-01-24