summaryrefslogtreecommitdiff
path: root/ext/curl/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/curl/interface.c')
-rw-r--r--ext/curl/interface.c721
1 files changed, 394 insertions, 327 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 808785c445..d8ce11df37 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -97,26 +97,14 @@ static ZEND_ATTRIBUTE_UNUSED unsigned long php_curl_ssl_id(void)
# define php_curl_ret(__ret) RETVAL_FALSE; return;
#endif
-static int php_curl_option_str(php_curl *ch, zend_long option, const char *str, const size_t len, zend_bool make_copy)
+static int php_curl_option_str(php_curl *ch, zend_long option, const char *str, const size_t len)
{
- CURLcode error = CURLE_OK;
-
if (strlen(str) != len) {
zend_value_error("%s(): cURL option must not contain any null bytes", get_active_function_name());
return FAILURE;
}
- if (make_copy) {
- char *copystr;
-
- /* Strings passed to libcurl as 'char *' arguments, are copied by the library since 7.17.0 */
- copystr = estrndup(str, len);
- error = curl_easy_setopt(ch->cp, option, copystr);
- zend_llist_add_element(&ch->to_free->str, &copystr);
- } else {
- error = curl_easy_setopt(ch->cp, option, str);
- }
-
+ CURLcode error = curl_easy_setopt(ch->cp, option, str);
SAVE_CURL_ERROR(ch, error);
return error == CURLE_OK ? SUCCESS : FAILURE;
@@ -136,11 +124,11 @@ static int php_curl_option_url(php_curl *ch, const char *url, const size_t len)
memmove(_tmp, "file:///", sizeof("file:///") - 1);
memmove(_tmp + sizeof("file:///") - 1, url + sizeof("file://") - 1, len - sizeof("file://") + 1);
- return php_curl_option_str(ch, CURLOPT_URL, _tmp, len + 1, 0);
+ return php_curl_option_str(ch, CURLOPT_URL, _tmp, len + 1);
}
#endif
- return php_curl_option_str(ch, CURLOPT_URL, url, len, 0);
+ return php_curl_option_str(ch, CURLOPT_URL, url, len);
}
/* }}} */
@@ -148,59 +136,59 @@ void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
{
php_stream *stream;
- ZEND_ASSERT(ch && ch->handlers);
+ ZEND_ASSERT(ch);
- if (!Z_ISUNDEF(ch->handlers->std_err)) {
- stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->std_err, NULL, php_file_le_stream(), php_file_le_pstream());
+ if (!Z_ISUNDEF(ch->handlers.std_err)) {
+ stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers.std_err, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_STDERR resource has gone away, resetting to stderr");
}
- zval_ptr_dtor(&ch->handlers->std_err);
- ZVAL_UNDEF(&ch->handlers->std_err);
+ zval_ptr_dtor(&ch->handlers.std_err);
+ ZVAL_UNDEF(&ch->handlers.std_err);
curl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr);
}
}
- if (ch->handlers->read && !Z_ISUNDEF(ch->handlers->read->stream)) {
- stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->read->stream, NULL, php_file_le_stream(), php_file_le_pstream());
+ if (ch->handlers.read && !Z_ISUNDEF(ch->handlers.read->stream)) {
+ stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers.read->stream, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_INFILE resource has gone away, resetting to default");
}
- zval_ptr_dtor(&ch->handlers->read->stream);
- ZVAL_UNDEF(&ch->handlers->read->stream);
- ch->handlers->read->res = NULL;
- ch->handlers->read->fp = 0;
+ zval_ptr_dtor(&ch->handlers.read->stream);
+ ZVAL_UNDEF(&ch->handlers.read->stream);
+ ch->handlers.read->res = NULL;
+ ch->handlers.read->fp = 0;
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
}
}
- if (ch->handlers->write_header && !Z_ISUNDEF(ch->handlers->write_header->stream)) {
- stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->write_header->stream, NULL, php_file_le_stream(), php_file_le_pstream());
+ if (ch->handlers.write_header && !Z_ISUNDEF(ch->handlers.write_header->stream)) {
+ stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers.write_header->stream, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_WRITEHEADER resource has gone away, resetting to default");
}
- zval_ptr_dtor(&ch->handlers->write_header->stream);
- ZVAL_UNDEF(&ch->handlers->write_header->stream);
- ch->handlers->write_header->fp = 0;
+ zval_ptr_dtor(&ch->handlers.write_header->stream);
+ ZVAL_UNDEF(&ch->handlers.write_header->stream);
+ ch->handlers.write_header->fp = 0;
- ch->handlers->write_header->method = PHP_CURL_IGNORE;
+ ch->handlers.write_header->method = PHP_CURL_IGNORE;
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
}
}
- if (ch->handlers->write && !Z_ISUNDEF(ch->handlers->write->stream)) {
- stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->write->stream, NULL, php_file_le_stream(), php_file_le_pstream());
+ if (ch->handlers.write && !Z_ISUNDEF(ch->handlers.write->stream)) {
+ stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers.write->stream, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_FILE resource has gone away, resetting to default");
}
- zval_ptr_dtor(&ch->handlers->write->stream);
- ZVAL_UNDEF(&ch->handlers->write->stream);
- ch->handlers->write->fp = 0;
+ zval_ptr_dtor(&ch->handlers.write->stream);
+ ZVAL_UNDEF(&ch->handlers.write->stream);
+ ch->handlers.write->fp = 0;
- ch->handlers->write->method = PHP_CURL_STDOUT;
+ ch->handlers.write->method = PHP_CURL_STDOUT;
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
}
}
@@ -1153,6 +1141,10 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLOPT_TLS13_CIPHERS);
#endif
+#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */
+ REGISTER_CURL_CONSTANT(CURLOPT_DOH_URL);
+#endif
+
#if LIBCURL_VERSION_NUM >= 0x074000 /* Available since 7.64.0 */
REGISTER_CURL_CONSTANT(CURLOPT_HTTP09_ALLOWED);
#endif
@@ -1185,10 +1177,7 @@ PHP_MINIT_FUNCTION(curl)
return FAILURE;
}
- zend_class_entry ce;
- INIT_CLASS_ENTRY(ce, "CurlHandle", class_CurlHandle_methods);
- curl_ce = zend_register_internal_class(&ce);
- curl_ce->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES;
+ curl_ce = register_class_CurlHandle();
curl_ce->create_object = curl_create_object;
curl_ce->serialize = zend_class_serialize_deny;
curl_ce->unserialize = zend_class_unserialize_deny;
@@ -1202,8 +1191,11 @@ PHP_MINIT_FUNCTION(curl)
curl_object_handlers.cast_object = curl_cast_object;
curl_object_handlers.compare = zend_objects_not_comparable;
- curl_multi_register_class(class_CurlMultiHandle_methods);
- curl_share_register_class(class_CurlShareHandle_methods);
+ curl_multi_ce = register_class_CurlMultiHandle();
+ curl_multi_register_handlers();
+
+ curl_share_ce = register_class_CurlShareHandle();
+ curl_share_register_handlers();
curlfile_register_class();
return SUCCESS;
@@ -1266,34 +1258,33 @@ static HashTable *curl_get_gc(zend_object *object, zval **table, int *n)
zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create();
zend_get_gc_buffer_add_zval(gc_buffer, &curl->postfields);
- if (curl->handlers) {
- if (curl->handlers->read) {
- zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->read->func_name);
- zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->read->stream);
- }
+ if (curl->handlers.read) {
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.read->func_name);
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.read->stream);
+ }
- if (curl->handlers->write) {
- zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->write->func_name);
- zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->write->stream);
- }
+ if (curl->handlers.write) {
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.write->func_name);
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.write->stream);
+ }
- if (curl->handlers->write_header) {
- zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->write_header->func_name);
- zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->write_header->stream);
- }
+ if (curl->handlers.write_header) {
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.write_header->func_name);
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.write_header->stream);
+ }
- if (curl->handlers->progress) {
- zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->progress->func_name);
- }
+ if (curl->handlers.progress) {
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.progress->func_name);
+ }
#if LIBCURL_VERSION_NUM >= 0x071500
- if (curl->handlers->fnmatch) {
- zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->fnmatch->func_name);
- }
+ if (curl->handlers.fnmatch) {
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.fnmatch->func_name);
+ }
#endif
- zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->std_err);
- }
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.std_err);
+ zend_get_gc_buffer_add_zval(gc_buffer, &curl->private_data);
zend_get_gc_buffer_use(gc_buffer, table, n);
@@ -1349,7 +1340,7 @@ static size_t curl_write_nothing(char *data, size_t size, size_t nmemb, void *ct
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
{
php_curl *ch = (php_curl *) ctx;
- php_curl_write *t = ch->handlers->write;
+ php_curl_write *t = ch->handlers.write;
size_t length = size * nmemb;
#if PHP_CURL_DEBUG
@@ -1411,43 +1402,38 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
{
php_curl *ch = (php_curl *) ctx;
- php_curl_fnmatch *t = ch->handlers->fnmatch;
+ php_curl_callback *t = ch->handlers.fnmatch;
int rval = CURL_FNMATCHFUNC_FAIL;
- switch (t->method) {
- case PHP_CURL_USER: {
- zval argv[3];
- zval retval;
- int error;
- zend_fcall_info fci;
-
- GC_ADDREF(&ch->std);
- ZVAL_OBJ(&argv[0], &ch->std);
- ZVAL_STRING(&argv[1], pattern);
- ZVAL_STRING(&argv[2], string);
-
- fci.size = sizeof(fci);
- ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
- fci.object = NULL;
- fci.retval = &retval;
- fci.param_count = 3;
- fci.params = argv;
- fci.named_params = NULL;
-
- ch->in_callback = 1;
- error = zend_call_function(&fci, &t->fci_cache);
- ch->in_callback = 0;
- if (error == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION");
- } else if (!Z_ISUNDEF(retval)) {
- _php_curl_verify_handlers(ch, 1);
- rval = zval_get_long(&retval);
- }
- zval_ptr_dtor(&argv[0]);
- zval_ptr_dtor(&argv[1]);
- zval_ptr_dtor(&argv[2]);
- break;
- }
- }
+ zval argv[3];
+ zval retval;
+ int error;
+ zend_fcall_info fci;
+
+ GC_ADDREF(&ch->std);
+ ZVAL_OBJ(&argv[0], &ch->std);
+ ZVAL_STRING(&argv[1], pattern);
+ ZVAL_STRING(&argv[2], string);
+
+ fci.size = sizeof(fci);
+ ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
+ fci.object = NULL;
+ fci.retval = &retval;
+ fci.param_count = 3;
+ fci.params = argv;
+ fci.named_params = NULL;
+
+ ch->in_callback = 1;
+ error = zend_call_function(&fci, &t->fci_cache);
+ ch->in_callback = 0;
+ if (error == FAILURE) {
+ php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION");
+ } else if (!Z_ISUNDEF(retval)) {
+ _php_curl_verify_handlers(ch, 1);
+ rval = zval_get_long(&retval);
+ }
+ zval_ptr_dtor(&argv[0]);
+ zval_ptr_dtor(&argv[1]);
+ zval_ptr_dtor(&argv[2]);
return rval;
}
/* }}} */
@@ -1456,7 +1442,7 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
php_curl *ch = (php_curl *)clientp;
- php_curl_progress *t = ch->handlers->progress;
+ php_curl_callback *t = ch->handlers.progress;
size_t rval = 0;
#if PHP_CURL_DEBUG
@@ -1464,43 +1450,38 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
fprintf(stderr, "clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow);
#endif
- switch (t->method) {
- case PHP_CURL_USER: {
- zval argv[5];
- zval retval;
- int error;
- zend_fcall_info fci;
-
- GC_ADDREF(&ch->std);
- ZVAL_OBJ(&argv[0], &ch->std);
- ZVAL_LONG(&argv[1], (zend_long)dltotal);
- ZVAL_LONG(&argv[2], (zend_long)dlnow);
- ZVAL_LONG(&argv[3], (zend_long)ultotal);
- ZVAL_LONG(&argv[4], (zend_long)ulnow);
-
- fci.size = sizeof(fci);
- ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
- fci.object = NULL;
- fci.retval = &retval;
- fci.param_count = 5;
- fci.params = argv;
- fci.named_params = NULL;
-
- ch->in_callback = 1;
- error = zend_call_function(&fci, &t->fci_cache);
- ch->in_callback = 0;
- if (error == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
- } else if (!Z_ISUNDEF(retval)) {
- _php_curl_verify_handlers(ch, 1);
- if (0 != zval_get_long(&retval)) {
- rval = 1;
- }
- }
- zval_ptr_dtor(&argv[0]);
- break;
- }
- }
+ zval argv[5];
+ zval retval;
+ int error;
+ zend_fcall_info fci;
+
+ GC_ADDREF(&ch->std);
+ ZVAL_OBJ(&argv[0], &ch->std);
+ ZVAL_LONG(&argv[1], (zend_long)dltotal);
+ ZVAL_LONG(&argv[2], (zend_long)dlnow);
+ ZVAL_LONG(&argv[3], (zend_long)ultotal);
+ ZVAL_LONG(&argv[4], (zend_long)ulnow);
+
+ fci.size = sizeof(fci);
+ ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
+ fci.object = NULL;
+ fci.retval = &retval;
+ fci.param_count = 5;
+ fci.params = argv;
+ fci.named_params = NULL;
+
+ ch->in_callback = 1;
+ error = zend_call_function(&fci, &t->fci_cache);
+ ch->in_callback = 0;
+ if (error == FAILURE) {
+ php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
+ } else if (!Z_ISUNDEF(retval)) {
+ _php_curl_verify_handlers(ch, 1);
+ if (0 != zval_get_long(&retval)) {
+ rval = 1;
+ }
+ }
+ zval_ptr_dtor(&argv[0]);
return rval;
}
/* }}} */
@@ -1509,7 +1490,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
{
php_curl *ch = (php_curl *)ctx;
- php_curl_read *t = ch->handlers->read;
+ php_curl_read *t = ch->handlers.read;
int length = 0;
switch (t->method) {
@@ -1571,15 +1552,15 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx)
{
php_curl *ch = (php_curl *) ctx;
- php_curl_write *t = ch->handlers->write_header;
+ php_curl_write *t = ch->handlers.write_header;
size_t length = size * nmemb;
switch (t->method) {
case PHP_CURL_STDOUT:
/* Handle special case write when we're returning the entire transfer
*/
- if (ch->handlers->write->method == PHP_CURL_RETURN && length > 0) {
- smart_str_appendl(&ch->handlers->write->buf, data, (int) length);
+ if (ch->handlers.write->method == PHP_CURL_RETURN && length > 0) {
+ smart_str_appendl(&ch->handlers.write->buf, data, (int) length);
} else {
PHPWRITE(data, length);
}
@@ -1647,13 +1628,6 @@ static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, v
}
/* }}} */
-/* {{{ curl_free_string */
-static void curl_free_string(void **string)
-{
- efree((char *)*string);
-}
-/* }}} */
-
/* {{{ curl_free_post */
static void curl_free_post(void **post)
{
@@ -1681,6 +1655,15 @@ static void curl_free_cb_arg(void **cb_arg_p)
}
/* }}} */
+#if LIBCURL_VERSION_NUM < 0x073800 /* 7.56.0 */
+/* {{{ curl_free_buffers */
+static void curl_free_buffers(void **buffer)
+{
+ zend_string_release((zend_string *) *buffer);
+}
+/* }}} */
+#endif
+
/* {{{ curl_free_slist */
static void curl_free_slist(zval *el)
{
@@ -1757,22 +1740,24 @@ php_curl *init_curl_handle_into_zval(zval *curl)
void init_curl_handle(php_curl *ch)
{
- ch->to_free = ecalloc(1, sizeof(struct _php_curl_free));
- ch->handlers = ecalloc(1, sizeof(php_curl_handlers));
- ch->handlers->write = ecalloc(1, sizeof(php_curl_write));
- ch->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
- ch->handlers->read = ecalloc(1, sizeof(php_curl_read));
- ch->handlers->progress = NULL;
- ch->handlers->fnmatch = NULL;
- ch->clone = emalloc(sizeof(uint32_t));
- *ch->clone = 1;
+ ch->to_free = ecalloc(1, sizeof(struct _php_curl_free));
+ ch->handlers.write = ecalloc(1, sizeof(php_curl_write));
+ ch->handlers.write_header = ecalloc(1, sizeof(php_curl_write));
+ ch->handlers.read = ecalloc(1, sizeof(php_curl_read));
+ ch->handlers.progress = NULL;
+ ch->handlers.fnmatch = NULL;
+ ch->clone = emalloc(sizeof(uint32_t));
+ *ch->clone = 1;
memset(&ch->err, 0, sizeof(struct _php_curl_error));
- zend_llist_init(&ch->to_free->str, sizeof(char *), (llist_dtor_func_t)curl_free_string, 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->stream, sizeof(struct mime_data_cb_arg *), (llist_dtor_func_t)curl_free_cb_arg, 0);
+#if LIBCURL_VERSION_NUM < 0x073800 /* 7.56.0 */
+ zend_llist_init(&ch->to_free->buffers, sizeof(zend_string *), (llist_dtor_func_t)curl_free_buffers, 0);
+#endif
+
ch->to_free->slist = emalloc(sizeof(HashTable));
zend_hash_init(ch->to_free->slist, 4, NULL, curl_free_slist, 0);
ZVAL_UNDEF(&ch->postfields);
@@ -1870,9 +1855,9 @@ PHP_FUNCTION(curl_init)
ch->cp = cp;
- ch->handlers->write->method = PHP_CURL_STDOUT;
- ch->handlers->read->method = PHP_CURL_DIRECT;
- ch->handlers->write_header->method = PHP_CURL_IGNORE;
+ ch->handlers.write->method = PHP_CURL_STDOUT;
+ ch->handlers.read->method = PHP_CURL_DIRECT;
+ ch->handlers.write_header->method = PHP_CURL_IGNORE;
_php_curl_set_default_options(ch);
@@ -1887,35 +1872,35 @@ PHP_FUNCTION(curl_init)
void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source)
{
- if (!Z_ISUNDEF(source->handlers->write->stream)) {
- Z_ADDREF(source->handlers->write->stream);
+ if (!Z_ISUNDEF(source->handlers.write->stream)) {
+ Z_ADDREF(source->handlers.write->stream);
}
- ch->handlers->write->stream = source->handlers->write->stream;
- ch->handlers->write->method = source->handlers->write->method;
- if (!Z_ISUNDEF(source->handlers->read->stream)) {
- Z_ADDREF(source->handlers->read->stream);
+ ch->handlers.write->stream = source->handlers.write->stream;
+ ch->handlers.write->method = source->handlers.write->method;
+ if (!Z_ISUNDEF(source->handlers.read->stream)) {
+ Z_ADDREF(source->handlers.read->stream);
}
- ch->handlers->read->stream = source->handlers->read->stream;
- ch->handlers->read->method = source->handlers->read->method;
- ch->handlers->write_header->method = source->handlers->write_header->method;
- if (!Z_ISUNDEF(source->handlers->write_header->stream)) {
- Z_ADDREF(source->handlers->write_header->stream);
+ ch->handlers.read->stream = source->handlers.read->stream;
+ ch->handlers.read->method = source->handlers.read->method;
+ ch->handlers.write_header->method = source->handlers.write_header->method;
+ if (!Z_ISUNDEF(source->handlers.write_header->stream)) {
+ Z_ADDREF(source->handlers.write_header->stream);
}
- ch->handlers->write_header->stream = source->handlers->write_header->stream;
+ ch->handlers.write_header->stream = source->handlers.write_header->stream;
- ch->handlers->write->fp = source->handlers->write->fp;
- ch->handlers->write_header->fp = source->handlers->write_header->fp;
- ch->handlers->read->fp = source->handlers->read->fp;
- ch->handlers->read->res = source->handlers->read->res;
+ ch->handlers.write->fp = source->handlers.write->fp;
+ ch->handlers.write_header->fp = source->handlers.write_header->fp;
+ ch->handlers.read->fp = source->handlers.read->fp;
+ ch->handlers.read->res = source->handlers.read->res;
- if (!Z_ISUNDEF(source->handlers->write->func_name)) {
- ZVAL_COPY(&ch->handlers->write->func_name, &source->handlers->write->func_name);
+ if (!Z_ISUNDEF(source->handlers.write->func_name)) {
+ ZVAL_COPY(&ch->handlers.write->func_name, &source->handlers.write->func_name);
}
- if (!Z_ISUNDEF(source->handlers->read->func_name)) {
- ZVAL_COPY(&ch->handlers->read->func_name, &source->handlers->read->func_name);
+ if (!Z_ISUNDEF(source->handlers.read->func_name)) {
+ ZVAL_COPY(&ch->handlers.read->func_name, &source->handlers.read->func_name);
}
- if (!Z_ISUNDEF(source->handlers->write_header->func_name)) {
- ZVAL_COPY(&ch->handlers->write_header->func_name, &source->handlers->write_header->func_name);
+ if (!Z_ISUNDEF(source->handlers.write_header->func_name)) {
+ ZVAL_COPY(&ch->handlers.write_header->func_name, &source->handlers.write_header->func_name);
}
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
@@ -1923,24 +1908,24 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source)
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
- if (source->handlers->progress) {
- ch->handlers->progress = ecalloc(1, sizeof(php_curl_progress));
- if (!Z_ISUNDEF(source->handlers->progress->func_name)) {
- ZVAL_COPY(&ch->handlers->progress->func_name, &source->handlers->progress->func_name);
+ if (source->handlers.progress) {
+ ch->handlers.progress = ecalloc(1, sizeof(php_curl_callback));
+ if (!Z_ISUNDEF(source->handlers.progress->func_name)) {
+ ZVAL_COPY(&ch->handlers.progress->func_name, &source->handlers.progress->func_name);
}
- ch->handlers->progress->method = source->handlers->progress->method;
curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, (void *) ch);
}
- if (source->handlers->fnmatch) {
- ch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch));
- if (!Z_ISUNDEF(source->handlers->fnmatch->func_name)) {
- ZVAL_COPY(&ch->handlers->fnmatch->func_name, &source->handlers->fnmatch->func_name);
+ if (source->handlers.fnmatch) {
+ ch->handlers.fnmatch = ecalloc(1, sizeof(php_curl_callback));
+ if (!Z_ISUNDEF(source->handlers.fnmatch->func_name)) {
+ ZVAL_COPY(&ch->handlers.fnmatch->func_name, &source->handlers.fnmatch->func_name);
}
- ch->handlers->fnmatch->method = source->handlers->fnmatch->method;
curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, (void *) ch);
}
+ ZVAL_COPY(&ch->private_data, &source->private_data);
+
efree(ch->to_free->slist);
efree(ch->to_free);
ch->to_free = source->to_free;
@@ -2115,6 +2100,78 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
continue;
}
+ if (Z_TYPE_P(current) == IS_OBJECT && instanceof_function(Z_OBJCE_P(current), curl_CURLStringFile_class)) {
+ /* new-style file upload from string */
+ zval *prop, rv;
+ char *type = NULL, *filename = NULL;
+
+ prop = zend_read_property(curl_CURLStringFile_class, Z_OBJ_P(current), "postname", sizeof("postname")-1, 0, &rv);
+ if (EG(exception)) {
+ zend_string_release_ex(string_key, 0);
+ return FAILURE;
+ }
+ ZVAL_DEREF(prop);
+ ZEND_ASSERT(Z_TYPE_P(prop) == IS_STRING);
+
+ filename = Z_STRVAL_P(prop);
+
+ prop = zend_read_property(curl_CURLStringFile_class, Z_OBJ_P(current), "mime", sizeof("mime")-1, 0, &rv);
+ if (EG(exception)) {
+ zend_string_release_ex(string_key, 0);
+ return FAILURE;
+ }
+ ZVAL_DEREF(prop);
+ ZEND_ASSERT(Z_TYPE_P(prop) == IS_STRING);
+
+ type = Z_STRVAL_P(prop);
+
+ prop = zend_read_property(curl_CURLStringFile_class, Z_OBJ_P(current), "data", sizeof("data")-1, 0, &rv);
+ if (EG(exception)) {
+ zend_string_release_ex(string_key, 0);
+ return FAILURE;
+ }
+ ZVAL_DEREF(prop);
+ ZEND_ASSERT(Z_TYPE_P(prop) == IS_STRING);
+
+ postval = Z_STR_P(prop);
+
+#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
+ zval_ptr_dtor(&ch->postfields);
+ ZVAL_COPY(&ch->postfields, zpostfields);
+
+ part = curl_mime_addpart(mime);
+ if (part == NULL) {
+ zend_string_release_ex(string_key, 0);
+ return FAILURE;
+ }
+ if ((form_error = curl_mime_name(part, ZSTR_VAL(string_key))) != CURLE_OK
+ || (form_error = curl_mime_data(part, ZSTR_VAL(postval), ZSTR_LEN(postval))) != CURLE_OK
+ || (form_error = curl_mime_filename(part, filename)) != CURLE_OK
+ || (form_error = curl_mime_type(part, type)) != CURLE_OK) {
+ error = form_error;
+ }
+#else
+ postval = zend_string_copy(postval);
+ zend_llist_add_element(&ch->to_free->buffers, &postval);
+
+ form_error = curl_formadd(&first, &last,
+ CURLFORM_COPYNAME, ZSTR_VAL(string_key),
+ CURLFORM_NAMELENGTH, ZSTR_LEN(string_key),
+ CURLFORM_BUFFER, filename,
+ CURLFORM_CONTENTTYPE, type,
+ CURLFORM_BUFFERPTR, ZSTR_VAL(postval),
+ CURLFORM_BUFFERLENGTH, ZSTR_LEN(postval),
+ CURLFORM_END);
+ if (form_error != CURL_FORMADD_OK) {
+ /* Not nice to convert between enums but we only have place for one error type */
+ error = (CURLcode)form_error;
+ }
+#endif
+
+ zend_string_release_ex(string_key, 0);
+ continue;
+ }
+
postval = zval_get_tmp_string(current, &tmp_postval);
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
@@ -2466,7 +2523,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
{
zend_string *tmp_str;
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
- int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0);
+ int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str));
zend_tmp_string_release(tmp_str);
return ret;
}
@@ -2486,6 +2543,9 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
#if LIBCURL_VERSION_NUM >= 0x072800 /* Available since 7.40.0 */
case CURLOPT_UNIX_SOCKET_PATH:
#endif
+#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */
+ case CURLOPT_DOH_URL:
+#endif
case CURLOPT_KRBLEVEL:
{
if (Z_ISNULL_P(zvalue)) {
@@ -2493,7 +2553,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
} else {
zend_string *tmp_str;
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
- int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0);
+ int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str));
zend_tmp_string_release(tmp_str);
return ret;
}
@@ -2503,11 +2563,9 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
/* Curl private option */
case CURLOPT_PRIVATE:
{
- zend_string *tmp_str;
- zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
- int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 1);
- zend_tmp_string_release(tmp_str);
- return ret;
+ zval_ptr_dtor(&ch->private_data);
+ ZVAL_COPY(&ch->private_data, zvalue);
+ return SUCCESS;
}
/* Curl url option */
@@ -2547,17 +2605,17 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
switch (option) {
case CURLOPT_FILE:
if (!what) {
- if (!Z_ISUNDEF(ch->handlers->write->stream)) {
- zval_ptr_dtor(&ch->handlers->write->stream);
- ZVAL_UNDEF(&ch->handlers->write->stream);
+ if (!Z_ISUNDEF(ch->handlers.write->stream)) {
+ zval_ptr_dtor(&ch->handlers.write->stream);
+ ZVAL_UNDEF(&ch->handlers.write->stream);
}
- ch->handlers->write->fp = NULL;
- ch->handlers->write->method = PHP_CURL_STDOUT;
+ ch->handlers.write->fp = NULL;
+ ch->handlers.write->method = PHP_CURL_STDOUT;
} else if (what->mode[0] != 'r' || what->mode[1] == '+') {
- zval_ptr_dtor(&ch->handlers->write->stream);
- ch->handlers->write->fp = fp;
- ch->handlers->write->method = PHP_CURL_FILE;
- ZVAL_COPY(&ch->handlers->write->stream, zvalue);
+ zval_ptr_dtor(&ch->handlers.write->stream);
+ ch->handlers.write->fp = fp;
+ ch->handlers.write->method = PHP_CURL_FILE;
+ ZVAL_COPY(&ch->handlers.write->stream, zvalue);
} else {
zend_value_error("%s(): The provided file handle must be writable", get_active_function_name());
return FAILURE;
@@ -2565,17 +2623,17 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
break;
case CURLOPT_WRITEHEADER:
if (!what) {
- if (!Z_ISUNDEF(ch->handlers->write_header->stream)) {
- zval_ptr_dtor(&ch->handlers->write_header->stream);
- ZVAL_UNDEF(&ch->handlers->write_header->stream);
+ if (!Z_ISUNDEF(ch->handlers.write_header->stream)) {
+ zval_ptr_dtor(&ch->handlers.write_header->stream);
+ ZVAL_UNDEF(&ch->handlers.write_header->stream);
}
- ch->handlers->write_header->fp = NULL;
- ch->handlers->write_header->method = PHP_CURL_IGNORE;
+ ch->handlers.write_header->fp = NULL;
+ ch->handlers.write_header->method = PHP_CURL_IGNORE;
} else if (what->mode[0] != 'r' || what->mode[1] == '+') {
- zval_ptr_dtor(&ch->handlers->write_header->stream);
- ch->handlers->write_header->fp = fp;
- ch->handlers->write_header->method = PHP_CURL_FILE;
- ZVAL_COPY(&ch->handlers->write_header->stream, zvalue);
+ zval_ptr_dtor(&ch->handlers.write_header->stream);
+ ch->handlers.write_header->fp = fp;
+ ch->handlers.write_header->method = PHP_CURL_FILE;
+ ZVAL_COPY(&ch->handlers.write_header->stream, zvalue);
} else {
zend_value_error("%s(): The provided file handle must be writable", get_active_function_name());
return FAILURE;
@@ -2583,28 +2641,28 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
break;
case CURLOPT_INFILE:
if (!what) {
- if (!Z_ISUNDEF(ch->handlers->read->stream)) {
- zval_ptr_dtor(&ch->handlers->read->stream);
- ZVAL_UNDEF(&ch->handlers->read->stream);
+ if (!Z_ISUNDEF(ch->handlers.read->stream)) {
+ zval_ptr_dtor(&ch->handlers.read->stream);
+ ZVAL_UNDEF(&ch->handlers.read->stream);
}
- ch->handlers->read->fp = NULL;
- ch->handlers->read->res = NULL;
+ ch->handlers.read->fp = NULL;
+ ch->handlers.read->res = NULL;
} else {
- zval_ptr_dtor(&ch->handlers->read->stream);
- ch->handlers->read->fp = fp;
- ch->handlers->read->res = Z_RES_P(zvalue);
- ZVAL_COPY(&ch->handlers->read->stream, zvalue);
+ zval_ptr_dtor(&ch->handlers.read->stream);
+ ch->handlers.read->fp = fp;
+ ch->handlers.read->res = Z_RES_P(zvalue);
+ ZVAL_COPY(&ch->handlers.read->stream, zvalue);
}
break;
case CURLOPT_STDERR:
if (!what) {
- if (!Z_ISUNDEF(ch->handlers->std_err)) {
- zval_ptr_dtor(&ch->handlers->std_err);
- ZVAL_UNDEF(&ch->handlers->std_err);
+ if (!Z_ISUNDEF(ch->handlers.std_err)) {
+ zval_ptr_dtor(&ch->handlers.std_err);
+ ZVAL_UNDEF(&ch->handlers.std_err);
}
} else if (what->mode[0] != 'r' || what->mode[1] == '+') {
- zval_ptr_dtor(&ch->handlers->std_err);
- ZVAL_COPY(&ch->handlers->std_err, zvalue);
+ zval_ptr_dtor(&ch->handlers.std_err);
+ ZVAL_COPY(&ch->handlers.std_err, zvalue);
} else {
zend_value_error("%s(): The provided file handle must be writable", get_active_function_name());
return FAILURE;
@@ -2716,12 +2774,12 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
break;
case CURLOPT_HEADERFUNCTION:
- if (!Z_ISUNDEF(ch->handlers->write_header->func_name)) {
- zval_ptr_dtor(&ch->handlers->write_header->func_name);
- ch->handlers->write_header->fci_cache = empty_fcall_info_cache;
+ if (!Z_ISUNDEF(ch->handlers.write_header->func_name)) {
+ zval_ptr_dtor(&ch->handlers.write_header->func_name);
+ ch->handlers.write_header->fci_cache = empty_fcall_info_cache;
}
- ZVAL_COPY(&ch->handlers->write_header->func_name, zvalue);
- ch->handlers->write_header->method = PHP_CURL_USER;
+ ZVAL_COPY(&ch->handlers.write_header->func_name, zvalue);
+ ch->handlers.write_header->method = PHP_CURL_USER;
break;
case CURLOPT_POSTFIELDS:
@@ -2747,40 +2805,39 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
case CURLOPT_PROGRESSFUNCTION:
curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION, curl_progress);
curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch);
- if (ch->handlers->progress == NULL) {
- ch->handlers->progress = ecalloc(1, sizeof(php_curl_progress));
- } else if (!Z_ISUNDEF(ch->handlers->progress->func_name)) {
- zval_ptr_dtor(&ch->handlers->progress->func_name);
- ch->handlers->progress->fci_cache = empty_fcall_info_cache;
+ if (ch->handlers.progress == NULL) {
+ ch->handlers.progress = ecalloc(1, sizeof(php_curl_callback));
+ } else if (!Z_ISUNDEF(ch->handlers.progress->func_name)) {
+ zval_ptr_dtor(&ch->handlers.progress->func_name);
+ ch->handlers.progress->fci_cache = empty_fcall_info_cache;
}
- ZVAL_COPY(&ch->handlers->progress->func_name, zvalue);
- ch->handlers->progress->method = PHP_CURL_USER;
+ ZVAL_COPY(&ch->handlers.progress->func_name, zvalue);
break;
case CURLOPT_READFUNCTION:
- if (!Z_ISUNDEF(ch->handlers->read->func_name)) {
- zval_ptr_dtor(&ch->handlers->read->func_name);
- ch->handlers->read->fci_cache = empty_fcall_info_cache;
+ if (!Z_ISUNDEF(ch->handlers.read->func_name)) {
+ zval_ptr_dtor(&ch->handlers.read->func_name);
+ ch->handlers.read->fci_cache = empty_fcall_info_cache;
}
- ZVAL_COPY(&ch->handlers->read->func_name, zvalue);
- ch->handlers->read->method = PHP_CURL_USER;
+ ZVAL_COPY(&ch->handlers.read->func_name, zvalue);
+ ch->handlers.read->method = PHP_CURL_USER;
break;
case CURLOPT_RETURNTRANSFER:
if (zend_is_true(zvalue)) {
- ch->handlers->write->method = PHP_CURL_RETURN;
+ ch->handlers.write->method = PHP_CURL_RETURN;
} else {
- ch->handlers->write->method = PHP_CURL_STDOUT;
+ ch->handlers.write->method = PHP_CURL_STDOUT;
}
break;
case CURLOPT_WRITEFUNCTION:
- if (!Z_ISUNDEF(ch->handlers->write->func_name)) {
- zval_ptr_dtor(&ch->handlers->write->func_name);
- ch->handlers->write->fci_cache = empty_fcall_info_cache;
+ if (!Z_ISUNDEF(ch->handlers.write->func_name)) {
+ zval_ptr_dtor(&ch->handlers.write->func_name);
+ ch->handlers.write->fci_cache = empty_fcall_info_cache;
}
- ZVAL_COPY(&ch->handlers->write->func_name, zvalue);
- ch->handlers->write->method = PHP_CURL_USER;
+ ZVAL_COPY(&ch->handlers.write->func_name, zvalue);
+ ch->handlers.write->method = PHP_CURL_USER;
break;
/* Curl off_t options */
@@ -2821,7 +2878,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
return FAILURE;
}
- ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0);
+ ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str));
zend_tmp_string_release(tmp_str);
return ret;
}
@@ -2856,14 +2913,13 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
case CURLOPT_FNMATCH_FUNCTION:
curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_FUNCTION, curl_fnmatch);
curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, ch);
- if (ch->handlers->fnmatch == NULL) {
- ch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch));
- } else if (!Z_ISUNDEF(ch->handlers->fnmatch->func_name)) {
- zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
- ch->handlers->fnmatch->fci_cache = empty_fcall_info_cache;
+ if (ch->handlers.fnmatch == NULL) {
+ ch->handlers.fnmatch = ecalloc(1, sizeof(php_curl_callback));
+ } else if (!Z_ISUNDEF(ch->handlers.fnmatch->func_name)) {
+ zval_ptr_dtor(&ch->handlers.fnmatch->func_name);
+ ch->handlers.fnmatch->fci_cache = empty_fcall_info_cache;
}
- ZVAL_COPY(&ch->handlers->fnmatch->func_name, zvalue);
- ch->handlers->fnmatch->method = PHP_CURL_USER;
+ ZVAL_COPY(&ch->handlers.fnmatch->func_name, zvalue);
break;
default:
@@ -2943,7 +2999,7 @@ PHP_FUNCTION(curl_setopt_array)
Cleanup an execution phase */
void _php_curl_cleanup_handle(php_curl *ch)
{
- smart_str_free(&ch->handlers->write->buf);
+ smart_str_free(&ch->handlers.write->buf);
if (ch->header.str) {
zend_string_release_ex(ch->header.str, 0);
ch->header.str = NULL;
@@ -2975,32 +3031,32 @@ PHP_FUNCTION(curl_exec)
SAVE_CURL_ERROR(ch, error);
if (error != CURLE_OK) {
- smart_str_free(&ch->handlers->write->buf);
+ smart_str_free(&ch->handlers.write->buf);
RETURN_FALSE;
}
- if (!Z_ISUNDEF(ch->handlers->std_err)) {
+ if (!Z_ISUNDEF(ch->handlers.std_err)) {
php_stream *stream;
- stream = (php_stream*)zend_fetch_resource2_ex(&ch->handlers->std_err, NULL, php_file_le_stream(), php_file_le_pstream());
+ stream = (php_stream*)zend_fetch_resource2_ex(&ch->handlers.std_err, NULL, php_file_le_stream(), php_file_le_pstream());
if (stream) {
php_stream_flush(stream);
}
}
- if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.s) {
- smart_str_0(&ch->handlers->write->buf);
- RETURN_STR_COPY(ch->handlers->write->buf.s);
+ if (ch->handlers.write->method == PHP_CURL_RETURN && ch->handlers.write->buf.s) {
+ smart_str_0(&ch->handlers.write->buf);
+ RETURN_STR_COPY(ch->handlers.write->buf.s);
}
/* flush the file handle, so any remaining data is synched to disk */
- if (ch->handlers->write->method == PHP_CURL_FILE && ch->handlers->write->fp) {
- fflush(ch->handlers->write->fp);
+ if (ch->handlers.write->method == PHP_CURL_FILE && ch->handlers.write->fp) {
+ fflush(ch->handlers.write->fp);
}
- if (ch->handlers->write_header->method == PHP_CURL_FILE && ch->handlers->write_header->fp) {
- fflush(ch->handlers->write_header->fp);
+ if (ch->handlers.write_header->method == PHP_CURL_FILE && ch->handlers.write_header->fp) {
+ fflush(ch->handlers.write_header->fp);
}
- if (ch->handlers->write->method == PHP_CURL_RETURN) {
+ if (ch->handlers.write->method == PHP_CURL_RETURN) {
RETURN_EMPTY_STRING();
} else {
RETURN_TRUE;
@@ -3014,7 +3070,7 @@ PHP_FUNCTION(curl_getinfo)
zval *zid;
php_curl *ch;
zend_long option;
- zend_bool option_is_null = 1;
+ bool option_is_null = 1;
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
@@ -3188,6 +3244,13 @@ PHP_FUNCTION(curl_getinfo)
}
break;
}
+ case CURLINFO_PRIVATE:
+ if (!Z_ISUNDEF(ch->private_data)) {
+ RETURN_COPY(&ch->private_data);
+ } else {
+ RETURN_FALSE;
+ }
+ break;
default: {
int type = CURLINFO_TYPEMASK & option;
switch (type) {
@@ -3351,44 +3414,48 @@ static void curl_free_obj(zend_object *object)
/* cURL destructors should be invoked only by last curl handle */
if (--(*ch->clone) == 0) {
- zend_llist_clean(&ch->to_free->str);
zend_llist_clean(&ch->to_free->post);
zend_llist_clean(&ch->to_free->stream);
+
+#if LIBCURL_VERSION_NUM < 0x073800 /* 7.56.0 */
+ zend_llist_clean(&ch->to_free->buffers);
+#endif
+
zend_hash_destroy(ch->to_free->slist);
efree(ch->to_free->slist);
efree(ch->to_free);
efree(ch->clone);
}
- smart_str_free(&ch->handlers->write->buf);
- zval_ptr_dtor(&ch->handlers->write->func_name);
- zval_ptr_dtor(&ch->handlers->read->func_name);
- zval_ptr_dtor(&ch->handlers->write_header->func_name);
- zval_ptr_dtor(&ch->handlers->std_err);
+ smart_str_free(&ch->handlers.write->buf);
+ zval_ptr_dtor(&ch->handlers.write->func_name);
+ zval_ptr_dtor(&ch->handlers.read->func_name);
+ zval_ptr_dtor(&ch->handlers.write_header->func_name);
+ zval_ptr_dtor(&ch->handlers.std_err);
if (ch->header.str) {
zend_string_release_ex(ch->header.str, 0);
}
- zval_ptr_dtor(&ch->handlers->write_header->stream);
- zval_ptr_dtor(&ch->handlers->write->stream);
- zval_ptr_dtor(&ch->handlers->read->stream);
+ zval_ptr_dtor(&ch->handlers.write_header->stream);
+ zval_ptr_dtor(&ch->handlers.write->stream);
+ zval_ptr_dtor(&ch->handlers.read->stream);
- efree(ch->handlers->write);
- efree(ch->handlers->write_header);
- efree(ch->handlers->read);
+ efree(ch->handlers.write);
+ efree(ch->handlers.write_header);
+ efree(ch->handlers.read);
- if (ch->handlers->progress) {
- zval_ptr_dtor(&ch->handlers->progress->func_name);
- efree(ch->handlers->progress);
+ if (ch->handlers.progress) {
+ zval_ptr_dtor(&ch->handlers.progress->func_name);
+ efree(ch->handlers.progress);
}
- if (ch->handlers->fnmatch) {
- zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
- efree(ch->handlers->fnmatch);
+ if (ch->handlers.fnmatch) {
+ zval_ptr_dtor(&ch->handlers.fnmatch->func_name);
+ efree(ch->handlers.fnmatch);
}
- efree(ch->handlers);
zval_ptr_dtor(&ch->postfields);
+ zval_ptr_dtor(&ch->private_data);
if (ch->share) {
OBJ_RELEASE(&ch->share->std);
@@ -3421,43 +3488,43 @@ PHP_FUNCTION(curl_strerror)
Reset all handlers of a given php_curl */
static void _php_curl_reset_handlers(php_curl *ch)
{
- if (!Z_ISUNDEF(ch->handlers->write->stream)) {
- zval_ptr_dtor(&ch->handlers->write->stream);
- ZVAL_UNDEF(&ch->handlers->write->stream);
+ if (!Z_ISUNDEF(ch->handlers.write->stream)) {
+ zval_ptr_dtor(&ch->handlers.write->stream);
+ ZVAL_UNDEF(&ch->handlers.write->stream);
}
- ch->handlers->write->fp = NULL;
- ch->handlers->write->method = PHP_CURL_STDOUT;
+ ch->handlers.write->fp = NULL;
+ ch->handlers.write->method = PHP_CURL_STDOUT;
- if (!Z_ISUNDEF(ch->handlers->write_header->stream)) {
- zval_ptr_dtor(&ch->handlers->write_header->stream);
- ZVAL_UNDEF(&ch->handlers->write_header->stream);
+ if (!Z_ISUNDEF(ch->handlers.write_header->stream)) {
+ zval_ptr_dtor(&ch->handlers.write_header->stream);
+ ZVAL_UNDEF(&ch->handlers.write_header->stream);
}
- ch->handlers->write_header->fp = NULL;
- ch->handlers->write_header->method = PHP_CURL_IGNORE;
+ ch->handlers.write_header->fp = NULL;
+ ch->handlers.write_header->method = PHP_CURL_IGNORE;
- if (!Z_ISUNDEF(ch->handlers->read->stream)) {
- zval_ptr_dtor(&ch->handlers->read->stream);
- ZVAL_UNDEF(&ch->handlers->read->stream);
+ if (!Z_ISUNDEF(ch->handlers.read->stream)) {
+ zval_ptr_dtor(&ch->handlers.read->stream);
+ ZVAL_UNDEF(&ch->handlers.read->stream);
}
- ch->handlers->read->fp = NULL;
- ch->handlers->read->res = NULL;
- ch->handlers->read->method = PHP_CURL_DIRECT;
+ ch->handlers.read->fp = NULL;
+ ch->handlers.read->res = NULL;
+ ch->handlers.read->method = PHP_CURL_DIRECT;
- if (!Z_ISUNDEF(ch->handlers->std_err)) {
- zval_ptr_dtor(&ch->handlers->std_err);
- ZVAL_UNDEF(&ch->handlers->std_err);
+ if (!Z_ISUNDEF(ch->handlers.std_err)) {
+ zval_ptr_dtor(&ch->handlers.std_err);
+ ZVAL_UNDEF(&ch->handlers.std_err);
}
- if (ch->handlers->progress) {
- zval_ptr_dtor(&ch->handlers->progress->func_name);
- efree(ch->handlers->progress);
- ch->handlers->progress = NULL;
+ if (ch->handlers.progress) {
+ zval_ptr_dtor(&ch->handlers.progress->func_name);
+ efree(ch->handlers.progress);
+ ch->handlers.progress = NULL;
}
- if (ch->handlers->fnmatch) {
- zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
- efree(ch->handlers->fnmatch);
- ch->handlers->fnmatch = NULL;
+ if (ch->handlers.fnmatch) {
+ zval_ptr_dtor(&ch->handlers.fnmatch->func_name);
+ efree(ch->handlers.fnmatch);
+ ch->handlers.fnmatch = NULL;
}
}