📄 curl_easy_setopt.3
字号:
expect in the trailer..IP CURLOPT_WRITEHEADER(This option is also known as \fBCURLOPT_HEADERDATA\fP) Pass a pointer to beused to write the header part of the received data to. If you don't use yourown callback to take care of the writing, this must be a valid FILE *. Seealso the \fICURLOPT_HEADERFUNCTION\fP option above on how to set a customget-all-headers callback..IP CURLOPT_DEBUGFUNCTIONFunction pointer that should match the following prototype: \fIintcurl_debug_callback (CURL *, curl_infotype, char *, size_t, void *);\fP\fICURLOPT_DEBUGFUNCTION\fP replaces the standard debug function used when\fICURLOPT_VERBOSE \fP is in effect. This callback receives debug information,as specified with the \fBcurl_infotype\fP argument. This function must return0. The data pointed to by the char * passed to this function WILL NOT be zeroterminated, but will be exactly of the size as told by the size_t argument.Available curl_infotype values:.RS.IP CURLINFO_TEXTThe data is informational text..IP CURLINFO_HEADER_INThe data is header (or header-like) data received from the peer..IP CURLINFO_HEADER_OUTThe data is header (or header-like) data sent to the peer..IP CURLINFO_DATA_INThe data is protocol data received from the peer..IP CURLINFO_DATA_OUTThe data is protocol data sent to the peer..RE.IP CURLOPT_DEBUGDATAPass a pointer to whatever you want passed in to your\fICURLOPT_DEBUGFUNCTION\fP in the last void * argument. This pointer is notused by libcurl, it is only passed to the callback..IP CURLOPT_SSL_CTX_FUNCTIONFunction pointer that should match the following prototype: \fBCURLcodesslctxfun(CURL *curl, void *sslctx, void *parm);\fP This function gets calledby libcurl just before the initialization of an SSL connection after havingprocessed all other SSL related options to give a last chance to anapplication to modify the behaviour of openssl's ssl initialization. The\fIsslctx\fP parameter is actually a pointer to an openssl \fISSL_CTX\fP. Ifan error is returned no attempt to establish a connection is made and theperform operation will return the error code from this callback function. Setthe \fIparm\fP argument with the \fICURLOPT_SSL_CTX_DATA\fP option. Thisoption was introduced in 7.11.0.This function will get called on all new connections made to a server, duringthe SSL negotiation. The SSL_CTX pointer will be a new one every time.To use this properly, a non-trivial amount of knowledge of the openssllibraries is necessary. Using this function allows for example to use opensslcallbacks to add additional validation code for certificates, and even tochange the actual URI of an HTTPS request (example used in the lib509 testcase). See also the example section for a replacement of the key, certificateand trust file settings..IP CURLOPT_SSL_CTX_DATAData pointer to pass to the ssl context callback set by the option\fICURLOPT_SSL_CTX_FUNCTION\fP, this is the pointer you'll get as thirdparameter, otherwise \fBNULL\fP. (Added in 7.11.0).IP CURLOPT_CONV_TO_NETWORK_FUNCTION.IP CURLOPT_CONV_FROM_NETWORK_FUNCTION.IP CURLOPT_CONV_FROM_UTF8_FUNCTIONFunction pointers that should match the following prototype: CURLcodefunction(char *ptr, size_t length);These three options apply to non-ASCII platforms only. They are availableonly if \fBCURL_DOES_CONVERSIONS\fP was defined when libcurl was built. Whenthis is the case, \fIcurl_version_info(3)\fP will return the CURL_VERSION_CONVfeature bit set.The data to be converted is in a buffer pointed to by the ptr parameter. Theamount of data to convert is indicated by the length parameter. The converteddata overlays the input data in the buffer pointed to by the ptr parameter.CURLE_OK should be returned upon successful conversion. A CURLcode returnvalue defined by curl.h, such as CURLE_CONV_FAILED, should be returned if anerror was encountered.\fBCURLOPT_CONV_TO_NETWORK_FUNCTION\fP and\fBCURLOPT_CONV_FROM_NETWORK_FUNCTION\fP convert between the host encoding andthe network encoding. They are used when commands or ASCII data aresent/received over the network.\fBCURLOPT_CONV_FROM_UTF8_FUNCTION\fP is called to convert from UTF8 into thehost encoding. It is required only for SSL processing.If you set a callback pointer to NULL, or don't set it at all, the built-inlibcurl iconv functions will be used. If HAVE_ICONV was not defined whenlibcurl was built, and no callback has been established, conversion willreturn the CURLE_CONV_REQD error code.If HAVE_ICONV is defined, CURL_ICONV_CODESET_OF_HOST must also be defined.For example: \&#define CURL_ICONV_CODESET_OF_HOST "IBM-1047"The iconv code in libcurl will default the network and UTF8 codeset names asfollows: \&#define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1" \&#define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8"You will need to override these definitions if they are different on yoursystem..SH ERROR OPTIONS.IP CURLOPT_ERRORBUFFERPass a char * to a buffer that the libcurl may store human readable errormessages in. This may be more helpful than just the return code from\fIcurl_easy_perform\fP. The buffer must be at least CURL_ERROR_SIZE big.Although this argument is a 'char *', it does not describe an input string.Therefore the (probably undefined) contents of the buffer is NOT copiedby the library. You should keep the associated storage available untillibcurl no longer needs it. Failing to do so will cause very odd behavioror even crashes. libcurl will need it until you call \fIcurl_easy_cleanup(3)\fPor you set the same option again to use a different pointer. Use \fICURLOPT_VERBOSE\fP and \fICURLOPT_DEBUGFUNCTION\fP to betterdebug/trace why errors happen.If the library does not return an error, the buffer may not have beentouched. Do not rely on the contents in those cases..IP CURLOPT_STDERRPass a FILE * as parameter. Tell libcurl to use this stream instead of stderrwhen showing the progress meter and displaying \fICURLOPT_VERBOSE\fP data..IP CURLOPT_FAILONERRORA non-zero parameter tells the library to fail silently if the HTTP codereturned is equal to or larger than 400. The default action would be to returnthe page normally, ignoring that code.This method is not fail-safe and there are occasions where non-successfulresponse codes will slip through, especially when authentication is involved(response codes 401 and 407).You might get some amounts of headers transferred before this situation isdetected, like for when a "100-continue" is received as a response to aPOST/PUT and a 401 or 407 is received immediately afterwards..SH NETWORK OPTIONS.IP CURLOPT_URLThe actual URL to deal with. The parameter should be a char * to a zeroterminated string.If the given URL lacks the protocol part ("http://" or "ftp://" etc), it willattempt to guess which protocol to use based on the given host name. If thegiven protocol of the set URL is not supported, libcurl will return on error(\fICURLE_UNSUPPORTED_PROTOCOL\fP) when you call \fIcurl_easy_perform(3)\fP or\fIcurl_multi_perform(3)\fP. Use \fIcurl_version_info(3)\fP for detailed infoon which protocols that are supported.The string given to CURLOPT_URL must be url-encoded and following the RFC 2396(http://curl.haxx.se/rfc/rfc2396.txt).\fICURLOPT_URL\fP is the only option that \fBmust\fP be set before\fIcurl_easy_perform(3)\fP is called..IP CURLOPT_PROXYSet HTTP proxy to use. The parameter should be a char * to a zero terminatedstring holding the host name or dotted IP address. To specify port number inthis string, append :[port] to the end of the host name. The proxy string maybe prefixed with [protocol]:// since any such prefix will be ignored. Theproxy's port number may optionally be specified with the separate option\fICURLOPT_PROXYPORT\fP.When you tell the library to use an HTTP proxy, libcurl will transparentlyconvert operations to HTTP even if you specify an FTP URL etc. This may havean impact on what other features of the library you can use, such as\fICURLOPT_QUOTE\fP and similar FTP specifics that don't work unless youtunnel through the HTTP proxy. Such tunneling is activated with\fICURLOPT_HTTPPROXYTUNNEL\fP.libcurl respects the environment variables \fBhttp_proxy\fP, \fBftp_proxy\fP,\fBall_proxy\fP etc, if any of those is set. The \fICURLOPT_PROXY\fP optiondoes however override any possibly set environment variables.Setting the proxy string to "" (an empty string) will explicitly disable theuse of a proxy, even if there is an environment variable set for it.Since 7.14.1, the proxy host string given in environment variables can bespecified the exact same way as the proxy can be set with \fICURLOPT_PROXY\fP,include protocol prefix (http://) and embedded user + password..IP CURLOPT_PROXYPORTPass a long with this option to set the proxy port to connect to unless it isspecified in the proxy string \fICURLOPT_PROXY\fP..IP CURLOPT_PROXYTYPEPass a long with this option to set type of the proxy. Available options forthis are \fICURLPROXY_HTTP\fP, \fICURLPROXY_SOCKS4\fP (added in 7.15.2)\fICURLPROXY_SOCKS5\fP. The HTTP type is default. (Added in 7.10).IP CURLOPT_HTTPPROXYTUNNELSet the parameter to non-zero to get the library to tunnel all operationsthrough a given HTTP proxy. There is a big difference between using a proxyand to tunnel through it. If you don't know what this means, you probablydon't want this tunneling option..IP CURLOPT_INTERFACEPass a char * as parameter. This set the interface name to use as outgoingnetwork interface. The name can be an interface name, an IP address or a hostname..IP CURLOPT_LOCALPORTPass a long. This sets the local port number of the socket used forconnection. This can be used in combination with \fICURLOPT_INTERFACE\fP andyou are recommended to use \fICURLOPT_LOCALPORTRANGE\fP as well when this isset. Note that port numbers are only valid 1 - 65535. (Added in 7.15.2).IP CURLOPT_LOCALPORTRANGEPass a long. This is the number of attempts libcurl should do to find aworking local port number. It starts with the given \fICURLOPT_LOCALPORT\fPand adds one to the number for each retry. Setting this value to 1 or belowwill make libcurl do only one try for exact port number. Note that portnumbers by nature is a scarce resource that will be busy at times so settingthis value to something too low might cause unnecessary connection setupfailures. (Added in 7.15.2).IP CURLOPT_DNS_CACHE_TIMEOUTPass a long, this sets the timeout in seconds. Name resolves will be kept inmemory for this number of seconds. Set to zero (0) to completely disablecaching, or set to -1 to make the cached entries remain forever. By default,libcurl caches this info for 60 seconds..IP CURLOPT_DNS_USE_GLOBAL_CACHEPass a long. If the value is non-zero, it tells curl to use a global DNS cachethat will survive between easy handle creations and deletions. This is notthread-safe and this will use a global variable.\fBWARNING:\fP this option is considered obsolete. Stop using it. Switch overto using the share interface instead! See \fICURLOPT_SHARE\fP and\fIcurl_share_init(3)\fP..IP CURLOPT_BUFFERSIZEPass a long specifying your preferred size (in bytes) for the receive bufferin libcurl. The main point of this would be that the write callback getscalled 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. (Addedin 7.10)This size is by default set as big as possible (CURL_MAX_WRITE_SIZE), so itonly makes sense to use this option if you want it smaller..IP CURLOPT_PORTPass a long specifying what remote port number to connect to, instead of theone specified in the URL or the default port for the used protocol..IP CURLOPT_TCP_NODELAYPass a long specifying whether the TCP_NODELAY option should be set orcleared (1 = set, 0 = clear). The option is cleared by default. Thiswill have no effect after the connection has been established.Setting this option will disable TCP's Nagle algorithm. The purpose ofthis algorithm is to try to minimize the number of small packets onthe network (where "small packets" means TCP segments less than theMaximum Segment Size (MSS) for the network).Maximizing the amount of data sent per TCP segment is good because itamortizes the overhead of the send. However, in some cases (mostnotably telnet or rlogin) small segments may need to be sentwithout delay. This is less efficient than sending larger amounts ofdata at a time, and can contribute to congestion on the network ifoverdone..SH NAMES and PASSWORDS OPTIONS (Authentication)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -