man curl_easy_setopt(原创)

中文翻译:

curl_easy_setopt(3) libcurl 手册 curl_easy_setopt(3)

名称
curl_easy_setopt -curl的设置选项
概要
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);
描述
curl_easy_setopt(3)是用来告诉libcurl如何表现.通过设置适当的选项,应用程序可以改变libcurl的行为。所有选项都设置一个选项,然后由一个参数.
这个比较长:一个函数指针,一个对象的指针或curl_off_t,取决于具体方案预计。如果参数的值不符合要求,可能导致libcurl达到理想效果,请仔细阅读本手册。一个典型的应用程序中会使用许多‐curl_easy_setopt(3)来对环境进行设置。此函数调用的选项设置对下面程序进行传输执行的参数设置,这个函数不能对已经设置的函数进行恢复,如果你想回到内部默认的状态,你可以调用curl_easy_reset(3)。

字符串传递给libcurl作为字符串参数,由图书馆复制,从而对指针参数的字符串储存空间可能会被curl_easy_setopt(3)的返回值覆盖。

字符串传递给libcurl作为字符串参数,由文件管理系统复制,从而对指针参数关联的字符串存储空间可能会被curl_easy_setopt(3)的返回值覆盖。这个规则的唯一例外是 really 的curlopt_postfields(3),但选择拷贝的字符串curlopt_copypostfields(3)有一定的使用特点需要你读了。

选项设置的顺序不重要。

以前的版本7.17.0,字符串不复制。相反,保持用户促使有效直到libcurl不再需要他们。

处理是从curl_easy_init返回代码(3)或(3)curl_easy_duphandle调用。
行为选择
CURLOPT_VERBOSE
如果你想CURL报告每一件意外的事情,设置这个选项为一个非零值。See CURLOPT_VERBOSE(3)
CURLOPT_HEADER
如果你想把一个头包含在输出中,设置这个选项为一个非零值. See CURLOPT_HEADER(3)
CURLOPT_NOPROGRESS
关闭进度表. See CURLOPT_NOPROGRESS(3)
CURLOPT_NOSIGNAL
不要安装信号处理程序. See CURLOPT_NOSIGNAL(3)
CURLOPT_WILDCARDMATCH
根据文件名模式传输多个文件. See CURLOPT_WILDCARDMATCH(3)
回调函数的选择
CURLOPT_WRITEFUNCTION
写入数据的回调. See CURLOPT_WRITEFUNCTION(3)
CURLOPT_WRITEDATA
数据指针传递给写回调. See CURLOPT_WRITE‐DATA(3)
CURLOPT_READFUNCTION
读取数据回调. See CURLOPT_READFUNCTION(3)
CURLOPT_READDATA
数据指针传递给读回调. See CURLOPT_READ‐DATA(3)
CURLOPT_IOCTLFUNCTION
回调的I/O操作. See CURLOPT_IOCTLFUNCTION(3)
CURLOPT_IOCTLDATA
数据指针传递给I/O回调. See CURLOPT_IOCTL‐DATA(3)
CURLOPT_SEEKFUNCTION
寻求操作的回调. See CURLOPT_SEEKFUNCTION(3)
CURLOPT_SEEKDATA
数据指针传递给寻求回调. See CURLOPT_SEEK‐ DATA(3)
CURLOPT_SOCKOPTFUNCTION
套接字创建的回调. See CURLOPT_SOCKOPTFUNCTION(3)
CURLOPT_SOCKOPTDATA
数据指针传递给sockopt回调. See CURLOPT_SOCK‐OPTDATA(3)
CURLOPT_OPENSOCKETFUNCTION
创建套接字(socket)的回调. See CURLOPT_OPENSOCKETFUNCTION(3)
CURLOPT_OPENSOCKETDATA
数据指针传递给打开的套接字(socket)回调.See CUR‐LOPT_OPENSOCKETDATA(3)
CURLOPT_CLOSESOCKETFUNCTION
关闭套接字(socket)的回调. See CURLOPT_CLOSESOCKETFUNCTION(3)
CURLOPT_CLOSESOCKETDATA
数据指针传递给 关闭套接字回调
数据指针传递给关闭套接字(socket)回调. See CUR‐LOPT_CLOSESOCKETDATA(3)
CURLOPT_PROGRESSFUNCTION
过时的回调进度表(meter). See CURLOPT_PROGRESSFUNC‐TION(3)
CURLOPT_PROGRESSDATA
数据指针传递给进度表(meter)回调. See CUR‐LOPT_PROGRESSDATA(3)
CURLOPT_XFERINFOFUNCTION
进度表的回调. See CURLOPT_XFERINFOFUNCTION(3)
CURLOPT_XFERINFODATA
数据指针传递给进度表回调.See CUR‐LOPT_XFERINFODATA(3)
CURLOPT_HEADERFUNCTION
写入接收头的回调. See CURLOPT_HEADERFUNC‐TION(3)
CURLOPT_HEADERDATA
数据指针指向头(header)回调. See CURLOPT_HEADER‐DATA(3)
CURLOPT_DEBUGFUNCTION
调试信息的回调. See CURLOPT_DEBUGFUNCTION(3)
CURLOPT_DEBUGDATA
数据指传递向调试回调. See CURLOPT_DEBUG‐DATA(3)
CURLOPT_SSL_CTX_FUNCTION
ssl上线文逻辑回调. See CURLOPT_SSL_CTX_FUNCTION(3)
CURLOPT_SSL_CTX_DATA
数据指针传递给SSL上下文回调. See CUR‐LOPT_SSL_CTX_DATA(3)
CURLOPT_CONV_TO_NETWORK_FUNCTION
代码库转换的回调. See CURLOPT_CONV_TO_NET‐WORK_FUNCTION(3)
CURLOPT_CONV_FROM_NETWORK_FUNCTION
代码库转换的回调. See CURLOPT_CONV_FROM_NET‐WORK_FUNCTION(3)
CURLOPT_CONV_FROM_UTF8_FUNCTION
代码库转换的回调. See CUR‐LOPT_CONV_FROM_UTF8_FUNCTION(3)
CURLOPT_INTERLEAVEFUNCTION
回调RTSP交错的数据. See CURLOPT_INTERLEAVEFUNC‐TION(3)
CURLOPT_INTERLEAVEDATA
数据指针通过RTSP交织回调. See CUR‐LOPT_INTERLEAVEDATA(3)
CURLOPT_CHUNK_BGN_FUNCTION
通配符下载启动块回调. See CUR‐LOPT_CHUNK_BGN_FUNCTION(3)
CURLOPT_CHUNK_END_FUNCTION
对于大块通配符下载结束回调. See CUR‐LOPT_CHUNK_END_FUNCTION(3)
CURLOPT_CHUNK_DATA
数据指针传递给块回调.See CUR‐LOPT_CHUNK_DATA(3)
CURLOPT_FNMATCH_FUNCTION
通配符匹配回调. See CURLOPT_FNMATCH_FUNCTION(3)
CURLOPT_FNMATCH_DATA
数据指针通过通配符匹配回调. See CUR‐LOPT_FNMATCH_DATA(3)
错误选择
CURLOPT_ERRORBUFFER
错误消息缓冲区. See CURLOPT_ERRORBUFFER(3)
CURLOPT_STDERR
标准错误置换流. See CURLOPT_STDERR(3)
CURLOPT_FAILONERROR
在HTTP 4xx 错误失败. CURLOPT_FAILONERROR(3)
网络选项
CURLOPT_URL
URL工作. See CURLOPT_URL(3)
CURLOPT_PATH_AS_IS
禁用挤压/../ 和/../在路径序列. See CUR‐LOPT_PATH_AS_IS(3)
CURLOPT_PROTOCOLS
协议允许. See CURLOPT_PROTOCOLS(3)
CURLOPT_REDIR_PROTOCOLS
协议允许重定向到. See CURLOPT_REDIR_PROTOCOLS(3)
CURLOPT_DEFAULT_PROTOCOL
默认协议. See CURLOPT_DEFAULT_PROTOCOL(3)
CURLOPT_PROXY
使用代理. See CURLOPT_PROXY(3)
CURLOPT_PROXYPORT
代理端口使用. See CURLOPT_PROXYPORT(3)
CURLOPT_PROXYTYPE
代理类型. See CURLOPT_PROXYTYPE(3)
CURLOPT_NOPROXY
从代理使用筛选主机. CURLOPT_NOPROXY(3)
CURLOPT_HTTPPROXYTUNNEL
通过HTTP代理隧道. CURLOPT_HTTPPROXYTUNNEL(3)
CURLOPT_SOCKS5_GSSAPI_SERVICE
Socks5 GSSAPI服务名字. CURLOPT_SOCKS5_GSSAPI_SERVICE(3)
CURLOPT_SOCKS5_GSSAPI_NEC
Socks5 GSSAPI 无差错校验模式. See CURLOPT_SOCKS5_GSSAPI_NEC(3)
CURLOPT_PROXY_SERVICE_NAME
代理服务名字. CURLOPT_PROXY_SERVICE_NAME(3)
CURLOPT_SERVICE_NAME
SPNEGO服务名字. CURLOPT_SERVICE_NAME(3)
CURLOPT_INTERFACE
绑定本地连接. See CURLOPT_INTERFACE(3)
CURLOPT_LOCALPORT
绑定本地连接到端口. See CURLOPT_LOCALPORT(3)
CURLOPT_LOCALPORTRANGE
绑定本地连接绑定到范围端口. See CURLOPT_LOCALPOR‐TRANGE(3)
CURLOPT_DNS_CACHE_TIMEOUT
DNS缓存超时. See CURLOPT_DNS_CACHE_TIMEOUT(3)
CURLOPT_DNS_USE_GLOBAL_CACHE
过时的使全局DNS缓存。See CUR‐LOPT_DNS_USE_GLOBAL_CACHE(3)
CURLOPT_BUFFERSIZE
要求较小的缓冲区大小. See CURLOPT_BUFFERSIZE(3)
CURLOPT_PORT
端口号连接到. See CURLOPT_PORT(3)
CURLOPT_TCP_NODELAY
禁用Nagle算法. See CURLOPT_TCP_NODELAY(3)
CURLOPT_ADDRESS_SCOPE
对于本地地址IPv6范围. See CURLOPT_ADDRESS_SCOPE(3)
CURLOPT_TCP_KEEPALIVE
启动持久连接(TCP keep-alive). See CURLOPT_TCP_KEEPALIVE(3)
CURLOPT_TCP_KEEPIDLE
发送前的空闲时间. See CURLOPT_TCP_KEEPIDLE(3)
CURLOPT_TCP_KEEPINTVL
保持活探针之间的间隔. See CURLOPT_TCP_KEEPINTVL(3)
CURLOPT_UNIX_SOCKET_PATH
一个Unix域套接字(socket)的路径. See CURLOPT_UNIX_SOCKET_PATH(3)
名称和密码选项(身份验证)
CURLOPT_NETRC
使用.户配置脚本文件解析. See CURLOPT_NETRC(3)
CURLOPT_NETRC_FILE
.配置脚本文件名. See CURLOPT_NETRC_FILE(3)
CURLOPT_USERPWD
用户名和密码. See CURLOPT_USERPWD(3)
CURLOPT_PROXYUSERPWD
代理用户名和密码.See CURLOPT_PROXYUSERPWD(3)
CURLOPT_USERNAME
用户名. See CURLOPT_USERNAME(3)
CURLOPT_PASSWORD
密码. See CURLOPT_PASSWORD(3)
CURLOPT_LOGIN_OPTIONS
登陆选项. See CURLOPT_LOGIN_OPTIONS(3)
CURLOPT_PROXYUSERNAME
代理用户名. See CURLOPT_PROXYUSERNAME(3)
CURLOPT_PROXYPASSWORD
代理密码. See CURLOPT_PROXYPASSWORD(3)
CURLOPT_HTTPAUTH
HTTP服务器的身份验证方法. See CURLOPT_HTTPAUTH(3)
CURLOPT_TLSAUTH_USERNAME
TLS 验证用户名. See CURLOPT_TLSAUTH_USERNAME(3)
CURLOPT_TLSAUTH_PASSWORD
TLS 验证密码. See CURLOPT_TLSAUTH_PASSWORD(3)
CURLOPT_TLSAUTH_TYPE
TLS 身份验证方法. See CURLOPT_TLSAUTH_TYPE(3)
CURLOPT_PROXYAUTH
HTTP代理验证方法. See CURLOPT_PROXYAUTH(3)
CURLOPT_SASL_IR
使SASL的初始响应. See CURLOPT_SASL_IR(3)
CURLOPT_XOAUTH2_BEARER
OAuth2不记名令牌. See CURLOPT_XOAUTH2_BEARER(3)

