curl_easy_setopt(3) libcurl Manual curl_easy_setopt(3)
CURLOPT_OPENSOCKETFUNCTION
Function pointer that should match the curl_opensocket_callback prototype found in
<curl/curl.h>.This function gets called by libcurl instead of the socket(2) call. The callback’s pur-
pose argument identifies the exact purpose for this particular socket, and currently only one value
is supported: CURLSOCKTYPE_IPCXN for the primary connection (meaning the control connec-
tion in the FTP case). Future versions of libcurl may support more purposes. It passes the resolved
peer address as a address argument so the callback can modify the address or refuse to connect at
all. The callback function should return the socket or CURL_SOCKET_BAD in case no connection
should be established or anyerror detected. Anyadditional setsockopt(2) calls can be done on the
socket at the user’sdiscretion. CURL_SOCKET_BAD return value from the callback function will
signal an unrecoverable error to the library and it will return CURLE_COULDNT_CONNECT.
This return code can be used for IP address blacklisting. The default behavior is:
return socket(addr->family,addr->socktype, addr->protocol); (Option added in 7.17.1.)
CURLOPT_OPENSOCKETDAT A
Pass a pointer that will be untouched by libcurl and passed as the first argument in the opensocket
callback set with CURLOPT_OPENSOCKETFUNCTION.(Option added in 7.17.1.)
CURLOPT_PROGRESSFUNCTION
Function pointer that should match the curl_progress_callback prototype found in <curl/curl.h>.
This function gets called by libcurl instead of its internal equivalent with a frequent interval during
operation (roughly once per second) no matter if data is being transfered or not. Unknown/unused
argument values passed to the callback will be set to zero (likeifyou only download data, the
upload size will remain 0). Returning a non-zero value from this callback will cause libcurl to
abort the transfer and return CURLE_ABORTED_BY_CALLBACK.
If you transfer data with the multi interface, this function will not be called during periods of idle-
ness unless you call the appropriate libcurl function that performs transfers.
CURLOPT_NOPROGRESS must be set to 0 to makethis function actually get called.
CURLOPT_PROGRESSDAT A
Pass a pointer that will be untouched by libcurl and passed as the first argument in the progress
callback set with CURLOPT_PROGRESSFUNCTION.
CURLOPT_HEADERFUNCTION
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 receivedheader
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.Donot assume that the header line is zero termi-
nated! 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 (CUR-
LOPT_WRITEHEADER)isset 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.
Since 7.14.1: When a server sends a chunked encoded transfer,itmay contain a trailer.That trailer
is identical to a HTTP header and if such a trailer is receiveditispassed to the application using
this callback as well. There are several ways to detect it being a trailer and not an ordinary header:
1) it comes after the response-body.2)itcomes after the final header line (CR LF) 3) a Trailer:
header among the response-headers mention what header to expect in the trailer.
libcurl 7.19.3 11 Dec 2008 4
- 1
- 2
- 3
- 4
- 5
- 6
前往页