I was refactoring my cURL class today and thought about looking at default values of cURL FLAGS.
Could anyone tell me where I might find or how could I output them?
PS: If it's possible at all.
Let's discuss more the options used with the curl command. -I: to get the HTTP headers. –-cookie: to fetch the cookies and store it in a file. -L: to follow redirects. –limit-rate: to specify the transfer rate.
From man curl : -F, --form <name=content> (HTTP) This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC 2388. This enables uploading of binary files etc.
“php curl default timeout” Code Answer's The default connect timeout value seems to be 5 minutes / 300 seconds according to the DEFAULT_CONNECT_TIMEOUT macro in lib/connect. h.
Returns true on success or false on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, false on failure. This function may return Boolean false , but may also return a non-Boolean value which evaluates to false .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With