HTTP选项
CURLOPT_AUTOREFERER
自动设置参考;标题. See CURLOPT_AUTOREFERER(3)
CURLOPT_ACCEPT_ENCODING
接受编码和自动解压缩数据. See CUR‐LOPT_ACCEPT_ENCODING(3)
CURLOPT_TRANSFER_ENCODING
请求传输编码. See CURLOPT_TRANSFER_ENCODING(3)
CURLOPT_FOLLOWLOCATION
遵循HTTP重定向. See CURLOPT_FOLLOWLOCATION(3)
CURLOPT_UNRESTRICTED_AUTH
不限制对原始主机的身份验证. CURLOPT_UNRE‐STRICTED_AUTH(3)
CURLOPT_MAXREDIRS
跟随重定向的最大数量. See CURLOPT_MAXREDIRS(3)
CURLOPT_POSTREDIR
如何采取行动后的重定向POST. See CURLOPT_POSTREDIR(3)
CURLOPT_PUT
发出一个HTTP PUT请求. See CURLOPT_PUT(3)
CURLOPT_POST
发送一个HTTP POST要求. See CURLOPT_POST(3)
CURLOPT_POSTFIELDS
用这个数据发送一个POST. See CURLOPT_POSTFIELDS(3)
CURLOPT_POSTFIELDSIZE
如果你想发送数据POST到服务器没有libcurl做strlen()测量数据的大小,必须使用此选项。使用此选项时你可以把完全的二进制数据,否则可能会失败。如果这个大小设置为1,图书馆将使用strlen()得到尺寸. See CURLOPT_POSTFIELDSIZE(3)
CURLOPT_POSTFIELDSIZE_LARGE
如果你想发送数据POST到服务器没有libcurl做strlen()测量数据的大小,必须使用此选项。使用此选项时你可以把完全的二进制数据,否则可能会失败。如果这个大小设置为1,图书馆将使用strlen()得到尺寸. See CURLOPT_POSTFIELDSIZE_LARGE(3)
CURLOPT_COPYPOSTFIELDS
以POST的方式发送一段内容.See CURLOPT_COPYPOST‐FIELDS(3)
CURLOPT_HTTPPOST
多窗体发送HTTP POST. See CURLOPT_HTTPPOST(3)
CURLOPT_REFERER
引用:标头. See CURLOPT_REFERER(3)
CURLOPT_USERAGENT
用户代理:标头. See CURLOPT_USERAGENT(3)
CURLOPT_HTTPHEADER
自定义HTTP头.See CURLOPT_HTTPHEADER(3)
CURLOPT_HEADEROPT
控件自定义HTTP头. See CURLOPT_HEADEROPT(3)
CURLOPT_PROXYHEADER
自定义发送到代理的HTTP头. See CURLOPT_PROXYHEADER(3)
CURLOPT_HTTP200ALIASES
指定HTTP 200 OK备选匹配.See CURLOPT_HTTP200ALIASES(3)
CURLOPT_COOKIE
发送小文件. See CURLOPT_COOKIE(3)
CURLOPT_COOKIEFILE
从文件读取. See CURLOPT_COOKIEFILE(3)
CURLOPT_COOKIEJAR
向文件写入. See CURLOPT_COOKIEJAR(3)
CURLOPT_COOKIESESSION
开始一个新的cookie会话. See CURLOPT_COOKIESESSION(3)
CURLOPT_COOKIELIST
添加或控制cookies. See CURLOPT_COOKIELIST(3)
CURLOPT_HTTPGET
做一个HTTP GET请求.See CURLOPT_HTTPGET(3)
CURLOPT_HTTP_VERSION
HTTP版本的使用.CURLOPT_HTTP_VERSION(3)
CURLOPT_IGNORE_CONTENT_LENGTH
忽略内容长度(Content-Length). See CURLOPT_IGNORE_CONTENT_LENGTH(3)
CURLOPT_HTTP_CONTENT_DECODING
禁用Content(CSS的一种属性)译码. See CURLOPT_HTTP_CONTENT_DECODING(3)
CURLOPT_HTTP_TRANSFER_DECODING
禁用传输解码.See CURLOPT_HTTP_TRANSFER_DECODING(3)
CURLOPT_EXPECT_100_TIMEOUT_MS
客户端在发送POST数据给服务器前,征询服务器情况,看服务器是否处理POST的数据(100ms). See CURLOPT_EXPECT_100_TIMEOUT_MS(3)
CURLOPT_PIPEWAIT
等待连接到通道.See CURLOPT_PIPEWAIT(3)
CURLOPT_STREAM_DEPENDS
当前HTTP/2流取决于另一端. See CUR‐LOPT_STREAM_DEPENDS(3)
CURLOPT_STREAM_DEPENDS_E
当前HTTP/2流只取决于另一端. See CUR‐LOPT_STREAM_DEPENDS_E(3)
CURLOPT_STREAM_WEIGHT
设置HTTP/2流的重量. See CURLOPT_STREAM_WEIGHT(3)
SMTP(简单邮件传输协议) OPTIONS
CURLOPT_MAIL_FROM
发件人地址. See CURLOPT_MAIL_FROM(3)
一个指针传递给一个零结尾的字符串作为参数。这应该是用于发送libcurl的SMTP邮件时指定发件人的电子邮件地址。发起者的电子邮件地址应与尖括号(<>)周围,如果没有提供,将被自动添加指定。如果未指定该参数是一个空地址将被发送到这可能会导致邮件被拒绝的邮件服务器。
CURLOPT_MAIL_RCPT
邮件的收件人列表. See CURLOPT_MAIL_RCPT(3)
一个指针传递到收件人的链表传递给服务器的smtp邮件的请求。链表应该是一个完全有效的列表结构curl_slist结构正确填写。使用curl_slist_append创建列表和curl_slist_free_all清理整个列表。
CURLOPT_MAIL_AUTH
证书地址. See CURLOPT_MAIL_AUTH(3)
TFTP选择
CURLOPT_TFTP_BLKSIZE
TFTP block size. See CURLOPT_TFTP_BLKSIZE(3)

