Default cURL option values
Code to get the CURLOPT
configuration options you will want to edit:
foreach (get_defined_constants() as $key => $val) {
if (strpos($key, 'CURLOPT_') === 0) {
echo $key . ' => ' . $val . "\n";
}
}
Following are the default PHP CURL settings on my installation of PHP 5.6.30 on CentOS 7:
CURLOPT_AUTOREFERER
58CURLOPT_BINARYTRANSFER
19914CURLOPT_BUFFERSIZE
98CURLOPT_CAINFO
10065CURLOPT_CAPATH
10097CURLOPT_CONNECTTIMEOUT
78CURLOPT_COOKIE
10022CURLOPT_COOKIEFILE
10031CURLOPT_COOKIEJAR
10082CURLOPT_COOKIESESSION
96CURLOPT_CRLF
27CURLOPT_CUSTOMREQUEST
10036CURLOPT_DNS_CACHE_TIMEOUT
92CURLOPT_DNS_USE_GLOBAL_CACHE
91CURLOPT_EGDSOCKET
10077CURLOPT_ENCODING
10102CURLOPT_FAILONERROR
45CURLOPT_FILE
10001CURLOPT_FILETIME
69CURLOPT_FOLLOWLOCATION
52CURLOPT_FORBID_REUSE
75CURLOPT_FRESH_CONNECT
74CURLOPT_FTPAPPEND
50CURLOPT_FTPLISTONLY
48CURLOPT_FTPPORT
10017CURLOPT_FTP_USE_EPRT
106CURLOPT_FTP_USE_EPSV
85CURLOPT_HEADER
42CURLOPT_HEADERFUNCTION
20079CURLOPT_HTTP200ALIASES
10104CURLOPT_HTTPGET
80CURLOPT_HTTPHEADER
10023CURLOPT_HTTPPROXYTUNNEL
61CURLOPT_HTTP_VERSION
84CURLOPT_INFILE
10009CURLOPT_INFILESIZE
14CURLOPT_INTERFACE
10062CURLOPT_KRB4LEVEL
10063CURLOPT_LOW_SPEED_LIMIT
19CURLOPT_LOW_SPEED_TIME
20CURLOPT_MAXCONNECTS
71CURLOPT_MAXREDIRS
68CURLOPT_NETRC
51CURLOPT_NOBODY
44CURLOPT_NOPROGRESS
43CURLOPT_NOSIGNAL
99CURLOPT_PORT
3CURLOPT_POST
47CURLOPT_POSTFIELDS
10015CURLOPT_POSTQUOTE
10039CURLOPT_PREQUOTE
10093CURLOPT_PRIVATE
10103CURLOPT_PROGRESSFUNCTION
20056CURLOPT_PROXY
10004CURLOPT_PROXYPORT
59CURLOPT_PROXYTYPE
101CURLOPT_PROXYUSERPWD
10006CURLOPT_PUT
54CURLOPT_QUOTE
10028CURLOPT_RANDOM_FILE
10076CURLOPT_RANGE
10007CURLOPT_READDATA
10009CURLOPT_READFUNCTION
20012CURLOPT_REFERER
10016CURLOPT_RESUME_FROM
21CURLOPT_RETURNTRANSFER
19913CURLOPT_SHARE
10100CURLOPT_SSLCERT
10025CURLOPT_SSLCERTPASSWD
10026CURLOPT_SSLCERTTYPE
10086CURLOPT_SSLENGINE
10089CURLOPT_SSLENGINE_DEFAULT
90CURLOPT_SSLKEY
10087CURLOPT_SSLKEYPASSWD
10026CURLOPT_SSLKEYTYPE
10088CURLOPT_SSLVERSION
32CURLOPT_SSL_CIPHER_LIST
10083CURLOPT_SSL_VERIFYHOST
81CURLOPT_SSL_VERIFYPEER
64CURLOPT_STDERR
10037CURLOPT_TELNETOPTIONS
10070CURLOPT_TIMECONDITION
33CURLOPT_TIMEOUT
13CURLOPT_TIMEVALUE
34CURLOPT_TRANSFERTEXT
53CURLOPT_UNRESTRICTED_AUTH
105CURLOPT_UPLOAD
46CURLOPT_URL
10002CURLOPT_USERAGENT
10018CURLOPT_USERPWD
10005CURLOPT_VERBOSE
41CURLOPT_WRITEFUNCTION
20011CURLOPT_WRITEHEADER
10029CURLOPT_HTTPAUTH
107CURLOPT_FTP_CREATE_MISSING_DIRS
110CURLOPT_PROXYAUTH
111CURLOPT_FTP_RESPONSE_TIMEOUT
112CURLOPT_IPRESOLVE
113CURLOPT_MAXFILESIZE
114CURLOPT_FTP_SSL
119CURLOPT_NETRC_FILE
10118CURLOPT_FTPSSLAUTH
129CURLOPT_FTP_ACCOUNT
10134CURLOPT_TCP_NODELAY
121CURLOPT_COOKIELIST
10135CURLOPT_IGNORE_CONTENT_LENGTH
136CURLOPT_FTP_SKIP_PASV_IP
137CURLOPT_FTP_FILEMETHOD
138CURLOPT_CONNECT_ONLY
141CURLOPT_LOCALPORT
139CURLOPT_LOCALPORTRANGE
140CURLOPT_FTP_ALTERNATIVE_TO_USER
10147CURLOPT_MAX_RECV_SPEED_LARGE
30146CURLOPT_MAX_SEND_SPEED_LARGE
30145CURLOPT_SSL_SESSIONID_CACHE
150CURLOPT_FTP_SSL_CCC
154CURLOPT_SSH_AUTH_TYPES
151CURLOPT_SSH_PRIVATE_KEYFILE
10153CURLOPT_SSH_PUBLIC_KEYFILE
10152CURLOPT_CONNECTTIMEOUT_MS
156CURLOPT_HTTP_CONTENT_DECODING
158CURLOPT_HTTP_TRANSFER_DECODING
157CURLOPT_TIMEOUT_MS
155CURLOPT_KRBLEVEL
10063CURLOPT_NEW_DIRECTORY_PERMS
160CURLOPT_NEW_FILE_PERMS
159CURLOPT_APPEND
50CURLOPT_DIRLISTONLY
48CURLOPT_USE_SSL
119CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
10162CURLOPT_PROXY_TRANSFER_MODE
166CURLOPT_ADDRESS_SCOPE
171CURLOPT_CRLFILE
10169CURLOPT_ISSUERCERT
10170CURLOPT_KEYPASSWD
10026CURLOPT_CERTINFO
172CURLOPT_PASSWORD
10174CURLOPT_POSTREDIR
161CURLOPT_PROXYPASSWORD
10176CURLOPT_PROXYUSERNAME
10175CURLOPT_USERNAME
10173CURLOPT_NOPROXY
10177CURLOPT_PROTOCOLS
181CURLOPT_REDIR_PROTOCOLS
182CURLOPT_SOCKS5_GSSAPI_NEC
180CURLOPT_SOCKS5_GSSAPI_SERVICE
10179CURLOPT_TFTP_BLKSIZE
178CURLOPT_SSH_KNOWNHOSTS
10183CURLOPT_FTP_USE_PRET
188CURLOPT_MAIL_FROM
10186CURLOPT_MAIL_RCPT
10187CURLOPT_RTSP_CLIENT_CSEQ
193CURLOPT_RTSP_REQUEST
189CURLOPT_RTSP_SERVER_CSEQ
194CURLOPT_RTSP_SESSION_ID
10190CURLOPT_RTSP_STREAM_URI
10191CURLOPT_RTSP_TRANSPORT
10192CURLOPT_FNMATCH_FUNCTION
20200CURLOPT_WILDCARDMATCH
197CURLOPT_RESOLVE
10203CURLOPT_TLSAUTH_PASSWORD
10205CURLOPT_TLSAUTH_TYPE
10206CURLOPT_TLSAUTH_USERNAME
10204CURLOPT_ACCEPT_ENCODING
10102CURLOPT_TRANSFER_ENCODING
207CURLOPT_GSSAPI_DELEGATION
210CURLOPT_ACCEPTTIMEOUT_MS
212CURLOPT_DNS_SERVERS
10211CURLOPT_MAIL_AUTH
10217CURLOPT_SSL_OPTIONS
216CURLOPT_TCP_KEEPALIVE
213CURLOPT_TCP_KEEPIDLE
214CURLOPT_TCP_KEEPINTVL
215CURLOPT_SAFE_UPLOAD
-1
While the PHP Docs for curl_setopt()
enumerate the list of available options, it doesn't* show the defaults that PHP sets for every connection (default, until you overwrite them of course).
You can view these default options PHP sets for curl in the ext/curl/interface.c file, in a call to _php_curl_set_default_options(php_curl *ch)
.
At the current time, the default options + values are:
// "value" options
CURLOPT_NOPROGRESS => 1
CURLOPT_VERBOSE => 0
CURLOPT_DNS_CACHE_TIMEOUT => 120
CURLOPT_MAXREDIRS => 20
// callback functions
CURLOPT_WRITEFUNCTION => curl_write
CURLOPT_READFUNCTION => curl_read
CURLOPT_HEADERFUNCTION => curl_write_header
// file/stream references
CURLOPT_INFILE => (void *)ch
CURLOPT_FILE => (void *)ch
CURLOPT_WRITEHEADER => (void *)ch
CURLOPT_ERRORBUFFER => ch->err.str
// If ZTS (Zend Thread Safety) *is* enabled
CURLOPT_NOSIGNAL => 1
// If ZTS (Zend Thread Safety) *is not* enabled
CURLOPT_DNS_USE_GLOBAL_CACHE => 1
// OpenSSL CA File (`cainfo` = either in openssl.cafile, curl.cainfo or it doesn't exist)
// note: if the file doesn't exist, this option isn't set
CURLOPT_CAINFO => cainfo
* Note: The php doc does mention that it sets the default for CURLOPT_NOPROGRESS
:
PHP automatically sets this option to TRUE, this should only be changed for debugging purposes.
If you're curious about general default behavior of curl, you can view the individual options in the documentation for curl_easy_setopt()
and curl_setopt()
. The former gives a very detailed description of each, the latter a general summary. Both list the default behavior of curl without the option(s) set.
I have been researching the same problem today and came across this (rather old) post. Since it shows up pretty much at the top of Google, I thought this is the place to conclude my research.
In short: It's not possible.
It seems like most cURL options do not even have any default values. For example, timeouts. Or the user agent. But many others do have defaults, as the PHP manual states. I could not find any list of default values - neither for PHP's cURL extension, nor for cURL in general. Only individual defaults that are mentioned within said PHP manual or within the cURL API doc. However, I doubt that every single default is mentioned within those pages.
Unfortunately, finding them out programmatically is not possible, either. The idea would be to find out all options values before setting the first one. But there is no curl_getopt()
. Not even in cURL itself. All solutions that emulate curl_getopt()
can only retrieve those options that have been set manually.
After a (very) short glance at the cURL source code (the original C lib) I also suspect that sometimes there are no real defaults, but if an option is not set, some logic goes into figuring out which value to use. In that case, default values would not even be well-defined.
Lastly, chances are that PHP's cURL extension employs some different defaults than cURL itself.
So unless some cURL developer sheds some light on this - or at least someone who has the time and skill to really dive into the code - we are pretty much stuck on this.