version 1.1, 2012/02/21 23:47:53
|
version 1.1.1.4, 2013/10/14 08:02:09
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2013 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| This source file is subject to version 3.01 of the PHP license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 10
|
Line 10
|
| http://www.php.net/license/3_01.txt | |
| http://www.php.net/license/3_01.txt | |
| If you did not receive a copy of the PHP license and are unable to | |
| If you did not receive a copy of the PHP license and are unable to | |
| obtain it through the world-wide-web, please send a note to | |
| obtain it through the world-wide-web, please send a note to | |
| license@php.net so we can mail you a copy immediately. | | | license@php.net so we can mail you 6 copy immediately. | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Author: Sterling Hughes <sterling@php.net> | |
| Author: Sterling Hughes <sterling@php.net> | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
Line 164 static void _php_curl_close(zend_rsrc_list_entry *rsrc
|
Line 164 static void _php_curl_close(zend_rsrc_list_entry *rsrc
|
# define php_curl_ret(__ret) RETVAL_FALSE; return; |
# define php_curl_ret(__ret) RETVAL_FALSE; return; |
#endif |
#endif |
|
|
static int php_curl_option_url(php_curl *ch, const char *url, const int len) /* {{{ */ | static int php_curl_option_url(php_curl *ch, const char *url, const int len TSRMLS_DC) /* {{{ */ |
{ |
{ |
CURLcode error = CURLE_OK; |
CURLcode error = CURLE_OK; |
#if LIBCURL_VERSION_NUM < 0x071100 |
#if LIBCURL_VERSION_NUM < 0x071100 |
char *copystr = NULL; |
char *copystr = NULL; |
#endif |
#endif |
TSRMLS_FETCH(); | /* Disable file:// if open_basedir are used */ |
| if (PG(open_basedir) && *PG(open_basedir)) { |
/* Disable file:// if open_basedir or safe_mode are used */ | |
if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) { | |
#if LIBCURL_VERSION_NUM >= 0x071304 |
#if LIBCURL_VERSION_NUM >= 0x071304 |
error = curl_easy_setopt(ch->cp, CURLOPT_PROTOCOLS, CURLPROTO_ALL & ~CURLPROTO_FILE); |
error = curl_easy_setopt(ch->cp, CURLOPT_PROTOCOLS, CURLPROTO_ALL & ~CURLPROTO_FILE); |
#else |
#else |
Line 715 PHP_MINIT_FUNCTION(curl)
|
Line 713 PHP_MINIT_FUNCTION(curl)
|
#if LIBCURL_VERSION_NUM >= 0x071202 |
#if LIBCURL_VERSION_NUM >= 0x071202 |
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL); |
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL); |
#endif |
#endif |
|
#if LIBCURL_VERSION_NUM >= 0x071300 /* 7.19.0 */ |
|
REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_IP); |
|
#endif |
|
#if LIBCURL_VERSION_NUM >= 0x071500 /* 7.21.0 */ |
|
REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_PORT); |
|
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_IP); |
|
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_PORT); |
|
#endif |
|
|
|
|
/* cURL protocol constants (curl_version) */ |
/* cURL protocol constants (curl_version) */ |
Line 971 PHP_MSHUTDOWN_FUNCTION(curl)
|
Line 977 PHP_MSHUTDOWN_FUNCTION(curl)
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
|
/* {{{ curl_write_nothing |
|
* Used as a work around. See _php_curl_close_ex |
|
*/ |
|
static size_t curl_write_nothing(char *data, size_t size, size_t nmemb, void *ctx) |
|
{ |
|
return size * nmemb; |
|
} |
|
/* }}} */ |
|
|
/* {{{ curl_write |
/* {{{ curl_write |
*/ |
*/ |
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) |
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) |
Line 1053 static size_t curl_progress(void *clientp, double dlto
|
Line 1068 static size_t curl_progress(void *clientp, double dlto
|
{ |
{ |
php_curl *ch = (php_curl *) clientp; |
php_curl *ch = (php_curl *) clientp; |
php_curl_progress *t = ch->handlers->progress; |
php_curl_progress *t = ch->handlers->progress; |
int length = -1; |
|
size_t rval = 0; |
size_t rval = 0; |
|
|
#if PHP_CURL_DEBUG |
#if PHP_CURL_DEBUG |
Line 1103 static size_t curl_progress(void *clientp, double dlto
|
Line 1117 static size_t curl_progress(void *clientp, double dlto
|
ch->in_callback = 0; |
ch->in_callback = 0; |
if (error == FAILURE) { |
if (error == FAILURE) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION"); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION"); |
length = -1; |
|
} else if (retval_ptr) { |
} else if (retval_ptr) { |
if (Z_TYPE_P(retval_ptr) != IS_LONG) { |
if (Z_TYPE_P(retval_ptr) != IS_LONG) { |
convert_to_long_ex(&retval_ptr); |
convert_to_long_ex(&retval_ptr); |
Line 1358 static void curl_free_post(void **post)
|
Line 1371 static void curl_free_post(void **post)
|
|
|
/* {{{ curl_free_slist |
/* {{{ curl_free_slist |
*/ |
*/ |
static void curl_free_slist(void **slist) | static void curl_free_slist(void *slist) |
{ |
{ |
curl_slist_free_all((struct curl_slist *) *slist); | curl_slist_free_all(*((struct curl_slist **) slist)); |
} |
} |
/* }}} */ |
/* }}} */ |
|
|
Line 1428 static void alloc_curl_handle(php_curl **ch)
|
Line 1441 static void alloc_curl_handle(php_curl **ch)
|
(*ch)->handlers->read->stream = NULL; |
(*ch)->handlers->read->stream = NULL; |
|
|
zend_llist_init(&(*ch)->to_free->str, sizeof(char *), (llist_dtor_func_t) curl_free_string, 0); |
zend_llist_init(&(*ch)->to_free->str, sizeof(char *), (llist_dtor_func_t) curl_free_string, 0); |
zend_llist_init(&(*ch)->to_free->slist, sizeof(struct curl_slist), (llist_dtor_func_t) curl_free_slist, 0); |
|
zend_llist_init(&(*ch)->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_post, 0); |
zend_llist_init(&(*ch)->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_post, 0); |
|
|
|
(*ch)->to_free->slist = emalloc(sizeof(HashTable)); |
|
zend_hash_init((*ch)->to_free->slist, 4, NULL, curl_free_slist, 0); |
} |
} |
/* }}} */ |
/* }}} */ |
|
|
Line 1547 PHP_FUNCTION(curl_init)
|
Line 1562 PHP_FUNCTION(curl_init)
|
MAKE_STD_ZVAL(clone); |
MAKE_STD_ZVAL(clone); |
ch->clone = clone; |
ch->clone = clone; |
|
|
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1); |
curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1); |
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); |
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); |
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); |
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); |
Line 1572 PHP_FUNCTION(curl_init)
|
Line 1585 PHP_FUNCTION(curl_init)
|
#endif |
#endif |
|
|
if (url) { |
if (url) { |
if (!php_curl_option_url(ch, url, url_len)) { | if (!php_curl_option_url(ch, url, url_len TSRMLS_CC)) { |
_php_curl_close_ex(ch TSRMLS_CC); |
_php_curl_close_ex(ch TSRMLS_CC); |
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
Line 1610 PHP_FUNCTION(curl_copy_handle)
|
Line 1623 PHP_FUNCTION(curl_copy_handle)
|
dupch->uses = 0; |
dupch->uses = 0; |
ch->uses++; |
ch->uses++; |
if (ch->handlers->write->stream) { |
if (ch->handlers->write->stream) { |
Z_ADDREF_P(dupch->handlers->write->stream); | Z_ADDREF_P(ch->handlers->write->stream); |
dupch->handlers->write->stream = ch->handlers->write->stream; | |
} |
} |
|
dupch->handlers->write->stream = ch->handlers->write->stream; |
dupch->handlers->write->method = ch->handlers->write->method; |
dupch->handlers->write->method = ch->handlers->write->method; |
dupch->handlers->write->type = ch->handlers->write->type; |
dupch->handlers->write->type = ch->handlers->write->type; |
if (ch->handlers->read->stream) { |
if (ch->handlers->read->stream) { |
Line 1662 PHP_FUNCTION(curl_copy_handle)
|
Line 1675 PHP_FUNCTION(curl_copy_handle)
|
curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch); |
curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch); |
curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch); |
curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch); |
|
|
|
efree(dupch->to_free->slist); |
efree(dupch->to_free); |
efree(dupch->to_free); |
dupch->to_free = ch->to_free; |
dupch->to_free = ch->to_free; |
|
|
Line 1679 static int _php_curl_setopt(php_curl *ch, long option,
|
Line 1693 static int _php_curl_setopt(php_curl *ch, long option,
|
CURLcode error=CURLE_OK; |
CURLcode error=CURLE_OK; |
|
|
switch (option) { |
switch (option) { |
|
/* Long options */ |
|
case CURLOPT_SSL_VERIFYHOST: |
|
if(Z_BVAL_PP(zvalue) == 1) { |
|
#if LIBCURL_VERSION_NUM <= 0x071c00 /* 7.28.0 */ |
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "CURLOPT_SSL_VERIFYHOST with value 1 is deprecated and will be removed as of libcurl 7.28.1. It is recommended to use value 2 instead"); |
|
#else |
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value 2 will be used instead"); |
|
error = curl_easy_setopt(ch->cp, option, 2); |
|
break; |
|
#endif |
|
} |
case CURLOPT_INFILESIZE: |
case CURLOPT_INFILESIZE: |
case CURLOPT_VERBOSE: |
case CURLOPT_VERBOSE: |
case CURLOPT_HEADER: |
case CURLOPT_HEADER: |
Line 1717 static int _php_curl_setopt(php_curl *ch, long option,
|
Line 1742 static int _php_curl_setopt(php_curl *ch, long option,
|
#if LIBCURL_VERSION_NUM > 0x071002 |
#if LIBCURL_VERSION_NUM > 0x071002 |
case CURLOPT_CONNECTTIMEOUT_MS: |
case CURLOPT_CONNECTTIMEOUT_MS: |
#endif |
#endif |
case CURLOPT_SSL_VERIFYHOST: |
|
case CURLOPT_SSL_VERIFYPEER: |
case CURLOPT_SSL_VERIFYPEER: |
case CURLOPT_DNS_USE_GLOBAL_CACHE: |
case CURLOPT_DNS_USE_GLOBAL_CACHE: |
case CURLOPT_NOSIGNAL: |
case CURLOPT_NOSIGNAL: |
Line 1767 static int _php_curl_setopt(php_curl *ch, long option,
|
Line 1791 static int _php_curl_setopt(php_curl *ch, long option,
|
convert_to_long_ex(zvalue); |
convert_to_long_ex(zvalue); |
#if LIBCURL_VERSION_NUM >= 0x71304 |
#if LIBCURL_VERSION_NUM >= 0x71304 |
if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) && |
if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) && |
((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) && (Z_LVAL_PP(zvalue) & CURLPROTO_FILE)) { | (PG(open_basedir) && *PG(open_basedir)) && (Z_LVAL_PP(zvalue) & CURLPROTO_FILE)) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLPROTO_FILE cannot be activated when in safe_mode or an open_basedir is set"); | php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLPROTO_FILE cannot be activated when an open_basedir is set"); |
RETVAL_FALSE; |
RETVAL_FALSE; |
return 1; |
return 1; |
} |
} |
Line 1784 static int _php_curl_setopt(php_curl *ch, long option,
|
Line 1808 static int _php_curl_setopt(php_curl *ch, long option,
|
#endif |
#endif |
case CURLOPT_FOLLOWLOCATION: |
case CURLOPT_FOLLOWLOCATION: |
convert_to_long_ex(zvalue); |
convert_to_long_ex(zvalue); |
if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) { | if (PG(open_basedir) && *PG(open_basedir)) { |
if (Z_LVAL_PP(zvalue) != 0) { |
if (Z_LVAL_PP(zvalue) != 0) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set"); | php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set"); |
RETVAL_FALSE; |
RETVAL_FALSE; |
return 1; |
return 1; |
} |
} |
Line 1828 static int _php_curl_setopt(php_curl *ch, long option,
|
Line 1852 static int _php_curl_setopt(php_curl *ch, long option,
|
case CURLOPT_SSH_PRIVATE_KEYFILE: |
case CURLOPT_SSH_PRIVATE_KEYFILE: |
#endif |
#endif |
{ |
{ |
#if LIBCURL_VERSION_NUM < 0x071100 |
|
char *copystr = NULL; |
|
#endif |
|
|
|
convert_to_string_ex(zvalue); |
convert_to_string_ex(zvalue); |
#if LIBCURL_VERSION_NUM >= 0x071300 |
#if LIBCURL_VERSION_NUM >= 0x071300 |
if ( |
if ( |
option == CURLOPT_SSH_PUBLIC_KEYFILE || option == CURLOPT_SSH_PRIVATE_KEYFILE |
option == CURLOPT_SSH_PUBLIC_KEYFILE || option == CURLOPT_SSH_PRIVATE_KEYFILE |
|
|
) { |
) { |
if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(zvalue), "rb+", CHECKUID_CHECK_MODE_PARAM))) { | if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) { |
RETVAL_FALSE; |
RETVAL_FALSE; |
return 1; |
return 1; |
} |
} |
} |
} |
#endif |
#endif |
if (option == CURLOPT_URL) { |
if (option == CURLOPT_URL) { |
if (!php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue))) { | if (!php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue) TSRMLS_CC)) { |
RETVAL_FALSE; |
RETVAL_FALSE; |
return 1; |
return 1; |
} |
} |
Line 2027 string_copy:
|
Line 2047 string_copy:
|
HashTable *postfields; |
HashTable *postfields; |
struct HttpPost *first = NULL; |
struct HttpPost *first = NULL; |
struct HttpPost *last = NULL; |
struct HttpPost *last = NULL; |
char *postval; |
|
char *string_key = NULL; |
|
ulong num_key; |
|
uint string_key_len; |
|
|
|
postfields = HASH_OF(*zvalue); |
postfields = HASH_OF(*zvalue); |
if (!postfields) { |
if (!postfields) { |
Line 2043 string_copy:
|
Line 2059 string_copy:
|
zend_hash_get_current_data(postfields, (void **) ¤t) == SUCCESS; |
zend_hash_get_current_data(postfields, (void **) ¤t) == SUCCESS; |
zend_hash_move_forward(postfields) |
zend_hash_move_forward(postfields) |
) { |
) { |
|
char *postval; |
|
char *string_key = NULL; |
|
uint string_key_len; |
|
ulong num_key; |
|
int numeric_key; |
|
|
SEPARATE_ZVAL(current); |
SEPARATE_ZVAL(current); |
convert_to_string_ex(current); |
convert_to_string_ex(current); |
|
|
zend_hash_get_current_key_ex(postfields, &string_key, &string_key_len, &num_key, 0, NULL); |
zend_hash_get_current_key_ex(postfields, &string_key, &string_key_len, &num_key, 0, NULL); |
|
|
|
/* Pretend we have a string_key here */ |
|
if(!string_key) { |
|
spprintf(&string_key, 0, "%ld", num_key); |
|
string_key_len = strlen(string_key)+1; |
|
numeric_key = 1; |
|
} else { |
|
numeric_key = 0; |
|
} |
|
|
postval = Z_STRVAL_PP(current); |
postval = Z_STRVAL_PP(current); |
|
|
/* The arguments after _NAMELENGTH and _CONTENTSLENGTH |
/* The arguments after _NAMELENGTH and _CONTENTSLENGTH |
Line 2064 string_copy:
|
Line 2094 string_copy:
|
if ((filename = php_memnstr(postval, ";filename=", sizeof(";filename=") - 1, postval + Z_STRLEN_PP(current)))) { |
if ((filename = php_memnstr(postval, ";filename=", sizeof(";filename=") - 1, postval + Z_STRLEN_PP(current)))) { |
*filename = '\0'; |
*filename = '\0'; |
} |
} |
/* safe_mode / open_basedir check */ | /* open_basedir check */ |
if (php_check_open_basedir(postval TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(postval, "rb+", CHECKUID_CHECK_MODE_PARAM))) { | if (php_check_open_basedir(postval TSRMLS_CC)) { |
RETVAL_FALSE; |
RETVAL_FALSE; |
return 1; |
return 1; |
} |
} |
Line 2090 string_copy:
|
Line 2120 string_copy:
|
CURLFORM_CONTENTSLENGTH, (long)Z_STRLEN_PP(current), |
CURLFORM_CONTENTSLENGTH, (long)Z_STRLEN_PP(current), |
CURLFORM_END); |
CURLFORM_END); |
} |
} |
|
|
|
if (numeric_key) { |
|
efree(string_key); |
|
} |
} |
} |
|
|
SAVE_CURL_ERROR(ch, error); |
SAVE_CURL_ERROR(ch, error); |
Line 2098 string_copy:
|
Line 2132 string_copy:
|
return 1; |
return 1; |
} |
} |
|
|
|
if (Z_REFCOUNT_P(ch->clone) <= 1) { |
|
zend_llist_clean(&ch->to_free->post); |
|
} |
zend_llist_add_element(&ch->to_free->post, &first); |
zend_llist_add_element(&ch->to_free->post, &first); |
error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first); |
error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first); |
|
|
Line 2148 string_copy:
|
Line 2185 string_copy:
|
return 1; |
return 1; |
} |
} |
} |
} |
zend_llist_add_element(&ch->to_free->slist, &slist); | zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NULL); |
|
|
error = curl_easy_setopt(ch->cp, option, slist); |
error = curl_easy_setopt(ch->cp, option, slist); |
|
|
break; |
break; |
} |
} |
/* the following options deal with files, therefor safe_mode & open_basedir checks | /* the following options deal with files, therefore the open_basedir check |
* are required. | * is required. |
*/ |
*/ |
case CURLOPT_COOKIEJAR: |
case CURLOPT_COOKIEJAR: |
case CURLOPT_SSLCERT: |
case CURLOPT_SSLCERT: |
Line 2167 string_copy:
|
Line 2204 string_copy:
|
|
|
convert_to_string_ex(zvalue); |
convert_to_string_ex(zvalue); |
|
|
if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(zvalue), "rb+", CHECKUID_CHECK_MODE_PARAM))) { | if (Z_STRLEN_PP(zvalue) && php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) { |
RETVAL_FALSE; |
RETVAL_FALSE; |
return 1; |
return 1; |
} |
} |
Line 2438 PHP_FUNCTION(curl_getinfo)
|
Line 2475 PHP_FUNCTION(curl_getinfo)
|
CAAZ("certinfo", listcode); |
CAAZ("certinfo", listcode); |
} |
} |
#endif |
#endif |
|
#if LIBCURL_VERSION_NUM >= 0x071300 /* 7.19.0 */ |
|
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) { |
|
CAAS("primary_ip", s_code); |
|
} |
|
#endif |
|
#if LIBCURL_VERSION_NUM > 0x071500 |
|
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_PORT, &l_code) == CURLE_OK) { |
|
CAAL("primary_port", l_code); |
|
} |
|
if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_IP, &s_code) == CURLE_OK) { |
|
CAAS("local_ip", s_code); |
|
} |
|
if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_PORT, &l_code) == CURLE_OK) { |
|
CAAL("local_port", l_code); |
|
} |
|
#endif |
#if LIBCURL_VERSION_NUM >= 0x071202 |
#if LIBCURL_VERSION_NUM >= 0x071202 |
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) { |
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) { |
CAAS("redirect_url", s_code); |
CAAS("redirect_url", s_code); |
Line 2448 PHP_FUNCTION(curl_getinfo)
|
Line 2501 PHP_FUNCTION(curl_getinfo)
|
} |
} |
} else { |
} else { |
switch (option) { |
switch (option) { |
|
/* string variable types */ |
|
#if LIBCURL_VERSION_NUM >= 0x071300 /* 7.19.0 */ |
|
case CURLINFO_PRIMARY_IP: |
|
#endif |
|
#if LIBCURL_VERSION_NUM >= 0x071500 /* 7.21.0 */ |
|
case CURLINFO_LOCAL_IP: |
|
#endif |
case CURLINFO_PRIVATE: |
case CURLINFO_PRIVATE: |
case CURLINFO_EFFECTIVE_URL: |
case CURLINFO_EFFECTIVE_URL: |
case CURLINFO_CONTENT_TYPE: |
case CURLINFO_CONTENT_TYPE: |
Line 2464 PHP_FUNCTION(curl_getinfo)
|
Line 2524 PHP_FUNCTION(curl_getinfo)
|
} |
} |
break; |
break; |
} |
} |
|
/* Long variable types */ |
|
#if LIBCURL_VERSION_NUM >= 0x071500 /* 7.21.0 */ |
|
case CURLINFO_PRIMARY_PORT: |
|
case CURLINFO_LOCAL_PORT: |
|
#endif |
case CURLINFO_HTTP_CODE: |
case CURLINFO_HTTP_CODE: |
case CURLINFO_HEADER_SIZE: |
case CURLINFO_HEADER_SIZE: |
case CURLINFO_REQUEST_SIZE: |
case CURLINFO_REQUEST_SIZE: |
Line 2479 PHP_FUNCTION(curl_getinfo)
|
Line 2544 PHP_FUNCTION(curl_getinfo)
|
} |
} |
break; |
break; |
} |
} |
|
/* Double variable types */ |
case CURLINFO_TOTAL_TIME: |
case CURLINFO_TOTAL_TIME: |
case CURLINFO_NAMELOOKUP_TIME: |
case CURLINFO_NAMELOOKUP_TIME: |
case CURLINFO_CONNECT_TIME: |
case CURLINFO_CONNECT_TIME: |
Line 2595 static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
|
Line 2661 static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
|
#endif |
#endif |
|
|
_php_curl_verify_handlers(ch, 0 TSRMLS_CC); |
_php_curl_verify_handlers(ch, 0 TSRMLS_CC); |
|
|
|
/* |
|
* Libcurl is doing connection caching. When easy handle is cleaned up, |
|
* if the handle was previously used by the curl_multi_api, the connection |
|
* remains open un the curl multi handle is cleaned up. Some protocols are |
|
* sending content like the FTP one, and libcurl try to use the |
|
* WRITEFUNCTION or the HEADERFUNCTION. Since structures used in those |
|
* callback are freed, we need to use an other callback to which avoid |
|
* segfaults. |
|
* |
|
* Libcurl commit d021f2e8a00 fix this issue and should be part of 7.28.2 |
|
*/ |
|
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_nothing); |
|
curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write_nothing); |
|
|
curl_easy_cleanup(ch->cp); |
curl_easy_cleanup(ch->cp); |
|
|
/* cURL destructors should be invoked only by last curl handle */ |
/* cURL destructors should be invoked only by last curl handle */ |
if (Z_REFCOUNT_P(ch->clone) <= 1) { |
if (Z_REFCOUNT_P(ch->clone) <= 1) { |
zend_llist_clean(&ch->to_free->str); |
zend_llist_clean(&ch->to_free->str); |
zend_llist_clean(&ch->to_free->slist); |
|
zend_llist_clean(&ch->to_free->post); |
zend_llist_clean(&ch->to_free->post); |
|
zend_hash_destroy(ch->to_free->slist); |
|
efree(ch->to_free->slist); |
efree(ch->to_free); |
efree(ch->to_free); |
FREE_ZVAL(ch->clone); |
FREE_ZVAL(ch->clone); |
} else { |
} else { |