FTP OPTIONS
CURLOPT_FTPPORT
使用主动FTP. See CURLOPT_FTPPORT(3)
CURLOPT_QUOTE
传输前运行的命令. See CURLOPT_QUOTE(3)
CURLOPT_POSTQUOTE
传输后运行命令. See CURLOPT_POSTQUOTE(3)
CURLOPT_PREQUOTE
命令在传输之前运行. See CURLOPT_PREQUOTE(3)
CURLOPT_APPEND
附加到远程文件. See CURLOPT_APPEND(3)
设置这个选项为一个非零值,PHP将应用远程文件代替覆盖它
CURLOPT_FTP_USE_EPRT
启用FTP /禁止使用EPRT的. See CURLOPT_FTP_USE_EPRT(3)
CURLOPT_FTP_USE_EPSV
启用/禁用使用的EPSV. See CURLOPT_FTP_USE_EPSV(3)
CURLOPT_FTP_USE_PRET
使PRET命令. See CURLOPT_FTP_USE_PRET(3)
CURLOPT_FTP_CREATE_MISSING_DIRS
选项可以在上传时在目标机创建新目录(如果该目录不存在). See CUR‐LOPT_FTP_CREATE_MISSING_DIRS(3)
CURLOPT_FTP_RESPONSE_TIMEOUT
FTP响应超时. See CURLOPT_FTP_RESPONSE_TIMEOUT(3)
CURLOPT_FTP_ALTERNATIVE_TO_USER
替代用户. See CURLOPT_FTP_ALTERNATIVE_TO_USER(3)
CURLOPT_FTP_SKIP_PASV_IP
忽略在PASV响应的IP地址. See CUR‐LOPT_FTP_SKIP_PASV_IP(3)
CURLOPT_FTPSSLAUTH
控制如何做TLS. See CURLOPT_FTPSSLAUTH(3)
CURLOPT_FTP_SSL_CCC
再次回到非TLS认证后. See CUR‐LOPT_FTP_SSL_CCC(3)
CURLOPT_FTP_ACCOUNT
为FTP设置帐户信息. See CURLOPT_FTP_ACCOUNT(3)
一个指针传递给一个零结尾的字符串(或NULL以禁用)。当FTP服务器请求已提供的用户名和密码后,“帐户数据”,此数据是使用ACCT命令被红牌罚下。
CURLOPT_FTP_FILEMETHOD
指定如何到达文件. See CURLOPT_FTP_FILEMETHOD(3)
RTSP选择
CURLOPT_RTSP_REQUEST
指定RTSP请求. See CURLOPT_RTSP_REQUEST(3)
CURLOPT_RTSP_SESSION_ID
设置RTSP会话ID. See CURLOPT_RTSP_SESSION_ID(3)
CURLOPT_RTSP_STREAM_URI
RTSP流URI集. See CURLOPT_RTSP_STREAM_URI(3)
CURLOPT_RTSP_TRANSPORT
RTSP传输: header. See CURLOPT_RTSP_TRANSPORT(3)
CURLOPT_RTSP_CLIENT_CSEQ
设置RTSP客户端的CSEQ号. See CURLOPT_RTSP_CLIENT_CSEQ(3)
CURLOPT_RTSP_SERVER_CSEQ
CSEQ信号的RTSP服务器->客户端请求. See CUR‐LOPT_RTSP_SERVER_CSEQ(3)
协议选项
CURLOPT_TRANSFERTEXT
使用文本传输. See CURLOPT_TRANSFERTEXT(3)
CURLOPT_PROXY_TRANSFER_MODE
通过添加传输模式到代理服务器上的网址. See CURLOPT_PROXY_TRANS‐FER_MODE(3)
CURLOPT_CRLF
启用/禁用CRLF转换. See CURLOPT_CRLF(3)
经过很长。如果该值设置为1(一),转换的libcurl unix的换行符crlf对转让换行符。通过将该值设置为0(零)再次关闭此选项。 这是值得商榷使用的传统的选项。
CURLOPT_RANGE
设置字节范围请求. See CURLOPT_RANGE(3)5
CURLOPT_RESUME_FROM
恢复传输. See CURLOPT_RESUME_FROM(3)
CURLOPT_RESUME_FROM_LARGE
恢复传输. See CURLOPT_RESUME_FROM_LARGE(3)
CURLOPT_CUSTOMREQUEST
自定义请求/方法. See CURLOPT_CUSTOMREQUEST(3)
CURLOPT_FILETIME
请求文件修改日期和时间. See CURLOPT_FILETIME(3)
CURLOPT_DIRLISTONLY
只有在目录列表中索要名称. See CURLOPT_DIRLISTONLY(3)
CURLOPT_NOBODY
不获取身体内容. See CURLOPT_NOBODY(3)
CURLOPT_INFILESIZE
发送的文件大小. CURLOPT_INFILESIZE(3)
CURLOPT_INFILESIZE_LARGE
发送的文件大小. CURLOPT_INFILESIZE_LARGE(3)
CURLOPT_UPLOAD
上载数据. See CURLOPT_UPLOAD(3)
CURLOPT_MAXFILESIZE
允许下载的最大文件大小. See CURLOPT_MAXFILESIZE(3)
CURLOPT_MAXFILESIZE_LARGE
允许下载的最大文件大小. See CURLOPT_MAXFILESIZE_LARGE(3)
CURLOPT_TIMECONDITION
做一个时间条件请求. See CURLOPT_TIMECONDITION(3)
CURLOPT_TIMEVALUE
时间条件请求的时间值. See CUR‐LOPT_TIMEVALUE(3)
连接选项
CURLOPT_TIMEOUT
整个请求的超时时间(s).See CURLOPT_TIMEOUT(3)
CURLOPT_TIMEOUT_MS
整个请求的超时时间(ms).See CURLOPT_TIME‐OUT_MS(3)
CURLOPT_LOW_SPEED_LIMIT
低限速中止传输.See CUR‐LOPT_LOW_SPEED_LIMIT(3)
CURLOPT_LOW_SPEED_TIME
时间低于速度触发低速中止. See CUR‐LOPT_LOW_SPEED_TIME(3)
CURLOPT_MAX_SEND_SPEED_LARGE
上限上传速度. See CUR‐LOPT_MAX_SEND_SPEED_LARGE(3)
CURLOPT_MAX_RECV_SPEED_LARGE
下载速度上限. See CUR‐LOPT_MAX_RECV_SPEED_LARGE(3)
CURLOPT_MAXCONNECTS
连接池中的最大连接数. See CUR‐LOPT_MAXCONNECTS(3)
CURLOPT_FRESH_CONNECT
使用一个新的连接. CURLOPT_FRESH_CONNECT(3)
CURLOPT_FORBID_REUSE
防止随后重新连接. See CUR‐LOPT_FORBID_REUSE(3)
CURLOPT_CONNECTTIMEOUT
连接阶段的超时(m). See CURLOPT_CONNECTTIMEOUT(3)
CURLOPT_CONNECTTIMEOUT_MS
连接阶段的超时(ms). See CURLOPT_CON‐NECTTIMEOUT_MS(3)
CURLOPT_IPRESOLVE
IP版本解决. See CURLOPT_IPRESOLVE(3)
CURLOPT_CONNECT_ONLY
只有连接,没有别的. See CURLOPT_CONNECT_ONLY(3)
CURLOPT_USE_SSL
使用TLS / SSL. See CURLOPT_USE_SSL(3)
CURLOPT_RESOLVE
提供自定义主机名到IP地址的解析. See CURLOPT_RESOLVE(3)
CURLOPT_DNS_INTERFACE
绑定名称解析到这个接口. See CURLOPT_DNS_INTER‐FACE(3)
CURLOPT_DNS_LOCAL_IP4
绑定名称解析到这个IP4地址. See CUR‐LOPT_DNS_LOCAL_IP4(3)
CURLOPT_DNS_LOCAL_IP6
绑定名称解析到这个IP6地址. See CUR‐LOPT_DNS_LOCAL_IP6(3)
CURLOPT_DNS_SERVERS
首选DNS服务器. See CURLOPT_DNS_SERVERS(3)
CURLOPT_ACCEPTTIMEOUT_MS
等待服务器的连接被接受的超时(ms). See CURLOPT_ACCEPTTIMEOUT_MS(3)
SSL和安全选项
CURLOPT_SSLCERT
客户端证书. See CURLOPT_SSLCERT(3)
CURLOPT_SSLCERTTYPE
客户端证书类型. See CURLOPT_SSLCERTTYPE(3)
CURLOPT_SSLKEY
客户端钥匙. See CURLOPT_SSLKEY(3)
CURLOPT_SSLKEYTYPE
客户端钥匙类型. See CURLOPT_SSLKEYTYPE(3)
CURLOPT_KEYPASSWD
客户端钥匙密码. See CURLOPT_KEYPASSWD(3)
CURLOPT_SSL_ENABLE_ALPN
启用ALPN. See CURLOPT_SSL_ENABLE_ALPN(3)
CURLOPT_SSL_ENABLE_NPN
启用NPN. See CURLOPT_SSL_ENABLE_NPN(3)
CURLOPT_SSLENGINE
使用SSL引擎标识符. See CURLOPT_SSLENGINE(3)
CURLOPT_SSLENGINE_DEFAULT
默认的SSL引擎. See CURLOPT_SSLENGINE_DEFAULT(3)
CURLOPT_SSL_FALSESTART
启用TLS抢跑.See CURLOPT_SSL_FALSESTART(3)
CURLOPT_SSLVERSION
SSL版本使用.See CURLOPT_SSLVERSION(3)
CURLOPT_SSL_VERIFYHOST
验证的主机名SSL证书.See CUR‐LOPT_SSL_VERIFYHOST(3)
CURLOPT_SSL_VERIFYPEER
验证SSL证书. See CURLOPT_SSL_VERIFYPEER(3)
CURLOPT_SSL_VERIFYSTATUS
验证SSL证书的状态.See CURLOPT_SSL_VERIFYSTA‐TUS(3)
CURLOPT_CAINFO
捆绑的CA证书. See CURLOPT_CAINFO(3)
CURLOPT_ISSUERCERT
发行者证书. See CURLOPT_ISSUERCERT(3)
CURLOPT_CAPATH
捆绑的CA证书路径. See CURLOPT_CAPATH(3)
CURLOPT_CRLFILE
证书吊销列表. See CURLOPT_CRLFILE(3)
CURLOPT_CERTINFO
提取证书信息. See CURLOPT_CERTINFO(3)
CURLOPT_PINNEDPUBLICKEY
设置固定的SSL密钥. See CURLOPT_PINNEDPUBLICKEY(3)
CURLOPT_RANDOM_FILE
指定一个随机的数据源.See CURLOPT_RAN‐DOM_FILE(3)
CURLOPT_EGDSOCKET
点对点(EGD)套接字(socket)的路径. See CURLOPT_EGDSOCKET(3)
CURLOPT_SSL_CIPHER_LIST
使用密码. See CURLOPT_SSL_CIPHER_LIST(3)
CURLOPT_SSL_SESSIONID_CACHE
禁用SSL会话ID缓存.See CURLOPT_SSL_SESSIONID_CACHE(3)
CURLOPT_SSL_OPTIONS
SSL行为控制.See CURLOPT_SSL_OPTIONS(3)
CURLOPT_KRBLEVEL
Kerberos安全水平.See CURLOPT_KRBLEVEL(3)
CURLOPT_GSSAPI_DELEGATION
禁用GSS-API授权.See CURLOPT_GSSAPI_DELEGATION(3)
SSH选择
CURLOPT_SSH_AUTH_TYPES
SSH认证类型. See CURLOPT_SSH_AUTH_TYPES(3)
CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
MD5的主机的公钥.See CURLOPT_SSH_HOST_PUBLIC_KEY_MD5(3)
CURLOPT_SSH_PUBLIC_KEYFILE
公共密钥的文件名. See CURLOPT_SSH_PUBLIC_KEYFILE(3)
CURLOPT_SSH_PRIVATE_KEYFILE
私有密匙的文件名. See CURLOPT_SSH_PRIVATE_KEYFILE(3)
CURLOPT_SSH_KNOWNHOSTS
已知主机的文件名. See CURLOPT_SSH_KNOWNHOSTS(3)
CURLOPT_SSH_KEYFUNCTION
回调已知主机处理. See CURLOPT_SSH_KEYFUNC‐TION(3)
CURLOPT_SSH_KEYDATA
自定义指针通过ssh钥匙的回调. See CURLOPT_SSH_KEY‐DATA(3)
其他选项
CURLOPT_PRIVATE
专用指针存储. See CURLOPT_PRIVATE(3)
CURLOPT_SHARE
共享对象使用. See CURLOPT_SHARE(3)
CURLOPT_NEW_FILE_PERMS
创建新远程文件的模式. See CUR‐LOPT_NEW_FILE_PERMS(3)
CURLOPT_NEW_DIRECTORY_PERMS
创建新的远程目录的模式. See CURLOPT_NEW_DIREC‐TORY_PERMS(3)

