NAME
curl_easy_setopt - set options for a curl easy handle
SYNOPSIS
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);
DESCRIPTION
curl_easy_setopt 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 parameter 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 application uses many curl_easy_setopt calls in the setup phase.
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 different options, you must change them between the transfers. You can optionally reset all options back to internal default with curl_easy_reset.
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 returns. The only exception to this rule is really CURLOPT_POSTFIELDS, but the alternative that copies the string CURLOPT_COPYPOSTFIELDShas some usage characteristics you need to read up on.
The order in which the options are set does not matter.
Before version 7.17.0, strings were not copied. Instead the user was forced keep them available until libcurl no longer needed them.
The handle is the return code from a curl_easy_init or curl_easy_duphandle call.
BEHAVIOR OPTIONS
Display verbose information. See CURLOPT_VERBOSE
Include the header in the body output. See CURLOPT_HEADER
Shut off the progress meter. See CURLOPT_NOPROGRESS
Do not install signal handlers. See CURLOPT_NOSIGNAL
Transfer multiple files according to a file name pattern. See CURLOPT_WILDCARDMATCH
CALLBACK OPTIONS
Callback for writing data. See CURLOPT_WRITEFUNCTION
Data pointer to pass to the write callback. See CURLOPT_WRITEDATA
Callback for reading data. See CURLOPT_READFUNCTION
Data pointer to pass to the read callback. See CURLOPT_READDATA
Callback for I/O operations. See CURLOPT_IOCTLFUNCTION
Data pointer to pass to the I/O callback. See CURLOPT_IOCTLDATA
Callback for seek operations. See CURLOPT_SEEKFUNCTION
Data pointer to pass to the seek callback. See CURLOPT_SEEKDATA
Callback for sockopt operations. See CURLOPT_SOCKOPTFUNCTION
Data pointer to pass to the sockopt callback. See CURLOPT_SOCKOPTDATA
Callback for socket creation. See CURLOPT_OPENSOCKETFUNCTION
Data pointer to pass to the open socket callback. See CURLOPT_OPENSOCKETDATA
Callback for closing socket. See CURLOPT_CLOSESOCKETFUNCTION
Data pointer to pass to the close socket callback. See CURLOPT_CLOSESOCKETDATA
OBSOLETE callback for progress meter. See CURLOPT_PROGRESSFUNCTION
Data pointer to pass to the progress meter callback. See CURLOPT_PROGRESSDATA
Callback for progress meter. See CURLOPT_XFERINFOFUNCTION
Data pointer to pass to the progress meter callback. See CURLOPT_XFERINFODATA
Callback for writing received headers. See CURLOPT_HEADERFUNCTION
Data pointer to pass to the header callback. See CURLOPT_HEADERDATA
Callback for debug information. See CURLOPT_DEBUGFUNCTION
Data pointer to pass to the debug callback. See CURLOPT_DEBUGDATA
Callback for SSL context logic. See CURLOPT_SSL_CTX_FUNCTION
Data pointer to pass to the SSL context callback. See CURLOPT_SSL_CTX_DATA
CURLOPT_CONV_TO_NETWORK_FUNCTION
Callback for code base conversion. See CURLOPT_CONV_TO_NETWORK_FUNCTION
CURLOPT_CONV_FROM_NETWORK_FUNCTION
Callback for code base conversion. See CURLOPT_CONV_FROM_NETWORK_FUNCTION
CURLOPT_CONV_FROM_UTF8_FUNCTION
Callback for code base conversion. See CURLOPT_CONV_FROM_UTF8_FUNCTION
Callback for RTSP interleaved data. See CURLOPT_INTERLEAVEFUNCTION
Data pointer to pass to the RTSP interleave callback. See CURLOPT_INTERLEAVEDATA
Callback for wildcard download start of chunk. See CURLOPT_CHUNK_BGN_FUNCTION
Callback for wildcard download end of chunk. See CURLOPT_CHUNK_END_FUNCTION
Data pointer to pass to the chunk callbacks. See CURLOPT_CHUNK_DATA
Callback for wildcard matching. See CURLOPT_FNMATCH_FUNCTION
Data pointer to pass to the wildcard matching callback. See CURLOPT_FNMATCH_DATA
ERROR OPTIONS
Error message buffer. See CURLOPT_ERRORBUFFER
stderr replacement stream. See CURLOPT_STDERR
Fail on HTTP 4xx errors. CURLOPT_FAILONERROR
NETWORK OPTIONS
URL to work on. See CURLOPT_URL
Disable squashing /../ and /./ sequences in the path. See CURLOPT_PATH_AS_IS
Allowed protocols. See CURLOPT_PROTOCOLS
Protocols to allow redirects to. See CURLOPT_REDIR_PROTOCOLS
Default protocol. See CURLOPT_DEFAULT_PROTOCOL
Proxy to use. See CURLOPT_PROXY
Proxy port to use. See CURLOPT_PROXYPORT
Proxy type. See CURLOPT_PROXYTYPE
Filter out hosts from proxy use. CURLOPT_NOPROXY
Tunnel through the HTTP proxy. CURLOPT_HTTPPROXYTUNNEL
Socks5 GSSAPI service name. CURLOPT_SOCKS5_GSSAPI_SERVICE
Socks5 GSSAPI NEC mode. See CURLOPT_SOCKS5_GSSAPI_NEC
Proxy service name. CURLOPT_PROXY_SERVICE_NAME
SPNEGO service name. CURLOPT_SERVICE_NAME
Bind connection locally to this. See CURLOPT_INTERFACE
Bind connection locally to this port. See CURLOPT_LOCALPORT
Bind connection locally to port range. See CURLOPT_LOCALPORTRANGE
Timeout for DNS cache. See CURLOPT_DNS_CACHE_TIMEOUT
OBSOLETE Enable global DNS cache. See CURLOPT_DNS_USE_GLOBAL_CACHE
Ask for smaller buffer size. See CURLOPT_BUFFERSIZE
Port number to connect to. See CURLOPT_PORT
Disable the Nagle algorithm. See CURLOPT_TCP_NODELAY
IPv6 scope for local addresses. See CURLOPT_ADDRESS_SCOPE
Enable TCP keep-alive. See CURLOPT_TCP_KEEPALIVE
Idle time before sending keep-alive. See CURLOPT_TCP_KEEPIDLE
Interval between keep-alive probes. See CURLOPT_TCP_KEEPINTVL
Path to a Unix domain socket. See CURLOPT_UNIX_SOCKET_PATH
NAMES and PASSWORDS OPTIONS (Authentication)
Enable .netrc parsing. See CURLOPT_NETRC
.netrc file name. See CURLOPT_NETRC_FILE
User name and password. See CURLOPT_USERPWD
Proxy user name and password. See CURLOPT_PROXYUSERPWD
User name. See CURLOPT_USERNAME
Password. See CURLOPT_PASSWORD
Login options. See CURLOPT_LOGIN_OPTIONS
Proxy user name. See CURLOPT_PROXYUSERNAME
Proxy password. See CURLOPT_PROXYPASSWORD
HTTP server authentication methods. See CURLOPT_HTTPAUTH
TLS authentication user name. See CURLOPT_TLSAUTH_USERNAME
TLS authentication password. See CURLOPT_TLSAUTH_PASSWORD
TLS authentication methods. See CURLOPT_TLSAUTH_TYPE
HTTP proxy authentication methods. See CURLOPT_PROXYAUTH
Enable SASL initial response. See CURLOPT_SASL_IR
OAuth2 bearer token. See CURLOPT_XOAUTH2_BEARER
HTTP OPTIONS
Automatically set Referer: header. See CURLOPT_AUTOREFERER
Accept-Encoding and automatic decompressing data. See CURLOPT_ACCEPT_ENCODING
Request Transfer-Encoding. See CURLOPT_TRANSFER_ENCODING
Follow HTTP redirects. See CURLOPT_FOLLOWLOCATION
Do not restrict authentication to original host. CURLOPT_UNRESTRICTED_AUTH
Maximum number of redirects to follow. See CURLOPT_MAXREDIRS
How to act on redirects after POST. See CURLOPT_POSTREDIR
Issue a HTTP PUT request. See CURLOPT_PUT
Issue a HTTP POST request. See CURLOPT_POST
Send a POST with this data. See CURLOPT_POSTFIELDS
The POST data is this big. See CURLOPT_POSTFIELDSIZE
The POST data is this big. See CURLOPT_POSTFIELDSIZE_LARGE
Send a POST with this data - and copy it. See CURLOPT_COPYPOSTFIELDS
Multipart formpost HTTP POST. See CURLOPT_HTTPPOST
Referer: header. See CURLOPT_REFERER
User-Agent: header. See CURLOPT_USERAGENT
Custom HTTP headers. See CURLOPT_HTTPHEADER
Control custom headers. See CURLOPT_HEADEROPT
Custom HTTP headers sent to proxy. See CURLOPT_PROXYHEADER
Alternative versions of 200 OK. See CURLOPT_HTTP200ALIASES
Cookie(s) to send. See CURLOPT_COOKIE
File to read cookies from. See CURLOPT_COOKIEFILE
File to write cookies to. See CURLOPT_COOKIEJAR
Start a new cookie session. See CURLOPT_COOKIESESSION
Add or control cookies. See CURLOPT_COOKIELIST
Do a HTTP GET request. See CURLOPT_HTTPGET
HTTP version to use. CURLOPT_HTTP_VERSION
Ignore Content-Length. See CURLOPT_IGNORE_CONTENT_LENGTH
Disable Content decoding. See CURLOPT_HTTP_CONTENT_DECODING
CURLOPT_HTTP_TRANSFER_DECODING
Disable Transfer decoding. See CURLOPT_HTTP_TRANSFER_DECODING
100-continue timeout. See CURLOPT_EXPECT_100_TIMEOUT_MS
Wait on connection to pipeline on it. See CURLOPT_PIPEWAIT
SMTP OPTIONS
Address of the sender. See CURLOPT_MAIL_FROM
Address of the recipients. See CURLOPT_MAIL_RCPT
Authentication address. See CURLOPT_MAIL_AUTH
TFTP OPTIONS
TFTP block size. See CURLOPT_TFTP_BLKSIZE
FTP OPTIONS
Use active FTP. See CURLOPT_FTPPORT
Commands to run before transfer. See CURLOPT_QUOTE
Commands to run after transfer. See CURLOPT_POSTQUOTE
Commands to run just before transfer. See CURLOPT_PREQUOTE
Append to remote file. See CURLOPT_APPEND
Use EPTR. See CURLOPT_FTP_USE_EPRT
Use EPSV. See CURLOPT_FTP_USE_EPSV
Use PRET. See CURLOPT_FTP_USE_PRET
CURLOPT_FTP_CREATE_MISSING_DIRS
Create missing directories on the remote server. See CURLOPT_FTP_CREATE_MISSING_DIRS
Timeout for FTP responses. See CURLOPT_FTP_RESPONSE_TIMEOUT
CURLOPT_FTP_ALTERNATIVE_TO_USER
Alternative to USER. See CURLOPT_FTP_ALTERNATIVE_TO_USER
Ignore the IP address in the PASV response. See CURLOPT_FTP_SKIP_PASV_IP
Control how to do TLS. See CURLOPT_FTPSSLAUTH
Back to non-TLS again after authentication. See CURLOPT_FTP_SSL_CCC
Send ACCT command. See CURLOPT_FTP_ACCOUNT
Specify how to reach files. See CURLOPT_FTP_FILEMETHOD
RTSP OPTIONS
RTSP request. See CURLOPT_RTSP_REQUEST
RTSP session-id. See CURLOPT_RTSP_SESSION_ID
RTSP stream URI. See CURLOPT_RTSP_STREAM_URI
RTSP Transport: header. See CURLOPT_RTSP_TRANSPORT
Client CSEQ number. See CURLOPT_RTSP_CLIENT_CSEQ
CSEQ number for RTSP Server->Client request. See CURLOPT_RTSP_SERVER_CSEQ
PROTOCOL OPTIONS
Use text transfer. See CURLOPT_TRANSFERTEXT
Add transfer mode to URL over proxy. See CURLOPT_PROXY_TRANSFER_MODE
Convert newlines. See CURLOPT_CRLF
Range requests. See CURLOPT_RANGE
Resume a transfer. See CURLOPT_RESUME_FROM
Resume a transfer. See CURLOPT_RESUME_FROM_LARGE
Custom request/method. See CURLOPT_CUSTOMREQUEST
Request file modification date and time. See CURLOPT_FILETIME
List only. See CURLOPT_DIRLISTONLY
Do not get the body contents. See CURLOPT_NOBODY
Size of file to send. CURLOPT_INFILESIZE
Size of file to send. CURLOPT_INFILESIZE_LARGE
Upload data. See CURLOPT_UPLOAD
Maximum file size to get. See CURLOPT_MAXFILESIZE
Maximum file size to get. See CURLOPT_MAXFILESIZE_LARGE
Make a time conditional request. See CURLOPT_TIMECONDITION
Time value for the time conditional request. See CURLOPT_TIMEVALUE
CONNECTION OPTIONS
Timeout for the entire request. See CURLOPT_TIMEOUT
Millisecond timeout for the entire request. See CURLOPT_TIMEOUT_MS
Low speed limit to abort transfer. See CURLOPT_LOW_SPEED_LIMIT
Time to be below the speed to trigger low speed abort. See CURLOPT_LOW_SPEED_TIME
Cap the upload speed to this. See CURLOPT_MAX_SEND_SPEED_LARGE
Cap the download speed to this. See CURLOPT_MAX_RECV_SPEED_LARGE
Maximum number of connections in the connection pool. See CURLOPT_MAXCONNECTS
Use a new connection. CURLOPT_FRESH_CONNECT
Prevent subsequent connections from re-using this. See CURLOPT_FORBID_REUSE
Timeout for the connection phase. See CURLOPT_CONNECTTIMEOUT
Millisecond timeout for the connection phase. See CURLOPT_CONNECTTIMEOUT_MS
IP version to resolve to. See CURLOPT_IPRESOLVE
Only connect, nothing else. See CURLOPT_CONNECT_ONLY
Use TLS/SSL. See CURLOPT_USE_SSL
Provide fixed/fake name resolves. See CURLOPT_RESOLVE
Bind name resolves to this interface. See CURLOPT_DNS_INTERFACE
Bind name resolves to this IP4 address. See CURLOPT_DNS_LOCAL_IP4
Bind name resolves to this IP6 address. See CURLOPT_DNS_LOCAL_IP6
Preferred DNS servers. See CURLOPT_DNS_SERVERS
Timeout for waiting for the server's connect back to be accepted. SeeCURLOPT_ACCEPTTIMEOUT_MS
SSL and SECURITY OPTIONS
Client cert. See CURLOPT_SSLCERT
Client cert type. See CURLOPT_SSLCERTTYPE
Client key. See CURLOPT_SSLKEY
Client key type. See CURLOPT_SSLKEYTYPE
Client key password. See CURLOPT_KEYPASSWD
Enable use of ALPN. See CURLOPT_SSL_ENABLE_ALPN
Enable use of NPN. See CURLOPT_SSL_ENABLE_NPN
Use identifier with SSL engine. See CURLOPT_SSLENGINE
Default SSL engine. See CURLOPT_SSLENGINE_DEFAULT
Enable TLS False Start. See CURLOPT_SSL_FALSESTART
SSL version to use. See CURLOPT_SSLVERSION
Verify the host name in the SSL certificate. See CURLOPT_SSL_VERIFYHOST
Verify the SSL certificate. See CURLOPT_SSL_VERIFYPEER
Verify the SSL certificate's status. See CURLOPT_SSL_VERIFYSTATUS
CA cert bundle. See CURLOPT_CAINFO
Issuer certificate. See CURLOPT_ISSUERCERT
Path to CA cert bundle. See CURLOPT_CAPATH
Certificate Revocation List. See CURLOPT_CRLFILE
Extract certificate info. See CURLOPT_CERTINFO
Set pinned SSL public key . See CURLOPT_PINNEDPUBLICKEY
Provide source for entropy random data. See CURLOPT_RANDOM_FILE
Identify EGD socket for entropy. See CURLOPT_EGDSOCKET
Ciphers to use. See CURLOPT_SSL_CIPHER_LIST
Disable SSL session-id cache. See CURLOPT_SSL_SESSIONID_CACHE
Control SSL behavior. See CURLOPT_SSL_OPTIONS
Kerberos security level. See CURLOPT_KRBLEVEL
Disable GSS-API delegation. See CURLOPT_GSSAPI_DELEGATION
SSH OPTIONS
SSH authentication types. See CURLOPT_SSH_AUTH_TYPES
CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
MD5 of host's public key. See CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
File name of public key. See CURLOPT_SSH_PUBLIC_KEYFILE
File name of private key. See CURLOPT_SSH_PRIVATE_KEYFILE
File name with known hosts. See CURLOPT_SSH_KNOWNHOSTS
Callback for known hosts handling. See CURLOPT_SSH_KEYFUNCTION
Custom pointer to pass to ssh key callback. See CURLOPT_SSH_KEYDATA
OTHER OPTIONS
Private pointer to store. See CURLOPT_PRIVATE
Share object to use. See CURLOPT_SHARE
Mode for creating new remote files. See CURLOPT_NEW_FILE_PERMS
Mode for creating new remote directories. See CURLOPT_NEW_DIRECTORY_PERMS
TELNET OPTIONS
TELNET options. See CURLOPT_TELNETOPTIONS
RETURN VALUE
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 man page for the full list with descriptions.
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.
EXAMPLE
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); }
SEE ALSO
curl_easy_init, curl_easy_cleanup, curl_easy_reset, curl_easy_getinfo, curl_multi_setopt
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html