全部博文(930)
分类: LINUX
2010-05-03 22:33:12
CURLOPT_WRITEFUNCTION
函数指针: size_t function( void *ptr, size_t size, size_t nmemb, void *stream);
作用: 当libcurl接收到要保存的数据时调用此函数, ptr所指数据大小为 size*nmemb. 返回实际处理的数据大小,如果返回值不等于传递给函数的数据大小,则报错,并返回CURLE_WIRTE_ERROR
注: 如果此参数置为NULL, 则会调用默认的函数,将数据写入到FILE*(由CURLOPT_WRITEDATA 给出)
此回调函数会尽量处理更多数据,但是传递给回调函数的数据最大值定义在curl.h文件中.
CURL_MAX_WRITE_SIZE = 16k
CURLOPT_WRITEDATA
数据指针:传递给写函数,
作用:如果使用了 CURLOPT_WRITEFUNCTION 参数, 可以使用这个指针作为输入,如果没有使用CURLOPT_WRITEFUNCTION, 则必需给出一个FILE*类型, libcurl会将其传递给fwrite()
CURLOPT_READFUNCTION
函数指针: size_t function( void *ptr, size_t size, size_t nmemb, void *stream);
作用:当libcurl需要读取数据并发送出去时调用此函数, ptr所指数据大小
注:如果此参数为NULL, 或者不设置, 将调用默认的函数,fread()读FILE* (由CURLOPT_READDATA 设置)
CURLOPT_READDATA
...
CURLOPT_IOCTLFUNCTION
处理特殊I/O事件: 仅用在 rewinding the read data stream 回环数据(用于处理HTTP put post 多次传输认证 multi-psss authentication 方法)
CURLOPT_IOCTLDATA
...
CURLOPT_SOCKOPTFUNCTION
由libcurl调用: 在socket()后, connect()前
设置 CURLSOCKTYPE_IPCXN (meaning the control connection in the FTP case)
CURLOPT_SOCKOPTDATA
...
CURLOPT_PROGRESSFUNCTION CURLOPT_PROGRESSDATA
CURLOPT_HEADERFUNCTION
函数指针: size_t function( void *ptr, size_t size, size_t nmemb, void *stream);
作用 :当libcurl收到header 数据, 会调用此函数处理. 当全部header的lines传递给回调函数后,此函数调用一次(为每个header), 可以使用此函数解析header
命名为stream的参数是你调用CURLOPT_WRITEHEADER设置的
int curl_debug_callback (CURL *, curl_infotype, char *, size_t, void *)
CURLOPT_DEBUGDATA
CURLOPT_SSL_CTX_FUNCTION
CURLcode sslctxfun(CURL *curl, void *sslctx, void *parm)
libcurl调用此函数在初始化一个SSL连接之前设置了全部的SSL连接参数之后, 是应用程序修改SSL连接设置的最后机会
CURLOPT_SSL_CTX_DATA
CURLOPT_CONV_TO_NETWORK_FUNCTION
CURLOPT_CONV_FROM_NETWORK_FUNCTION
CURLOPT_CONV_FROM_UTF8_FUNCTION
CURLOPT_URL
CURLOPT_INTERFACE
Pass a char * as parameter. This set the interface name to use as outgoing network interface. The name can be an interface name, an IP address or a host name.
CURLOPT_BUFFERSIZE
Pass a long specifying your preferred size (in bytes) for the receive buffer in libcurl. The main point of this would be that the write callback gets called more often and with smaller chunks. This is just treated as a request, not an order. You cannot be guaranteed to actually get the given size. (Added in 7.10)
This size is by default set as big as possible (CURL_MAX_WRITE_SIZE), so it only makes sense to use this option if you want it smaller.
CURLOPT_PORT
Pass a long specifying what remote port number to connect to, instead of the one specified in the URL or the default port for the used protocol.
CURLOPT_ENCODING
Three encodings are supported: identity gzip a zero-length string
This is a request, not an order
CURLOPT_PUT
A non-zero parameter tells the library to use HTTP PUT to transfer data. The data should be set with CURLOPT_READDATA and CURLOPT_INFILESIZE.
This option is deprecated and starting with version 7.12.1 you should instead use CURLOPT_UPLOAD.
CURLOPT_POST
非零:告知libcurl执行一个常规的HTTP POST, libcurl会使用"Content-Type: application/x-www-form-urlencoded"header
使用: CURLOPT_READFUNCTION and CURLOPT_READDATA 参数 (请确保不要设置 CURLOPT_POSTFIELDS, 或者置其为NULL)
When providing data with a callback, you must transmit it using chunked transfer-encoding or you must set the size of the data with the CURLOPT_POSTFIELDSIZE option.
可以重写默认的POST 内容类型使用 CURLOPT_HTTPHEADER.
当设置 CURLOPT_POST 非零时, 会自动CURLOPT_NOBODY to 0
如果声明了一个POST 请求后, 想要使用同一个handle 来 GET 或者 HEAD, 必需设置新的请求类型使用 CURLOPT_NOBODY or CURLOPT_HTTPGET or similar.
必需确保数据格式服务器可以 解析, libcurl不会转化或者encode. 但是大部分夫服务器假定这些数据是 url-encoded .
当此选项使用后 POST 是一个 application/x-www-form-urlencoded 类型
如果想要发送一个 zero-byte POST 需要设置CURLOPT_POSTFIELDSIZE 为0
CURLOPT_POSTFIELDS to NULL or "" 仅仅设置不发送指定数据, libcurl会认为使用回调函数发送数据
Pass a pointer to a linked list of HTTP headers to pass to the server in your HTTP request. The linked list should be a fully valid list of struct curl_slist structs properly filled in. Use curl_slist_append(3) to create the list and curl_slist_free_all(3) to clean up an entire list. If you add a header that is otherwise generated and used by libcurl internally, your added one will be used instead. If you add a header with no contents as in 'Accept:' (no data on the right side of the colon), the internally used header will get disabled. Thus, using this option you can add new headers, replace internal headers and remove internal headers. To add a header with no contents, make the contents be two quotes: "". The headers included in the linked list must not be CRLF-terminated, because curl adds CRLF after each header item. Failure to comply with this will result in strange bugs because the server will most likely ignore part of the headers you specified.
The first line in a request (containing the method, usually a GET or POST) is not a header and cannot be replaced using this option. Only the lines following the request-line are headers. Adding this method line in this list of headers will only cause your request to send an invalid header.
Pass a NULL to this to reset back to no custom headers.
The most commonly replaced headers have "shortcuts" in the options CURLOPT_COOKIE, CURLOPT_USERAGENT and CURLOPT_REFERER.
CURLOPT_HTTP_VERSION
force libcurl 使用 特定的 HTTP_VERSION
CURL_HTTP_VERSION_NONE
We don't care about what version the library uses. libcurl will use whatever it thinks fit.
CURL_HTTP_VERSION_1_0
Enforce HTTP 1.0 requests.
CURL_HTTP_VERSION_1_1
Enforce HTTP 1.1 requests.
CURLOPT_HTTP_CONTENT_DECODING
Pass a long to tell libcurl how to act on content decoding. If set to zero, content decoding will be disabled. If set to 1 it is enabled. Note however that libcurl has no default content decoding but requires you to use CURLOPT_ENCODING for that. (added in 7.16.2)
CURLOPT_HTTP_TRANSFER_DECODING
Pass a long to tell libcurl how to act on transfer decoding. If set to zero, transfer decoding will be disabled, if set to 1 it is enabled (default). libcurl does chunked transfer decoding by default unless this option is set to zero. (added in 7.16.2)
CURLOPT_TIMEOUT
Example:
#includechinaunix网友2010-05-31 22:35:11
MBT is based on Africa's indigenous people to create innovative walking barefoot, and wear this shoe can stimulate the body to relax the muscles so that the muscles of heat to be released, consumed calories, thus to achieve weight loss results. MBT's pursuit of beauty in order to satisfy customers, design a variety of styles, such as Mbt Chapa shoe, MBT Lami Shoe