远程登录选项
CURLOPT_TELNETOPTIONS
远程登录选项. See CURLOPT_TELNETOPTIONS(3)

返回值
CURLE_OK (零)意味着选择了正确的选项, 非零意味着错误发生是<curl/curl.h>定义.详情请见libcurl-errors(3) 操作说明有完整的列表.
如果你试图设置一个libcurl的不知道的选项,也许是因为说明手册太老的支持或选择在最近的版本中删除,该函数将返回curle_unknown_option。如果参数不真确在编译时,它将返回curle_not_built_in。

范例
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}

请参阅
curl_easy_init(3), curl_easy_cleanup(3), curl_easy_reset(3),curl_easy_getinfo(3), curl_multi_setopt(3),

libcurl 7.38.0               25 Jun 2014                 curl_easy_setopt(3)

英文原文:

  1 curl_easy_setopt(3)             libcurl Manual             curl_easy_setopt(3)
  2 
  3 NAME
  4        curl_easy_setopt - set options for a curl easy handle
  5 
  6 SYNOPSIS
  7        #include <curl/curl.h>
  8 
  9        CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);
 10 
 11 DESCRIPTION
 12        curl_easy_setopt(3)  is  used to tell libcurl how to behave. By setting the appropriate options, the application can change libcurl's behavior. All options are set with an option followed by a parameter. That param‐ eter can be a  long,  a  function  pointer,  an  object  pointer  or  a curl_off_t,  depending  on  what the specific option expects. Read this manual carefully as bad input values may cause libcurl to behave badly! You  can  only set one option in each function call. A typical applica‐ tion uses many curl_easy_setopt(3) calls in the setup phase.
 13 
 14        Options set with this function  call  are  valid  for  all  forthcoming transfers  performed using this handle.  The options are not in any way reset between transfers, so if you want subsequent transfers with  dif‐ ferent  options,  you  must  change them between the transfers. You can optionally  reset  all  options   back   to   internal   default   with curl_easy_reset(3).
 15 
 16        Strings  passed  to  libcurl  as  'char *' arguments, are copied by the library; thus the string storage associated to the pointer argument may be overwritten after curl_easy_setopt(3) returns. The only exception to this rule is really CURLOPT_POSTFIELDS(3),  but  the  alternative  that copies the string CURLOPT_COPYPOSTFIELDS(3) has some usage characteris‐ tics you need to read up on.
 17 
 18        The order in which the options are set does not matter.
 19 
 20        Before version 7.17.0, strings were not copied. Instead  the  user  was forced keep them available until libcurl no longer needed them.
 21 
 22        The   handle   is   the   return   code  from  a  curl_easy_init(3)  or curl_easy_duphandle(3) call.
 23 
 24 BEHAVIOR OPTIONS
 25        CURLOPT_VERBOSE
 26               Display verbose information. See CURLOPT_VERBOSE(3)
 27 
 28        CURLOPT_HEADER
 29               Include the header in the body output. See CURLOPT_HEADER(3)
 30 
 31        CURLOPT_NOPROGRESS
 32               Shut off the progress meter. See CURLOPT_NOPROGRESS(3)
 33 
 34        CURLOPT_NOSIGNAL
 35               Do not install signal handlers. See CURLOPT_NOSIGNAL(3)
 36 
 37        CURLOPT_WILDCARDMATCH
 38               Transfer multiple files according to a file  name  pattern.  See CURLOPT_WILDCARDMATCH(3)
 39 
 40 CALLBACK OPTIONS
 41        CURLOPT_WRITEFUNCTION
 42               Callback for writing data. See CURLOPT_WRITEFUNCTION(3)
 43 
 44        CURLOPT_WRITEDATA
 45               Data  pointer  to pass to the write callback. See CURLOPT_WRITE‐ DATA(3)
 46 
 47        CURLOPT_READFUNCTION
 48               Callback for reading data. See CURLOPT_READFUNCTION(3)
 49 
 50        CURLOPT_READDATA
 51               Data pointer to pass to the  read  callback.  See  CURLOPT_READ‐DATA(3)
 52 
 53        CURLOPT_IOCTLFUNCTION
 54               Callback for I/O operations. See CURLOPT_IOCTLFUNCTION(3)
 55 
 56        CURLOPT_IOCTLDATA
 57               Data  pointer  to  pass  to the I/O callback. See CURLOPT_IOCTL‐DATA(3)
 58 
 59        CURLOPT_SEEKFUNCTION
 60               Callback for seek operations. See CURLOPT_SEEKFUNCTION(3)
 61 
 62        CURLOPT_SEEKDATA
 63               Data pointer to pass to the  seek  callback.  See  CURLOPT_SEEK‐DATA(3)
 64 
 65        CURLOPT_SOCKOPTFUNCTION
 66               Callback for sockopt operations. See CURLOPT_SOCKOPTFUNCTION(3)
 67 
 68        CURLOPT_SOCKOPTDATA
 69               Data  pointer to pass to the sockopt callback. See CURLOPT_SOCK‐OPTDATA(3)
 70 
 71        CURLOPT_OPENSOCKETFUNCTION
 72               Callback for socket creation. See CURLOPT_OPENSOCKETFUNCTION(3)
 73 
 74        CURLOPT_OPENSOCKETDATA
 75               Data pointer to pass to  the  open  socket  callback.  See  CUR‐LOPT_OPENSOCKETDATA(3)
 76 
 77        CURLOPT_CLOSESOCKETFUNCTION
 78               Callback for closing socket. See CURLOPT_CLOSESOCKETFUNCTION(3)
 79 
 80        CURLOPT_CLOSESOCKETDATA
 81               Data  pointer  to  pass  to  the close socket callback. See CUR‐LOPT_CLOSESOCKETDATA(3)
 82 
 83        CURLOPT_PROGRESSFUNCTION
 84               OBSOLETE callback for progress meter. See  CURLOPT_PROGRESSFUNC‐TION(3)
 85 
 86        CURLOPT_PROGRESSDATA
 87               Data  pointer  to  pass to the progress meter callback. See CUR‐LOPT_PROGRESSDATA(3)
 88 
 89        CURLOPT_XFERINFOFUNCTION
 90               Callback for progress meter. See CURLOPT_XFERINFOFUNCTION(3)
 91 
 92        CURLOPT_XFERINFODATA
 93               Data pointer to pass to the progress meter  callback.  See  CUR‐LOPT_XFERINFODATA(3)
 94 
 95        CURLOPT_HEADERFUNCTION
 96               Callback  for  writing received headers. See CURLOPT_HEADERFUNC‐TION(3)
 97 
 98        CURLOPT_HEADERDATA
 99               Data pointer to pass to the header callback. See CURLOPT_HEADER‐DATA(3)
