diff options
Diffstat (limited to 'ext/curl/interface.c')
-rw-r--r-- | ext/curl/interface.c | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 0a36e1a8d..23bd2edce 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: interface.c 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: interface.c 313826 2011-07-28 10:31:34Z pajoye $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS @@ -307,7 +307,7 @@ const zend_function_entry curl_functions[] = { PHP_FE(curl_multi_getcontent, arginfo_curl_multi_getcontent) PHP_FE(curl_multi_info_read, arginfo_curl_multi_info_read) PHP_FE(curl_multi_close, arginfo_curl_multi_close) - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ @@ -331,6 +331,13 @@ zend_module_entry curl_module_entry = { ZEND_GET_MODULE (curl) #endif +/* {{{ PHP_INI_BEGIN */ +PHP_INI_BEGIN() + PHP_INI_ENTRY("curl.cainfo", "", PHP_INI_SYSTEM, NULL) +PHP_INI_END() +/* }}} */ + +/* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(curl) @@ -458,6 +465,8 @@ PHP_MINIT_FUNCTION(curl) le_curl = zend_register_list_destructors_ex(_php_curl_close, NULL, "curl", module_number); le_curl_multi_handle = zend_register_list_destructors_ex(_php_curl_multi_close, NULL, "curl_multi", module_number); + REGISTER_INI_ENTRIES(); + /* See http://curl.haxx.se/lxr/source/docs/libcurl/symbols-in-versions or curl src/docs/libcurl/symbols-in-versions for a (almost) complete list of options and which version they were introduced */ @@ -581,6 +590,11 @@ PHP_MINIT_FUNCTION(curl) REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE); REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD); +#if LIBCURL_VERSION_NUM > 0x070f04 /* CURLOPT_MAX_RECV_SPEED_LARGE & CURLOPT_MAX_SEND_SPEED_LARGE are available since curl 7.15.5 */ + REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE); + REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE); +#endif + #if LIBCURL_VERSION_NUM > 0x070a05 /* CURLOPT_HTTPAUTH is available since curl 7.10.6 */ REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH); /* http authentication options */ @@ -632,6 +646,10 @@ PHP_MINIT_FUNCTION(curl) #if LIBCURL_VERSION_NUM > 0x071301 REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO); #endif +#if LIBCURL_VERSION_NUM >= 0x071202 + REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL); +#endif + /* cURL protocol constants (curl_version) */ REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6); @@ -803,6 +821,9 @@ PHP_MINIT_FUNCTION(curl) int i, c = CRYPTO_num_locks(); php_curl_openssl_tsl = malloc(c * sizeof(MUTEX_T)); + if (!php_curl_openssl_tsl) { + return FAILURE; + } for (i = 0; i < c; ++i) { php_curl_openssl_tsl[i] = tsrm_mutex_alloc(); @@ -879,6 +900,7 @@ PHP_MSHUTDOWN_FUNCTION(curl) php_curl_openssl_tsl = NULL; } #endif + UNREGISTER_INI_ENTRIES(); return SUCCESS; } /* }}} */ @@ -1427,6 +1449,7 @@ PHP_FUNCTION(curl_init) zval *clone; char *url = NULL; int url_len = 0; + char *cainfo; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &url, &url_len) == FAILURE) { return; @@ -1453,6 +1476,8 @@ PHP_FUNCTION(curl_init) MAKE_STD_ZVAL(clone); ch->clone = clone; + + curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); @@ -1465,6 +1490,12 @@ PHP_FUNCTION(curl_init) curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1); curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120); curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */ + + cainfo = INI_STR("curl.cainfo"); + if (cainfo && strlen(cainfo) > 0) { + curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo); + } + #if defined(ZTS) curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1); #endif @@ -1669,6 +1700,13 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu #endif error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); break; +#if LIBCURL_VERSION_NUM > 0x070f04 + case CURLOPT_MAX_RECV_SPEED_LARGE: + case CURLOPT_MAX_SEND_SPEED_LARGE: + convert_to_long_ex(zvalue); + error = curl_easy_setopt(ch->cp, option, (curl_off_t)Z_LVAL_PP(zvalue)); + break; +#endif case CURLOPT_FOLLOWLOCATION: convert_to_long_ex(zvalue); if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) { @@ -2306,6 +2344,11 @@ PHP_FUNCTION(curl_getinfo) CAAZ("certinfo", listcode); } #endif +#if LIBCURL_VERSION_NUM >= 0x071202 + if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) { + CAAS("redirect_url", s_code); + } +#endif if (ch->header.str_len > 0) { CAAS("request_header", ch->header.str); } @@ -2313,7 +2356,11 @@ PHP_FUNCTION(curl_getinfo) switch (option) { case CURLINFO_PRIVATE: case CURLINFO_EFFECTIVE_URL: - case CURLINFO_CONTENT_TYPE: { + case CURLINFO_CONTENT_TYPE: +#if LIBCURL_VERSION_NUM >= 0x071202 + case CURLINFO_REDIRECT_URL: +#endif + { char *s_code = NULL; if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) { |