From: Daniel Stenberg Date: Tue, 10 Apr 2001 06:49:32 +0000 (+0000) Subject: Added new CURLOPT_HEADERFUNCTION callback for writing headers only X-Git-Tag: upstream/7.37.1~16847 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=025fa762f644c9c1438c6669c4fe3e1800a112b5;p=platform%2Fupstream%2Fcurl.git Added new CURLOPT_HEADERFUNCTION callback for writing headers only --- diff --git a/include/curl/curl.h b/include/curl/curl.h index 0a612c0..5dbd7b4 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -430,6 +430,10 @@ typedef enum { phase. [Only works on unix-style/SIGALRM operating systems] */ CINIT(CONNECTTIMEOUT, LONG, 78), + /* Function that will be called to store headers (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79), + CURLOPT_LASTENTRY /* the last unusued */ } CURLoption; diff --git a/lib/sendf.c b/lib/sendf.c index 868aa88..25ccb92 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -236,7 +236,14 @@ CURLcode Curl_client_write(struct UrlData *data, } } if((type & CLIENTWRITE_HEADER) && data->writeheader) { - wrote = data->fwrite(ptr, 1, len, data->writeheader); + /* + * Write headers to the same callback or to the especially setup + * header callback function (added after version 7.7.1). + */ + curl_write_callback writeit= + data->fwrite_header?data->fwrite_header:data->fwrite; + + wrote = writeit(ptr, 1, len, data->writeheader); if(wrote != len) { failf (data, "Failed writing header"); return CURLE_WRITE_ERROR; diff --git a/lib/urldata.h b/lib/urldata.h index aef8435..5c01994 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -485,6 +485,9 @@ struct UrlData { /* function that stores the output:*/ curl_write_callback fwrite; + /* optional function that stores the header output:*/ + curl_write_callback fwrite_header; + /* function that reads the input:*/ curl_read_callback fread;