100 
101        CURLOPT_DEBUGFUNCTION
102               Callback for debug information. See CURLOPT_DEBUGFUNCTION(3)
103 
104        CURLOPT_DEBUGDATA
105               Data  pointer  to pass to the debug callback. See CURLOPT_DEBUG‐
106               DATA(3)
107 
108        CURLOPT_SSL_CTX_FUNCTION
109               Callback for SSL context logic. See CURLOPT_SSL_CTX_FUNCTION(3)
110 
111        CURLOPT_SSL_CTX_DATA
112               Data pointer to pass to  the  SSL  context  callback.  See  CUR‐LOPT_SSL_CTX_DATA(3)
113 
114        CURLOPT_CONV_TO_NETWORK_FUNCTION
115               Callback  for  code  base  conversion.  See CURLOPT_CONV_TO_NET‐WORK_FUNCTION(3)
116 
117        CURLOPT_CONV_FROM_NETWORK_FUNCTION
118               Callback for code base  conversion.  See  CURLOPT_CONV_FROM_NET‐WORK_FUNCTION(3)
119 
120        CURLOPT_CONV_FROM_UTF8_FUNCTION
121               Callback     for     code     base    conversion.    See    CUR‐LOPT_CONV_FROM_UTF8_FUNCTION(3)
122 
123        CURLOPT_INTERLEAVEFUNCTION
124               Callback for RTSP interleaved data. See  CURLOPT_INTERLEAVEFUNC‐TION(3)
125 
126        CURLOPT_INTERLEAVEDATA
127               Data  pointer  to pass to the RTSP interleave callback. See CUR‐LOPT_INTERLEAVEDATA(3)
128 
129        CURLOPT_CHUNK_BGN_FUNCTION
130               Callback  for  wildcard  download  start  of  chunk.  See   CUR‐LOPT_CHUNK_BGN_FUNCTION(3)
131 
132        CURLOPT_CHUNK_END_FUNCTION
133               Callback   for   wildcard   download  end  of  chunk.  See  CUR‐LOPT_CHUNK_END_FUNCTION(3)
134 
135        CURLOPT_CHUNK_DATA
136               Data  pointer  to  pass  to  the  chunk  callbacks.   See   CUR‐LOPT_CHUNK_DATA(3)
137 
138        CURLOPT_FNMATCH_FUNCTION
139               Callback for wildcard matching. See CURLOPT_FNMATCH_FUNCTION(3)
140 
141        CURLOPT_FNMATCH_DATA
142               Data pointer to pass to the wildcard matching callback. See CUR‐LOPT_FNMATCH_DATA(3)
143 
144 ERROR OPTIONS
145        CURLOPT_ERRORBUFFER
146               Error message buffer. See CURLOPT_ERRORBUFFER(3)
147 
148        CURLOPT_STDERR
149               stderr replacement stream. See CURLOPT_STDERR(3)
150 
151        CURLOPT_FAILONERROR
152               Fail on HTTP 4xx errors. CURLOPT_FAILONERROR(3)
153 
154 NETWORK OPTIONS
155        CURLOPT_URL
156               URL to work on. See CURLOPT_URL(3)
157 
158        CURLOPT_PATH_AS_IS
159               Disable squashing /../ and /./ sequences in the path.  See  CUR‐LOPT_PATH_AS_IS(3)
160 
161        CURLOPT_PROTOCOLS
162               Allowed protocols. See CURLOPT_PROTOCOLS(3)
163 
164        CURLOPT_REDIR_PROTOCOLS
165               Protocols to allow redirects to. See CURLOPT_REDIR_PROTOCOLS(3)
166 
167        CURLOPT_DEFAULT_PROTOCOL
168               Default protocol. See CURLOPT_DEFAULT_PROTOCOL(3)
169 
170        CURLOPT_PROXY
171               Proxy to use. See CURLOPT_PROXY(3)
172 
173        CURLOPT_PROXYPORT
174               Proxy port to use. See CURLOPT_PROXYPORT(3)
175 
176        CURLOPT_PROXYTYPE
177               Proxy type. See CURLOPT_PROXYTYPE(3)
178 
179        CURLOPT_NOPROXY
180               Filter out hosts from proxy use. CURLOPT_NOPROXY(3)
181 
182        CURLOPT_HTTPPROXYTUNNEL
183               Tunnel through the HTTP proxy. CURLOPT_HTTPPROXYTUNNEL(3)
184 
185        CURLOPT_SOCKS5_GSSAPI_SERVICE
186               Socks5 GSSAPI service name. CURLOPT_SOCKS5_GSSAPI_SERVICE(3)
187 
188        CURLOPT_SOCKS5_GSSAPI_NEC
189               Socks5 GSSAPI NEC mode. See CURLOPT_SOCKS5_GSSAPI_NEC(3)
190 
191        CURLOPT_PROXY_SERVICE_NAME
192               Proxy service name. CURLOPT_PROXY_SERVICE_NAME(3)
193 
194        CURLOPT_SERVICE_NAME
195               SPNEGO service name. CURLOPT_SERVICE_NAME(3)
196 
197        CURLOPT_INTERFACE
198               Bind connection locally to this. See CURLOPT_INTERFACE(3)
199 
200        CURLOPT_LOCALPORT
201               Bind connection locally to this port. See CURLOPT_LOCALPORT(3)
202 
203        CURLOPT_LOCALPORTRANGE
204               Bind  connection  locally  to  port range. See CURLOPT_LOCALPOR‐TRANGE(3)
205 
206        CURLOPT_DNS_CACHE_TIMEOUT
207               Timeout for DNS cache. See CURLOPT_DNS_CACHE_TIMEOUT(3)
208 
209        CURLOPT_DNS_USE_GLOBAL_CACHE
210               OBSOLETE    Enable    global     DNS     cache.     See     CUR‐LOPT_DNS_USE_GLOBAL_CACHE(3)
211 
212        CURLOPT_BUFFERSIZE
213               Ask for smaller buffer size. See CURLOPT_BUFFERSIZE(3)
214 
215        CURLOPT_PORT
216               Port number to connect to. See CURLOPT_PORT(3)
217 
218        CURLOPT_TCP_NODELAY
219               Disable the Nagle algorithm. See CURLOPT_TCP_NODELAY(3)
220 
221        CURLOPT_ADDRESS_SCOPE
222               IPv6 scope for local addresses. See CURLOPT_ADDRESS_SCOPE(3)
223 
224        CURLOPT_TCP_KEEPALIVE
225               Enable TCP keep-alive. See CURLOPT_TCP_KEEPALIVE(3)
226 
227        CURLOPT_TCP_KEEPIDLE
228               Idle time before sending keep-alive. See CURLOPT_TCP_KEEPIDLE(3)
229 
230        CURLOPT_TCP_KEEPINTVL
231               Interval between keep-alive probes. See CURLOPT_TCP_KEEPINTVL(3)
232 
233        CURLOPT_UNIX_SOCKET_PATH
234               Path to a Unix domain socket. See CURLOPT_UNIX_SOCKET_PATH(3)
235 
236 NAMES and PASSWORDS OPTIONS (Authentication)
237        CURLOPT_NETRC
238               Enable .netrc parsing. See CURLOPT_NETRC(3)
239 
240        CURLOPT_NETRC_FILE
241               .netrc file name. See CURLOPT_NETRC_FILE(3)
242 
243        CURLOPT_USERPWD
244               User name and password. See CURLOPT_USERPWD(3)
245 
246        CURLOPT_PROXYUSERPWD
247               Proxy user name and password. See CURLOPT_PROXYUSERPWD(3)
248 
249        CURLOPT_USERNAME
250               User name. See CURLOPT_USERNAME(3)
251 
252        CURLOPT_PASSWORD
253               Password. See CURLOPT_PASSWORD(3)
254 
255        CURLOPT_LOGIN_OPTIONS
256               Login options. See CURLOPT_LOGIN_OPTIONS(3)
257 
258        CURLOPT_PROXYUSERNAME
259               Proxy user name. See CURLOPT_PROXYUSERNAME(3)
260 
261        CURLOPT_PROXYPASSWORD
262               Proxy password. See CURLOPT_PROXYPASSWORD(3)
263 
264        CURLOPT_HTTPAUTH
265               HTTP server authentication methods. See CURLOPT_HTTPAUTH(3)
266 
267        CURLOPT_TLSAUTH_USERNAME
268               TLS authentication user name. See CURLOPT_TLSAUTH_USERNAME(3)
269 
270        CURLOPT_TLSAUTH_PASSWORD
271               TLS authentication password. See CURLOPT_TLSAUTH_PASSWORD(3)
272 
273        CURLOPT_TLSAUTH_TYPE
274               TLS authentication methods. See CURLOPT_TLSAUTH_TYPE(3)
275 
276        CURLOPT_PROXYAUTH
277               HTTP proxy authentication methods. See CURLOPT_PROXYAUTH(3)
278 
279        CURLOPT_SASL_IR
280               Enable SASL initial response. See CURLOPT_SASL_IR(3)
281 
282        CURLOPT_XOAUTH2_BEARER
283               OAuth2 bearer token. See CURLOPT_XOAUTH2_BEARER(3)
284 
285 HTTP OPTIONS
286        CURLOPT_AUTOREFERER
287               Automatically set Referer: header. See CURLOPT_AUTOREFERER(3)
288 
289        CURLOPT_ACCEPT_ENCODING
290               Accept-Encoding  and  automatic  decompressing  data.  See  CUR‐LOPT_ACCEPT_ENCODING(3)
291 
292        CURLOPT_TRANSFER_ENCODING
293               Request Transfer-Encoding. See CURLOPT_TRANSFER_ENCODING(3)
294 
295        CURLOPT_FOLLOWLOCATION
296               Follow HTTP redirects. See CURLOPT_FOLLOWLOCATION(3)
297 
298        CURLOPT_UNRESTRICTED_AUTH
299               Do not restrict authentication to original  host.  CURLOPT_UNRE‐STRICTED_AUTH(3)
300 
301        CURLOPT_MAXREDIRS
302               Maximum number of redirects to follow. See CURLOPT_MAXREDIRS(3)
303 
304        CURLOPT_POSTREDIR
305               How to act on redirects after POST. See CURLOPT_POSTREDIR(3)
306 
307        CURLOPT_PUT
308               Issue a HTTP PUT request. See CURLOPT_PUT(3)
309 
310        CURLOPT_POST
311               Issue a HTTP POST request. See CURLOPT_POST(3)
312 
313        CURLOPT_POSTFIELDS
314               Send a POST with this data. See CURLOPT_POSTFIELDS(3)
315 
316        CURLOPT_POSTFIELDSIZE
317               The POST data is this big. See CURLOPT_POSTFIELDSIZE(3)
318 
319        CURLOPT_POSTFIELDSIZE_LARGE
320               The POST data is this big. See CURLOPT_POSTFIELDSIZE_LARGE(3)
321 
322        CURLOPT_COPYPOSTFIELDS
323               Send  a POST with this data - and copy it. See CURLOPT_COPYPOST‐FIELDS(3)
324 
325        CURLOPT_HTTPPOST
326               Multipart formpost HTTP POST. See CURLOPT_HTTPPOST(3)
327 
328        CURLOPT_REFERER
329               Referer: header. See CURLOPT_REFERER(3)
330 
331        CURLOPT_USERAGENT
332               User-Agent: header. See CURLOPT_USERAGENT(3)
333 
334        CURLOPT_HTTPHEADER
335               Custom HTTP headers. See CURLOPT_HTTPHEADER(3)
336 
337        CURLOPT_HEADEROPT
338               Control custom headers. See CURLOPT_HEADEROPT(3)
339 
340        CURLOPT_PROXYHEADER
341               Custom HTTP headers sent to proxy. See CURLOPT_PROXYHEADER(3)
342 
343        CURLOPT_HTTP200ALIASES
344               Alternative versions of 200 OK. See CURLOPT_HTTP200ALIASES(3)
345 
346        CURLOPT_COOKIE
347               Cookie(s) to send. See CURLOPT_COOKIE(3)
348 
349        CURLOPT_COOKIEFILE
350               File to read cookies from. See CURLOPT_COOKIEFILE(3)
351 
352        CURLOPT_COOKIEJAR
353               File to write cookies to. See CURLOPT_COOKIEJAR(3)
354 
355        CURLOPT_COOKIESESSION
356               Start a new cookie session. See CURLOPT_COOKIESESSION(3)
357 
358        CURLOPT_COOKIELIST
359               Add or control cookies. See CURLOPT_COOKIELIST(3)
360 
361        CURLOPT_HTTPGET
362               Do a HTTP GET request. See CURLOPT_HTTPGET(3)
363 
364        CURLOPT_HTTP_VERSION
365               HTTP version to use. CURLOPT_HTTP_VERSION(3)
366 
367        CURLOPT_IGNORE_CONTENT_LENGTH
368               Ignore Content-Length. See CURLOPT_IGNORE_CONTENT_LENGTH(3)
369 
370        CURLOPT_HTTP_CONTENT_DECODING
371               Disable Content decoding. See CURLOPT_HTTP_CONTENT_DECODING(3)
372 
373        CURLOPT_HTTP_TRANSFER_DECODING
374               Disable Transfer decoding. See CURLOPT_HTTP_TRANSFER_DECODING(3)
375 
376        CURLOPT_EXPECT_100_TIMEOUT_MS
377               100-continue timeout. See CURLOPT_EXPECT_100_TIMEOUT_MS(3)
378 
379        CURLOPT_PIPEWAIT
380               Wait on connection to pipeline on it. See CURLOPT_PIPEWAIT(3)
381 
382        CURLOPT_STREAM_DEPENDS
383               This   HTTP/2   stream   depends   on    another.    See    CUR‐LOPT_STREAM_DEPENDS(3)
384 
385        CURLOPT_STREAM_DEPENDS_E
386               This  HTTP/2  stream  depends  on  another exclusively. See CUR‐LOPT_STREAM_DEPENDS_E(3)
387 
388        CURLOPT_STREAM_WEIGHT
389               Set this HTTP/2 stream's weight. See CURLOPT_STREAM_WEIGHT(3)
390 
391 SMTP OPTIONS
392        CURLOPT_MAIL_FROM
393               Address of the sender. See CURLOPT_MAIL_FROM(3)
394 
395        CURLOPT_MAIL_RCPT
396               Address of the recipients. See CURLOPT_MAIL_RCPT(3)
397 
398        CURLOPT_MAIL_AUTH
399               Authentication address. See CURLOPT_MAIL_AUTH(3)
400 
401 TFTP OPTIONS
402        CURLOPT_TFTP_BLKSIZE
403               TFTP block size. See CURLOPT_TFTP_BLKSIZE(3)
404 
405 FTP OPTIONS
406        CURLOPT_FTPPORT
407               Use active FTP. See CURLOPT_FTPPORT(3)
408 
409        CURLOPT_QUOTE
410               Commands to run before transfer. See CURLOPT_QUOTE(3)
411 
412        CURLOPT_POSTQUOTE
413               Commands to run after transfer. See CURLOPT_POSTQUOTE(3)
414 
415        CURLOPT_PREQUOTE
416               Commands to run just before transfer. See CURLOPT_PREQUOTE(3)
417 
418        CURLOPT_APPEND
419               Append to remote file. See CURLOPT_APPEND(3)
420 
421        CURLOPT_FTP_USE_EPRT
422               Use EPTR. See CURLOPT_FTP_USE_EPRT(3)
423 
424        CURLOPT_FTP_USE_EPSV
425               Use EPSV. See CURLOPT_FTP_USE_EPSV(3)
426 
427        CURLOPT_FTP_USE_PRET
428               Use PRET. See CURLOPT_FTP_USE_PRET(3)
429 
430        CURLOPT_FTP_CREATE_MISSING_DIRS
431               Create missing  directories  on  the  remote  server.  See  CUR‐LOPT_FTP_CREATE_MISSING_DIRS(3)
432 
433        CURLOPT_FTP_RESPONSE_TIMEOUT
434               Timeout for FTP responses. See CURLOPT_FTP_RESPONSE_TIMEOUT(3)
435 
436        CURLOPT_FTP_ALTERNATIVE_TO_USER
437               Alternative to USER. See CURLOPT_FTP_ALTERNATIVE_TO_USER(3)
438 
439        CURLOPT_FTP_SKIP_PASV_IP
440               Ignore   the   IP   address  in  the  PASV  response.  See  CUR‐LOPT_FTP_SKIP_PASV_IP(3)
441 
442        CURLOPT_FTPSSLAUTH
443               Control how to do TLS. See CURLOPT_FTPSSLAUTH(3)
444 
445        CURLOPT_FTP_SSL_CCC
446               Back  to  non-TLS   again   after   authentication.   See   CUR‐LOPT_FTP_SSL_CCC(3)
447 
448        CURLOPT_FTP_ACCOUNT
449               Send ACCT command. See CURLOPT_FTP_ACCOUNT(3)
450 
451        CURLOPT_FTP_FILEMETHOD
452               Specify how to reach files. See CURLOPT_FTP_FILEMETHOD(3)
453 
454 RTSP OPTIONS
455        CURLOPT_RTSP_REQUEST
456               RTSP request. See CURLOPT_RTSP_REQUEST(3)
457 
458        CURLOPT_RTSP_SESSION_ID
459               RTSP session-id. See CURLOPT_RTSP_SESSION_ID(3)
460 
461        CURLOPT_RTSP_STREAM_URI
462               RTSP stream URI. See CURLOPT_RTSP_STREAM_URI(3)
463 
464        CURLOPT_RTSP_TRANSPORT
465               RTSP Transport: header. See CURLOPT_RTSP_TRANSPORT(3)
466 
467        CURLOPT_RTSP_CLIENT_CSEQ
468               Client CSEQ number. See CURLOPT_RTSP_CLIENT_CSEQ(3)
469 
470        CURLOPT_RTSP_SERVER_CSEQ
471               CSEQ   number   for   RTSP   Server->Client  request.  See  CUR‐LOPT_RTSP_SERVER_CSEQ(3)
472 
473 PROTOCOL OPTIONS
474        CURLOPT_TRANSFERTEXT
475               Use text transfer. See CURLOPT_TRANSFERTEXT(3)
476 
477        CURLOPT_PROXY_TRANSFER_MODE
478               Add transfer mode to URL over  proxy.  See  CURLOPT_PROXY_TRANS‐FER_MODE(3)
479 
480        CURLOPT_CRLF
481               Convert newlines. See CURLOPT_CRLF(3)
482 
483        CURLOPT_RANGE
484               Range requests. See CURLOPT_RANGE(3)
485 
486        CURLOPT_RESUME_FROM
487               Resume a transfer. See CURLOPT_RESUME_FROM(3)
488 
489        CURLOPT_RESUME_FROM_LARGE
490               Resume a transfer. See CURLOPT_RESUME_FROM_LARGE(3)
491 
492        CURLOPT_CUSTOMREQUEST
493               Custom request/method. See CURLOPT_CUSTOMREQUEST(3)
494 
495        CURLOPT_FILETIME
496               Request file modification date and time. See CURLOPT_FILETIME(3)
497 
498        CURLOPT_DIRLISTONLY
499               List only. See CURLOPT_DIRLISTONLY(3)
500 
501        CURLOPT_NOBODY
502               Do not get the body contents. See CURLOPT_NOBODY(3)
503 
504        CURLOPT_INFILESIZE
505               Size of file to send. CURLOPT_INFILESIZE(3)
506 
507        CURLOPT_INFILESIZE_LARGE
508               Size of file to send. CURLOPT_INFILESIZE_LARGE(3)
509 
510        CURLOPT_UPLOAD
511               Upload data. See CURLOPT_UPLOAD(3)
512 
513        CURLOPT_MAXFILESIZE
514               Maximum file size to get. See CURLOPT_MAXFILESIZE(3)
515 
516        CURLOPT_MAXFILESIZE_LARGE
517               Maximum file size to get. See CURLOPT_MAXFILESIZE_LARGE(3)
518 
519        CURLOPT_TIMECONDITION
520               Make a time conditional request. See CURLOPT_TIMECONDITION(3)
521 
522        CURLOPT_TIMEVALUE
523               Time   value   for   the  time  conditional  request.  See  CUR‐
524               LOPT_TIMEVALUE(3)
525 
526 CONNECTION OPTIONS
527        CURLOPT_TIMEOUT
528               Timeout for the entire request. See CURLOPT_TIMEOUT(3)
529 
530        CURLOPT_TIMEOUT_MS
531               Millisecond timeout for the entire  request.  See  CURLOPT_TIME‐OUT_MS(3)
532 
533        CURLOPT_LOW_SPEED_LIMIT
534               Low    speed    limit    to    abort    transfer.    See    CUR‐LOPT_LOW_SPEED_LIMIT(3)
535 
536        CURLOPT_LOW_SPEED_TIME
537               Time to be below the speed to trigger low speed abort. See  CUR‐LOPT_LOW_SPEED_TIME(3)
538 
539        CURLOPT_MAX_SEND_SPEED_LARGE
540               Cap     the     upload     speed     to     this.    See    CUR‐LOPT_MAX_SEND_SPEED_LARGE(3)
541 
542        CURLOPT_MAX_RECV_SPEED_LARGE
543               Cap    the    download    speed    to     this.     See     CUR‐LOPT_MAX_RECV_SPEED_LARGE(3)
544 
545        CURLOPT_MAXCONNECTS
546               Maximum  number  of connections in the connection pool. See CUR‐LOPT_MAXCONNECTS(3)
547 
548        CURLOPT_FRESH_CONNECT
549               Use a new connection. CURLOPT_FRESH_CONNECT(3)
550 
551        CURLOPT_FORBID_REUSE
552               Prevent subsequent connections  from  re-using  this.  See  CUR‐LOPT_FORBID_REUSE(3)
553 
554        CURLOPT_CONNECTTIMEOUT
555               Timeout for the connection phase. See CURLOPT_CONNECTTIMEOUT(3)
556 
557        CURLOPT_CONNECTTIMEOUT_MS
558               Millisecond  timeout  for the connection phase. See CURLOPT_CON‐NECTTIMEOUT_MS(3)
559 
560        CURLOPT_IPRESOLVE
561               IP version to resolve to. See CURLOPT_IPRESOLVE(3)
562 
563        CURLOPT_CONNECT_ONLY
564               Only connect, nothing else. See CURLOPT_CONNECT_ONLY(3)
565 
566        CURLOPT_USE_SSL
567               Use TLS/SSL. See CURLOPT_USE_SSL(3)
568 
569        CURLOPT_RESOLVE
570               Provide fixed/fake name resolves. See CURLOPT_RESOLVE(3)
571 
572        CURLOPT_DNS_INTERFACE
573               Bind name resolves to  this  interface.  See  CURLOPT_DNS_INTER‐FACE(3)
574 
575        CURLOPT_DNS_LOCAL_IP4
576               Bind   name   resolves   to   this   IP4   address.   See   CUR‐LOPT_DNS_LOCAL_IP4(3)
577 
578        CURLOPT_DNS_LOCAL_IP6
579               Bind   name   resolves   to   this   IP6   address.   See   CUR‐LOPT_DNS_LOCAL_IP6(3)
580 
581        CURLOPT_DNS_SERVERS
582               Preferred DNS servers. See CURLOPT_DNS_SERVERS(3)
583 
584        CURLOPT_ACCEPTTIMEOUT_MS
585               Timeout  for  waiting  for  the  server's  connect  back  to  be
586               accepted. See CURLOPT_ACCEPTTIMEOUT_MS(3)
587 
588 SSL and SECURITY OPTIONS
589        CURLOPT_SSLCERT
590               Client cert. See CURLOPT_SSLCERT(3)
591 
592        CURLOPT_SSLCERTTYPE
593               Client cert type.  See CURLOPT_SSLCERTTYPE(3)
594 
595        CURLOPT_SSLKEY
596               Client key. See CURLOPT_SSLKEY(3)
597 
598        CURLOPT_SSLKEYTYPE
599               Client key type. See CURLOPT_SSLKEYTYPE(3)
600 
601        CURLOPT_KEYPASSWD
602               Client key password. See CURLOPT_KEYPASSWD(3)
603 
604        CURLOPT_SSL_ENABLE_ALPN
605               Enable use of ALPN. See CURLOPT_SSL_ENABLE_ALPN(3)
606 
607        CURLOPT_SSL_ENABLE_NPN
608               Enable use of NPN. See CURLOPT_SSL_ENABLE_NPN(3)
609 
610        CURLOPT_SSLENGINE
611               Use identifier with SSL engine. See CURLOPT_SSLENGINE(3)
612 
613        CURLOPT_SSLENGINE_DEFAULT
614               Default SSL engine. See CURLOPT_SSLENGINE_DEFAULT(3)
615 
616        CURLOPT_SSL_FALSESTART
617               Enable TLS False Start. See CURLOPT_SSL_FALSESTART(3)
618 
619        CURLOPT_SSLVERSION
620               SSL version to use. See CURLOPT_SSLVERSION(3)
621 
622        CURLOPT_SSL_VERIFYHOST
623               Verify  the  host  name  in  the  SSL  certificate.   See   CUR‐LOPT_SSL_VERIFYHOST(3)
624 
625        CURLOPT_SSL_VERIFYPEER
626               Verify the SSL certificate. See CURLOPT_SSL_VERIFYPEER(3)
627 
628        CURLOPT_SSL_VERIFYSTATUS
629               Verify  the SSL certificate's status. See CURLOPT_SSL_VERIFYSTA‐TUS(3)
630 
631        CURLOPT_CAINFO
632               CA cert bundle. See CURLOPT_CAINFO(3)
633 
634        CURLOPT_ISSUERCERT
635               Issuer certificate. See CURLOPT_ISSUERCERT(3)
636 
637        CURLOPT_CAPATH
638               Path to CA cert bundle. See CURLOPT_CAPATH(3)
639 
640        CURLOPT_CRLFILE
641               Certificate Revocation List. See CURLOPT_CRLFILE(3)
642 
643        CURLOPT_CERTINFO
644               Extract certificate info. See CURLOPT_CERTINFO(3)
645 
646        CURLOPT_PINNEDPUBLICKEY
647               Set pinned SSL public key . See CURLOPT_PINNEDPUBLICKEY(3)
648 
649        CURLOPT_RANDOM_FILE
650               Provide  source  for  entropy  random  data.  See   CURLOPT_RAN‐DOM_FILE(3)
651 
652        CURLOPT_EGDSOCKET
653               Identify EGD socket for entropy. See CURLOPT_EGDSOCKET(3)
654 
655        CURLOPT_SSL_CIPHER_LIST
656               Ciphers to use. See CURLOPT_SSL_CIPHER_LIST(3)
657 
658        CURLOPT_SSL_SESSIONID_CACHE
659               Disable SSL session-id cache. See CURLOPT_SSL_SESSIONID_CACHE(3)
660 
661        CURLOPT_SSL_OPTIONS
662               Control SSL behavior. See CURLOPT_SSL_OPTIONS(3)
663 
664        CURLOPT_KRBLEVEL
665               Kerberos security level. See CURLOPT_KRBLEVEL(3)
666 
667        CURLOPT_GSSAPI_DELEGATION
668               Disable GSS-API delegation. See CURLOPT_GSSAPI_DELEGATION(3)
669 
670 SSH OPTIONS
671        CURLOPT_SSH_AUTH_TYPES
672               SSH authentication types. See CURLOPT_SSH_AUTH_TYPES(3)
673 
674        CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
675               MD5 of host's public key. See CURLOPT_SSH_HOST_PUBLIC_KEY_MD5(3)
676 
677        CURLOPT_SSH_PUBLIC_KEYFILE
678               File name of public key. See CURLOPT_SSH_PUBLIC_KEYFILE(3)
679 
680        CURLOPT_SSH_PRIVATE_KEYFILE
681               File name of private key. See CURLOPT_SSH_PRIVATE_KEYFILE(3)
682 
683        CURLOPT_SSH_KNOWNHOSTS
684               File name with known hosts. See CURLOPT_SSH_KNOWNHOSTS(3)
685 
686        CURLOPT_SSH_KEYFUNCTION
687               Callback  for  known  hosts  handling.  See CURLOPT_SSH_KEYFUNC‐TION(3)
688 
689        CURLOPT_SSH_KEYDATA
690               Custom pointer to pass to ssh key callback. See CURLOPT_SSH_KEY‐DATA(3)
691 
692 OTHER OPTIONS
693        CURLOPT_PRIVATE
694               Private pointer to store. See CURLOPT_PRIVATE(3)
695 
696        CURLOPT_SHARE
697               Share object to use. See CURLOPT_SHARE(3)
698 
699        CURLOPT_NEW_FILE_PERMS
700               Mode    for    creating    new    remote    files.    See   CUR‐LOPT_NEW_FILE_PERMS(3)
701 
702        CURLOPT_NEW_DIRECTORY_PERMS
703               Mode for creating new remote directories. See CURLOPT_NEW_DIREC‐TORY_PERMS(3)
704 
705 TELNET OPTIONS
706        CURLOPT_TELNETOPTIONS
707               TELNET options. See CURLOPT_TELNETOPTIONS(3)
708 
709 RETURN VALUE
710        CURLE_OK  (zero) means that the option was set properly, non-zero means an error occurred as <curl/curl.h> defines. See  the  libcurl-errors(3) man page for the full list with descriptions.
711 
712        If  you  try  to set an option that libcurl doesn't know about, perhaps because the library is too old to support it or the option was  removed in a recent version, this function will return CURLE_UNKNOWN_OPTION. If support for the option was disabled at  compile-time,  it  will  return CURLE_NOT_BUILT_IN.
713 
714 EXAMPLE
715        CURL *curl = curl_easy_init();
716        if(curl) {
717          CURLcode res;
718          curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
719          res = curl_easy_perform(curl);
720          curl_easy_cleanup(curl);
721        }
722 
723 SEE ALSO
724        curl_easy_init(3),   curl_easy_cleanup(3),  curl_easy_reset(3),   curl_easy_getinfo(3), curl_multi_setopt(3),
725 
726 libcurl 7.38.0                    25 Jun 2014               curl_easy_setopt(3)

 

