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 58
  • CURLOPT_BINARYTRANSFER 19914
  • CURLOPT_BUFFERSIZE 98
  • CURLOPT_CAINFO 10065
  • CURLOPT_CAPATH 10097
  • CURLOPT_CONNECTTIMEOUT 78
  • CURLOPT_COOKIE 10022
  • CURLOPT_COOKIEFILE 10031
  • CURLOPT_COOKIEJAR 10082
  • CURLOPT_COOKIESESSION 96
  • CURLOPT_CRLF 27
  • CURLOPT_CUSTOMREQUEST 10036
  • CURLOPT_DNS_CACHE_TIMEOUT 92
  • CURLOPT_DNS_USE_GLOBAL_CACHE 91
  • CURLOPT_EGDSOCKET 10077
  • CURLOPT_ENCODING 10102
  • CURLOPT_FAILONERROR 45
  • CURLOPT_FILE 10001
  • CURLOPT_FILETIME 69
  • CURLOPT_FOLLOWLOCATION 52
  • CURLOPT_FORBID_REUSE 75
  • CURLOPT_FRESH_CONNECT 74
  • CURLOPT_FTPAPPEND 50
  • CURLOPT_FTPLISTONLY 48
  • CURLOPT_FTPPORT 10017
  • CURLOPT_FTP_USE_EPRT 106
  • CURLOPT_FTP_USE_EPSV 85
  • CURLOPT_HEADER 42
  • CURLOPT_HEADERFUNCTION 20079
  • CURLOPT_HTTP200ALIASES 10104
  • CURLOPT_HTTPGET 80
  • CURLOPT_HTTPHEADER 10023
  • CURLOPT_HTTPPROXYTUNNEL 61
  • CURLOPT_HTTP_VERSION 84
  • CURLOPT_INFILE 10009
  • CURLOPT_INFILESIZE 14
  • CURLOPT_INTERFACE 10062
  • CURLOPT_KRB4LEVEL 10063
  • CURLOPT_LOW_SPEED_LIMIT 19
  • CURLOPT_LOW_SPEED_TIME 20
  • CURLOPT_MAXCONNECTS 71
  • CURLOPT_MAXREDIRS 68
  • CURLOPT_NETRC 51
  • CURLOPT_NOBODY 44
  • CURLOPT_NOPROGRESS 43
  • CURLOPT_NOSIGNAL 99
  • CURLOPT_PORT 3
  • CURLOPT_POST 47
  • CURLOPT_POSTFIELDS 10015
  • CURLOPT_POSTQUOTE 10039
  • CURLOPT_PREQUOTE 10093
  • CURLOPT_PRIVATE 10103
  • CURLOPT_PROGRESSFUNCTION 20056
  • CURLOPT_PROXY 10004
  • CURLOPT_PROXYPORT 59
  • CURLOPT_PROXYTYPE 101
  • CURLOPT_PROXYUSERPWD 10006
  • CURLOPT_PUT 54
  • CURLOPT_QUOTE 10028
  • CURLOPT_RANDOM_FILE 10076
  • CURLOPT_RANGE 10007
  • CURLOPT_READDATA 10009
  • CURLOPT_READFUNCTION 20012
  • CURLOPT_REFERER 10016
  • CURLOPT_RESUME_FROM 21
  • CURLOPT_RETURNTRANSFER 19913
  • CURLOPT_SHARE 10100
  • CURLOPT_SSLCERT 10025
  • CURLOPT_SSLCERTPASSWD 10026
  • CURLOPT_SSLCERTTYPE 10086
  • CURLOPT_SSLENGINE 10089
  • CURLOPT_SSLENGINE_DEFAULT 90
  • CURLOPT_SSLKEY 10087
  • CURLOPT_SSLKEYPASSWD 10026
  • CURLOPT_SSLKEYTYPE 10088
  • CURLOPT_SSLVERSION 32
  • CURLOPT_SSL_CIPHER_LIST 10083
  • CURLOPT_SSL_VERIFYHOST 81
  • CURLOPT_SSL_VERIFYPEER 64
  • CURLOPT_STDERR 10037
  • CURLOPT_TELNETOPTIONS 10070
  • CURLOPT_TIMECONDITION 33
  • CURLOPT_TIMEOUT 13
  • CURLOPT_TIMEVALUE 34
  • CURLOPT_TRANSFERTEXT 53
  • CURLOPT_UNRESTRICTED_AUTH 105
  • CURLOPT_UPLOAD 46
  • CURLOPT_URL 10002
  • CURLOPT_USERAGENT 10018
  • CURLOPT_USERPWD 10005
  • CURLOPT_VERBOSE 41
  • CURLOPT_WRITEFUNCTION 20011
  • CURLOPT_WRITEHEADER 10029
  • CURLOPT_HTTPAUTH 107
  • CURLOPT_FTP_CREATE_MISSING_DIRS 110
  • CURLOPT_PROXYAUTH 111
  • CURLOPT_FTP_RESPONSE_TIMEOUT 112
  • CURLOPT_IPRESOLVE 113
  • CURLOPT_MAXFILESIZE 114
  • CURLOPT_FTP_SSL 119
  • CURLOPT_NETRC_FILE 10118
  • CURLOPT_FTPSSLAUTH 129
  • CURLOPT_FTP_ACCOUNT 10134
  • CURLOPT_TCP_NODELAY 121
  • CURLOPT_COOKIELIST 10135
  • CURLOPT_IGNORE_CONTENT_LENGTH 136
  • CURLOPT_FTP_SKIP_PASV_IP 137
  • CURLOPT_FTP_FILEMETHOD 138
  • CURLOPT_CONNECT_ONLY 141
  • CURLOPT_LOCALPORT 139
  • CURLOPT_LOCALPORTRANGE 140
  • CURLOPT_FTP_ALTERNATIVE_TO_USER 10147
  • CURLOPT_MAX_RECV_SPEED_LARGE 30146
  • CURLOPT_MAX_SEND_SPEED_LARGE 30145
  • CURLOPT_SSL_SESSIONID_CACHE 150
  • CURLOPT_FTP_SSL_CCC 154
  • CURLOPT_SSH_AUTH_TYPES 151
  • CURLOPT_SSH_PRIVATE_KEYFILE 10153
  • CURLOPT_SSH_PUBLIC_KEYFILE 10152
  • CURLOPT_CONNECTTIMEOUT_MS 156
  • CURLOPT_HTTP_CONTENT_DECODING 158
  • CURLOPT_HTTP_TRANSFER_DECODING 157
  • CURLOPT_TIMEOUT_MS 155
  • CURLOPT_KRBLEVEL 10063
  • CURLOPT_NEW_DIRECTORY_PERMS 160
  • CURLOPT_NEW_FILE_PERMS 159
  • CURLOPT_APPEND 50
  • CURLOPT_DIRLISTONLY 48
  • CURLOPT_USE_SSL 119
  • CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 10162
  • CURLOPT_PROXY_TRANSFER_MODE 166
  • CURLOPT_ADDRESS_SCOPE 171
  • CURLOPT_CRLFILE 10169
  • CURLOPT_ISSUERCERT 10170
  • CURLOPT_KEYPASSWD 10026
  • CURLOPT_CERTINFO 172
  • CURLOPT_PASSWORD 10174
  • CURLOPT_POSTREDIR 161
  • CURLOPT_PROXYPASSWORD 10176
  • CURLOPT_PROXYUSERNAME 10175
  • CURLOPT_USERNAME 10173
  • CURLOPT_NOPROXY 10177
  • CURLOPT_PROTOCOLS 181
  • CURLOPT_REDIR_PROTOCOLS 182
  • CURLOPT_SOCKS5_GSSAPI_NEC 180
  • CURLOPT_SOCKS5_GSSAPI_SERVICE 10179
  • CURLOPT_TFTP_BLKSIZE 178
  • CURLOPT_SSH_KNOWNHOSTS 10183
  • CURLOPT_FTP_USE_PRET 188
  • CURLOPT_MAIL_FROM 10186
  • CURLOPT_MAIL_RCPT 10187
  • CURLOPT_RTSP_CLIENT_CSEQ 193
  • CURLOPT_RTSP_REQUEST 189
  • CURLOPT_RTSP_SERVER_CSEQ 194
  • CURLOPT_RTSP_SESSION_ID 10190
  • CURLOPT_RTSP_STREAM_URI 10191
  • CURLOPT_RTSP_TRANSPORT 10192
  • CURLOPT_FNMATCH_FUNCTION 20200
  • CURLOPT_WILDCARDMATCH 197
  • CURLOPT_RESOLVE 10203
  • CURLOPT_TLSAUTH_PASSWORD 10205
  • CURLOPT_TLSAUTH_TYPE 10206
  • CURLOPT_TLSAUTH_USERNAME 10204
  • CURLOPT_ACCEPT_ENCODING 10102
  • CURLOPT_TRANSFER_ENCODING 207
  • CURLOPT_GSSAPI_DELEGATION 210
  • CURLOPT_ACCEPTTIMEOUT_MS 212
  • CURLOPT_DNS_SERVERS 10211
  • CURLOPT_MAIL_AUTH 10217
  • CURLOPT_SSL_OPTIONS 216
  • CURLOPT_TCP_KEEPALIVE 213
  • CURLOPT_TCP_KEEPIDLE 214
  • CURLOPT_TCP_KEEPINTVL 215
  • CURLOPT_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.

Tags:

Php

Curl

Default