|
|
cURL Mailing List Monthly Index Single Mail
curl-library Archives
RE: response to quoted pwd command in libcurl
From: Xu, Qiang (FXSGSC) <Qiang.Xu_at_fujixerox.com>
Date: Wed, 11 Nov 2009 19:02:20 +0800
> -----Original Message-----
From http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEHEADER and http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHEADERFUNCTION, it is clear that to get the feedback to the quoted cmd like "pwd", at least CURLOPT_WRITEHEADER must be pointed to a File pointer:
(This option is also known as CURLOPT_HEADERDATA) Pass a pointer to be used to write the header part of the received data to. If you don't use your own callback to take care of the writing, this must be a valid FILE *. See also the CURLOPT_HEADERFUNCTION option above on how to set a custom get-all-headers callback.
/* from http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHEADERFUNCTION */
Function pointer that should match the following prototype: size_t function( void *ptr, size_t size, size_t nmemb, void *stream);. This function gets called by libcurl as soon as it has received header data. The header callback will be called once for each header and only complete header lines are passed on to the callback. Parsing headers should be easy enough using this. The size of the data pointed to by ptr is size multiplied with nmemb. Do not assume that the header line is zero terminated! The pointer named stream is the one you set with the CURLOPT_WRITEHEADER option. The callback function must return the number of bytes actually taken care of, or return -1 to signal error to the library (it will cause it to abort the transfer with a CURLE_WRITE_ERROR return code).
If this option is not set, or if it is set to NULL, but CURLOPT_HEADERDATA (CURLOPT_WRITEHEADER) is set to anything but NULL, the function used to accept response data will be used instead. That is, it will be the function specified with CURLOPT_WRITEFUNCTION, or if it is not specified or NULL - the default, stream-writing function.
It's important to note that the callback will be invoked for the headers of all responses received after initiating a request and not just the final response. This includes all responses which occur during authentication negotiation. If you need to operate on only the headers from the final response, you will need to collect headers in the callback yourself and use HTTP status lines, for example, to delimit response boundaries.
The code is changed as follows:
Thanks,
These mail archives are generated by hypermail. |
Page updated November 16, 2009.
web site info