要使用CURL发送JSON数据到服务器,你可以按照以下步骤操作: 1. 初始化CURL会话: ```c++ CURL *pCurlHandle = curl_easy_init(); // 创建一个新的CURL会话 if (pCurlHandle) { // ... } else { // 处理初始化失败的情况 } ``` 2. 设置URL: ```c++ std::string url = "http://example.com/api/upload"; // 替换成实际的URL curl_easy_setopt(pCurlHandle, CURLOPT_URL, url.c_str()); ``` 3. 设置HTTP方法(通常是POST): ```c++ curl_easy_setopt(pCurlHandle, CURLOPT_POST, 1L); ``` 4. 添加JSON数据作为POST体: ```c++ // 假设我们有一个名为`jsonData`的JSON字符串 char* jsonPostData = strdup(jsonData.c_str()); // JSON字符串转化为C字符串 curl_easy_setopt(pCurlHandle, CURLOPT_POSTFIELDS, jsonPostData); ``` 5. 设置超时时间: ```c++ (void)curl_easy_setopt(pCurlHandle, CURLOPT_TIMEOUT, 30L); // 如果有超时限制,如引用[2]所示 ``` 6. 可选: 设置HTTP头,比如Content-Type(通常用于表示POST的数据类型为JSON): ```c++ char* contentType = "application/json"; curl_easy_setopt(pCurlHandle, CURLOPT_HTTPHEADER, (char*[]) {"Content-Type: " + contentType, NULL}); ``` 7. 启动请求并接收结果: ```c++ int responseCode; CURLcode res = curl_easy_perform(pCurlHandle); // 发送请求 if (res == CURLE_OK) { // 检查执行状态 responseCode = curl_easy_getinfo(pCurlHandle, CURLINFO_RESPONSE_CODE, &responseCode); // 处理响应数据 } else { // 处理错误情况 } curl_easy_cleanup(pCurlHandle); // 关闭CURL会话 free(jsonPostData); // 释放内存 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值