From 5865860ad6b9f02dba6ed389d554458930d47d07 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 4 Oct 2000 13:07:43 +0000 Subject: [PATCH] counts header and request size --- lib/getinfo.c | 6 ++++++ lib/highlevel.c | 2 ++ lib/http.c | 11 ++++++++--- lib/urldata.h | 8 +++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/getinfo.c b/lib/getinfo.c index a356741b0..177af976e 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -84,6 +84,12 @@ CURLcode curl_getinfo(CURL *curl, CURLINFO info, ...) case CURLINFO_HTTP_CODE: *param_longp = data->progress.httpcode; break; + case CURLINFO_HEADER_SIZE: + *param_longp = data->header_size; + break; + case CURLINFO_REQUEST_SIZE: + *param_longp = data->request_size; + break; case CURLINFO_TOTAL_TIME: *param_doublep = data->progress.timespent; break; diff --git a/lib/highlevel.c b/lib/highlevel.c index c3b6269e1..9c1a36c4f 100644 --- a/lib/highlevel.c +++ b/lib/highlevel.c @@ -349,6 +349,7 @@ _Transfer(struct connectdata *c_conn) return CURLE_WRITE_ERROR; } } + data->header_size += p - data->headerbuff; break; /* exit header line loop */ } @@ -425,6 +426,7 @@ _Transfer(struct connectdata *c_conn) return CURLE_WRITE_ERROR; } } + data->header_size += hbuflen; /* reset hbufp pointer && hbuflen */ hbufp = data->headerbuff; diff --git a/lib/http.c b/lib/http.c index 7e2089496..4b9da418b 100644 --- a/lib/http.c +++ b/lib/http.c @@ -475,7 +475,8 @@ CURLcode http(struct connectdata *conn) /* set upload size to the progress meter */ pgrsSetUploadSize(data, http->postsize); - add_buffer_send(data->firstsocket, conn, req_buffer); + data->request_size = + add_buffer_send(data->firstsocket, conn, req_buffer); result = Transfer(conn, data->firstsocket, -1, TRUE, &http->readbytecount, data->firstsocket, @@ -500,7 +501,8 @@ CURLcode http(struct connectdata *conn) pgrsSetUploadSize(data, data->infilesize); /* this sends the buffer and frees all the buffer resources */ - add_buffer_send(data->firstsocket, conn, req_buffer); + data->request_size = + add_buffer_send(data->firstsocket, conn, req_buffer); /* prepare for transfer */ result = Transfer(conn, data->firstsocket, -1, TRUE, @@ -544,8 +546,11 @@ CURLcode http(struct connectdata *conn) else add_buffer(req_buffer, "\r\n", 2); + /* issue the request */ + data->request_size = + add_buffer_send(data->firstsocket, conn, req_buffer); + /* HTTP GET/HEAD download: */ - add_buffer_send(data->firstsocket, conn, req_buffer); result = Transfer(conn, data->firstsocket, -1, TRUE, bytecount, -1, NULL); /* nothing to upload */ } diff --git a/lib/urldata.h b/lib/urldata.h index f255fbff3..241bfc268 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -211,7 +211,6 @@ struct connectdata { the same we read from. -1 disables */ long *writebytecountp; /* return number of bytes written or NULL */ - #ifdef KRB4 enum protection_level command_prot; @@ -357,6 +356,10 @@ struct UrlData { proxy string features a ":[port]" that one will override this. */ + + long header_size; /* size of read header(s) in bytes */ + long request_size; /* the amount of bytes sent in the request(s) */ + /*************** Request - specific items ************/ union { @@ -463,8 +466,11 @@ struct UrlData { char *headerbuff; /* allocated buffer to store headers in */ int headersize; /* size of the allocation */ +#if 0 + /* this was removed in libcurl 7.4 */ char *writeinfo; /* if non-NULL describes what to output on a successful completion */ +#endif struct Progress progress;