2000-07-16 19:37:33 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2019-01-30 09:03:12 +00:00
|
|
|
| Copyright (c) The PHP Group |
|
2000-07-16 19:37:33 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 12:51:34 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2000-07-16 19:37:33 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 12:51:34 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2000-07-16 19:37:33 +00:00
|
|
|
| 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 |
|
2014-12-05 20:59:46 +00:00
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
2000-07-16 19:37:33 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2001-02-15 16:20:13 +00:00
|
|
|
| Author: Sterling Hughes <sterling@php.net> |
|
2000-07-16 19:37:33 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2003-02-25 07:19:44 +00:00
|
|
|
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
|
|
|
|
|
2001-05-24 10:07:29 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2000-07-16 19:37:33 +00:00
|
|
|
|
|
|
|
#include "php.h"
|
2020-06-17 14:05:55 +00:00
|
|
|
#include "Zend/zend_interfaces.h"
|
|
|
|
#include "Zend/zend_exceptions.h"
|
2000-07-16 19:37:33 +00:00
|
|
|
|
2020-05-12 20:36:08 +00:00
|
|
|
#ifdef HAVE_CURL
|
2000-07-16 19:37:33 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2000-09-30 03:09:54 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-08-15 16:50:14 +00:00
|
|
|
#ifdef PHP_WIN32
|
2003-02-16 03:48:49 +00:00
|
|
|
#include <winsock2.h>
|
2000-08-20 08:28:00 +00:00
|
|
|
#include <sys/types.h>
|
2000-08-15 16:50:14 +00:00
|
|
|
#endif
|
2000-09-30 03:09:54 +00:00
|
|
|
|
2000-07-16 19:37:33 +00:00
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <curl/easy.h>
|
2000-09-30 03:09:54 +00:00
|
|
|
|
2004-03-22 18:42:03 +00:00
|
|
|
/* As of curl 7.11.1 this is no longer defined inside curl.h */
|
|
|
|
#ifndef HttpPost
|
|
|
|
#define HttpPost curl_httppost
|
|
|
|
#endif
|
|
|
|
|
2005-10-25 14:32:33 +00:00
|
|
|
/* {{{ cruft for thread safe SSL crypto locks */
|
2020-01-06 09:40:43 +00:00
|
|
|
#if defined(ZTS) && defined(HAVE_CURL_OLD_OPENSSL)
|
2020-01-06 09:16:42 +00:00
|
|
|
# if defined(HAVE_OPENSSL_CRYPTO_H)
|
2005-10-26 11:33:25 +00:00
|
|
|
# define PHP_CURL_NEED_OPENSSL_TSL
|
|
|
|
# include <openssl/crypto.h>
|
2020-01-06 09:16:42 +00:00
|
|
|
# else
|
|
|
|
# warning \
|
2019-06-12 13:26:06 +00:00
|
|
|
"libcurl was compiled with OpenSSL support, but configure could not find " \
|
|
|
|
"openssl/crypto.h; thus no SSL crypto locking callbacks will be set, which may " \
|
2005-10-26 11:33:25 +00:00
|
|
|
"cause random crashes on SSL requests"
|
2020-01-06 09:16:42 +00:00
|
|
|
# endif
|
2020-01-06 09:40:43 +00:00
|
|
|
#endif /* ZTS && HAVE_CURL_OLD_OPENSSL */
|
2005-10-25 14:32:33 +00:00
|
|
|
/* }}} */
|
|
|
|
|
2001-08-02 19:28:33 +00:00
|
|
|
#define SMART_STR_PREALLOC 4096
|
|
|
|
|
2014-09-20 20:42:02 +00:00
|
|
|
#include "zend_smart_str.h"
|
2000-07-16 19:37:33 +00:00
|
|
|
#include "ext/standard/info.h"
|
2000-11-23 15:57:24 +00:00
|
|
|
#include "ext/standard/file.h"
|
2005-03-14 09:02:23 +00:00
|
|
|
#include "ext/standard/url.h"
|
2000-07-16 19:37:33 +00:00
|
|
|
#include "php_curl.h"
|
2019-08-18 12:48:23 +00:00
|
|
|
#include "curl_arginfo.h"
|
2000-07-16 19:37:33 +00:00
|
|
|
|
2006-01-26 13:23:33 +00:00
|
|
|
#ifdef PHP_CURL_NEED_OPENSSL_TSL /* {{{ */
|
|
|
|
static MUTEX_T *php_curl_openssl_tsl = NULL;
|
|
|
|
|
2019-04-11 10:56:42 +00:00
|
|
|
/* Locking callbacks are no longer used since OpenSSL 1.1. Mark the functions as unused to
|
|
|
|
* avoid warnings due to this. */
|
|
|
|
static ZEND_ATTRIBUTE_UNUSED void php_curl_ssl_lock(int mode, int n, const char * file, int line)
|
2006-01-26 13:23:33 +00:00
|
|
|
{
|
|
|
|
if (mode & CRYPTO_LOCK) {
|
|
|
|
tsrm_mutex_lock(php_curl_openssl_tsl[n]);
|
|
|
|
} else {
|
|
|
|
tsrm_mutex_unlock(php_curl_openssl_tsl[n]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-11 10:56:42 +00:00
|
|
|
static ZEND_ATTRIBUTE_UNUSED unsigned long php_curl_ssl_id(void)
|
2006-01-26 13:23:33 +00:00
|
|
|
{
|
|
|
|
return (unsigned long) tsrm_thread_id();
|
|
|
|
}
|
2005-10-25 14:32:33 +00:00
|
|
|
#endif
|
2006-01-26 13:23:33 +00:00
|
|
|
/* }}} */
|
|
|
|
|
2014-08-25 17:24:55 +00:00
|
|
|
#define CAAL(s, v) add_assoc_long_ex(return_value, s, sizeof(s) - 1, (zend_long) v);
|
2014-05-09 04:17:09 +00:00
|
|
|
#define CAAD(s, v) add_assoc_double_ex(return_value, s, sizeof(s) - 1, (double) v);
|
|
|
|
#define CAAS(s, v) add_assoc_string_ex(return_value, s, sizeof(s) - 1, (char *) (v ? v : ""));
|
2016-02-08 11:36:14 +00:00
|
|
|
#define CAASTR(s, v) add_assoc_str_ex(return_value, s, sizeof(s) - 1, \
|
|
|
|
v ? zend_string_copy(v) : ZSTR_EMPTY_ALLOC());
|
2014-05-09 04:17:09 +00:00
|
|
|
#define CAAZ(s, v) add_assoc_zval_ex(return_value, s, sizeof(s) -1 , (zval *) v);
|
2002-11-08 17:58:43 +00:00
|
|
|
|
2006-12-26 16:55:56 +00:00
|
|
|
#if defined(PHP_WIN32) || defined(__GNUC__)
|
2009-05-18 12:51:05 +00:00
|
|
|
# define php_curl_ret(__ret) RETVAL_FALSE; return __ret;
|
2006-12-26 16:55:56 +00:00
|
|
|
#else
|
2009-05-18 12:51:05 +00:00
|
|
|
# define php_curl_ret(__ret) RETVAL_FALSE; return;
|
2006-12-26 16:55:56 +00:00
|
|
|
#endif
|
|
|
|
|
2016-06-21 21:40:50 +00:00
|
|
|
static int php_curl_option_str(php_curl *ch, zend_long option, const char *str, const size_t len, zend_bool make_copy)
|
2009-05-18 12:51:05 +00:00
|
|
|
{
|
|
|
|
CURLcode error = CURLE_OK;
|
2013-11-18 04:06:27 +00:00
|
|
|
|
2014-09-29 00:53:49 +00:00
|
|
|
if (strlen(str) != len) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Curl option contains invalid characters (\\0)");
|
2014-10-14 18:42:33 +00:00
|
|
|
return FAILURE;
|
2014-09-29 00:53:49 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 18:38:32 +00:00
|
|
|
if (make_copy) {
|
2014-10-14 18:17:48 +00:00
|
|
|
char *copystr;
|
2013-11-18 04:06:27 +00:00
|
|
|
|
2014-10-14 18:17:48 +00:00
|
|
|
/* 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, ©str);
|
|
|
|
} else {
|
|
|
|
error = curl_easy_setopt(ch->cp, option, str);
|
2013-11-18 04:06:27 +00:00
|
|
|
}
|
|
|
|
|
2019-05-13 08:21:46 +00:00
|
|
|
SAVE_CURL_ERROR(ch, error);
|
2014-10-14 18:17:48 +00:00
|
|
|
|
|
|
|
return error == CURLE_OK ? SUCCESS : FAILURE;
|
|
|
|
}
|
|
|
|
|
2016-06-21 21:40:50 +00:00
|
|
|
static int php_curl_option_url(php_curl *ch, const char *url, const size_t len) /* {{{ */
|
2014-10-14 18:17:48 +00:00
|
|
|
{
|
2010-04-26 23:53:30 +00:00
|
|
|
/* Disable file:// if open_basedir are used */
|
|
|
|
if (PG(open_basedir) && *PG(open_basedir)) {
|
2013-11-18 04:06:27 +00:00
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_PROTOCOLS, CURLPROTO_ALL & ~CURLPROTO_FILE);
|
2005-03-14 09:02:23 +00:00
|
|
|
}
|
2009-05-18 10:31:08 +00:00
|
|
|
|
2017-12-03 11:23:25 +00:00
|
|
|
#if LIBCURL_VERSION_NUM > 0x073800 && defined(PHP_WIN32)
|
|
|
|
if (len > sizeof("file://") - 1 && '/' != url[sizeof("file://") - 1] && !strncmp("file://", url, sizeof("file://") - 1) && len < MAXPATHLEN - 2) {
|
|
|
|
char _tmp[MAXPATHLEN] = {0};
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
return php_curl_option_str(ch, CURLOPT_URL, url, len, 0);
|
2009-05-18 10:31:08 +00:00
|
|
|
}
|
2009-05-18 12:51:05 +00:00
|
|
|
/* }}} */
|
2005-03-14 09:02:23 +00:00
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
|
2011-09-12 09:16:04 +00:00
|
|
|
{
|
|
|
|
php_stream *stream;
|
2015-05-08 05:54:28 +00:00
|
|
|
|
|
|
|
ZEND_ASSERT(ch && ch->handlers);
|
2011-09-12 09:16:04 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->std_err)) {
|
2015-02-02 06:45:19 +00:00
|
|
|
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->std_err, NULL, php_file_le_stream(), php_file_le_pstream());
|
2011-09-12 09:16:04 +00:00
|
|
|
if (stream == NULL) {
|
|
|
|
if (reporterror) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "CURLOPT_STDERR resource has gone away, resetting to stderr");
|
2011-09-12 09:16:04 +00:00
|
|
|
}
|
|
|
|
zval_ptr_dtor(&ch->handlers->std_err);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_UNDEF(&ch->handlers->std_err);
|
2011-09-12 09:16:04 +00:00
|
|
|
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr);
|
|
|
|
}
|
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
if (ch->handlers->read && !Z_ISUNDEF(ch->handlers->read->stream)) {
|
2015-02-02 06:45:19 +00:00
|
|
|
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->read->stream, NULL, php_file_le_stream(), php_file_le_pstream());
|
2011-09-12 09:16:04 +00:00
|
|
|
if (stream == NULL) {
|
|
|
|
if (reporterror) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "CURLOPT_INFILE resource has gone away, resetting to default");
|
2011-09-12 09:16:04 +00:00
|
|
|
}
|
|
|
|
zval_ptr_dtor(&ch->handlers->read->stream);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_UNDEF(&ch->handlers->read->stream);
|
|
|
|
ch->handlers->read->res = NULL;
|
2011-09-12 09:16:04 +00:00
|
|
|
ch->handlers->read->fp = 0;
|
|
|
|
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
|
|
|
|
}
|
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
if (ch->handlers->write_header && !Z_ISUNDEF(ch->handlers->write_header->stream)) {
|
2015-02-02 06:45:19 +00:00
|
|
|
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->write_header->stream, NULL, php_file_le_stream(), php_file_le_pstream());
|
2011-09-12 09:16:04 +00:00
|
|
|
if (stream == NULL) {
|
|
|
|
if (reporterror) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "CURLOPT_WRITEHEADER resource has gone away, resetting to default");
|
2011-09-12 09:16:04 +00:00
|
|
|
}
|
|
|
|
zval_ptr_dtor(&ch->handlers->write_header->stream);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_UNDEF(&ch->handlers->write_header->stream);
|
2011-09-12 09:16:04 +00:00
|
|
|
ch->handlers->write_header->fp = 0;
|
|
|
|
|
|
|
|
ch->handlers->write_header->method = PHP_CURL_IGNORE;
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
|
|
|
|
}
|
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
if (ch->handlers->write && !Z_ISUNDEF(ch->handlers->write->stream)) {
|
2015-02-02 06:45:19 +00:00
|
|
|
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers->write->stream, NULL, php_file_le_stream(), php_file_le_pstream());
|
2011-09-12 09:16:04 +00:00
|
|
|
if (stream == NULL) {
|
|
|
|
if (reporterror) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "CURLOPT_FILE resource has gone away, resetting to default");
|
2011-09-12 09:16:04 +00:00
|
|
|
}
|
|
|
|
zval_ptr_dtor(&ch->handlers->write->stream);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_UNDEF(&ch->handlers->write->stream);
|
2011-09-12 09:16:04 +00:00
|
|
|
ch->handlers->write->fp = 0;
|
|
|
|
|
|
|
|
ch->handlers->write->method = PHP_CURL_STDOUT;
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
|
|
|
|
}
|
|
|
|
}
|
2015-04-20 03:48:21 +00:00
|
|
|
return;
|
2011-09-12 09:16:04 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_module_entry */
|
2000-07-16 19:37:33 +00:00
|
|
|
zend_module_entry curl_module_entry = {
|
2001-10-11 23:33:59 +00:00
|
|
|
STANDARD_MODULE_HEADER,
|
2000-07-16 19:37:33 +00:00
|
|
|
"curl",
|
2020-04-04 18:41:42 +00:00
|
|
|
ext_functions,
|
2000-07-16 19:37:33 +00:00
|
|
|
PHP_MINIT(curl),
|
2001-09-22 00:38:59 +00:00
|
|
|
PHP_MSHUTDOWN(curl),
|
2000-08-17 02:14:41 +00:00
|
|
|
NULL,
|
2000-07-16 19:37:33 +00:00
|
|
|
NULL,
|
|
|
|
PHP_MINFO(curl),
|
2015-03-23 19:13:59 +00:00
|
|
|
PHP_CURL_VERSION,
|
2000-07-16 19:37:33 +00:00
|
|
|
STANDARD_MODULE_PROPERTIES
|
|
|
|
};
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2000-07-16 19:37:33 +00:00
|
|
|
|
|
|
|
#ifdef COMPILE_DL_CURL
|
|
|
|
ZEND_GET_MODULE (curl)
|
|
|
|
#endif
|
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
/* CurlHandle class */
|
|
|
|
|
|
|
|
zend_class_entry *curl_ce;
|
|
|
|
zend_class_entry *curl_share_ce;
|
|
|
|
static zend_object_handlers curl_object_handlers;
|
|
|
|
|
|
|
|
static zend_object *curl_create_object(zend_class_entry *class_type);
|
|
|
|
static void curl_free_obj(zend_object *object);
|
|
|
|
static HashTable *curl_get_gc(zend_object *object, zval **table, int *n);
|
|
|
|
static zend_function *curl_get_constructor(zend_object *object);
|
|
|
|
static zend_object *curl_clone_obj(zend_object *object);
|
|
|
|
php_curl *init_curl_handle_into_zval(zval *curl);
|
|
|
|
static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields);
|
|
|
|
|
2011-04-01 17:10:52 +00:00
|
|
|
/* {{{ PHP_INI_BEGIN */
|
|
|
|
PHP_INI_BEGIN()
|
|
|
|
PHP_INI_ENTRY("curl.cainfo", "", PHP_INI_SYSTEM, NULL)
|
|
|
|
PHP_INI_END()
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ PHP_MINFO_FUNCTION */
|
2000-07-16 19:37:33 +00:00
|
|
|
PHP_MINFO_FUNCTION(curl)
|
|
|
|
{
|
2008-11-11 12:26:04 +00:00
|
|
|
curl_version_info_data *d;
|
|
|
|
char **p;
|
|
|
|
char str[1024];
|
|
|
|
size_t n = 0;
|
|
|
|
|
|
|
|
d = curl_version_info(CURLVERSION_NOW);
|
2000-08-13 19:32:09 +00:00
|
|
|
php_info_print_table_start();
|
2006-09-09 20:04:50 +00:00
|
|
|
php_info_print_table_row(2, "cURL support", "enabled");
|
2008-11-11 12:26:04 +00:00
|
|
|
php_info_print_table_row(2, "cURL Information", d->version);
|
|
|
|
sprintf(str, "%d", d->age);
|
|
|
|
php_info_print_table_row(2, "Age", str);
|
|
|
|
|
2009-01-25 17:12:36 +00:00
|
|
|
/* To update on each new cURL release using src/main.c in cURL sources */
|
2009-05-18 12:51:05 +00:00
|
|
|
if (d->features) {
|
2009-01-25 17:12:36 +00:00
|
|
|
struct feat {
|
|
|
|
const char *name;
|
|
|
|
int bitmask;
|
|
|
|
};
|
2008-11-11 12:26:04 +00:00
|
|
|
|
2009-01-25 17:12:36 +00:00
|
|
|
unsigned int i;
|
2008-11-11 12:26:04 +00:00
|
|
|
|
2009-01-25 17:12:36 +00:00
|
|
|
static const struct feat feats[] = {
|
|
|
|
{"AsynchDNS", CURL_VERSION_ASYNCHDNS},
|
2011-12-03 21:24:19 +00:00
|
|
|
{"CharConv", CURL_VERSION_CONV},
|
2009-01-25 17:12:36 +00:00
|
|
|
{"Debug", CURL_VERSION_DEBUG},
|
|
|
|
{"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
|
|
|
|
{"IDN", CURL_VERSION_IDN},
|
|
|
|
{"IPv6", CURL_VERSION_IPV6},
|
2011-12-03 21:24:19 +00:00
|
|
|
{"krb4", CURL_VERSION_KERBEROS4},
|
2009-01-25 17:12:36 +00:00
|
|
|
{"Largefile", CURL_VERSION_LARGEFILE},
|
2011-12-03 21:24:19 +00:00
|
|
|
{"libz", CURL_VERSION_LIBZ},
|
2009-01-25 17:12:36 +00:00
|
|
|
{"NTLM", CURL_VERSION_NTLM},
|
2011-12-03 21:24:19 +00:00
|
|
|
{"NTLMWB", CURL_VERSION_NTLM_WB},
|
2009-01-25 17:12:36 +00:00
|
|
|
{"SPNEGO", CURL_VERSION_SPNEGO},
|
|
|
|
{"SSL", CURL_VERSION_SSL},
|
|
|
|
{"SSPI", CURL_VERSION_SSPI},
|
2011-12-03 21:24:19 +00:00
|
|
|
{"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
|
2014-10-03 19:45:51 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
|
|
|
|
{"HTTP2", CURL_VERSION_HTTP2},
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072600 /* 7.38.0 */
|
|
|
|
{"GSSAPI", CURL_VERSION_GSSAPI},
|
2016-04-27 22:43:41 +00:00
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072800 /* 7.40.0 */
|
|
|
|
{"KERBEROS5", CURL_VERSION_KERBEROS5},
|
|
|
|
{"UNIX_SOCKETS", CURL_VERSION_UNIX_SOCKETS},
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072f00 /* 7.47.0 */
|
|
|
|
{"PSL", CURL_VERSION_PSL},
|
2018-10-03 23:43:59 +00:00
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073400 /* 7.52.0 */
|
|
|
|
{"HTTPS_PROXY", CURL_VERSION_HTTPS_PROXY},
|
2018-10-08 14:15:20 +00:00
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
|
|
|
|
{"MULTI_SSL", CURL_VERSION_MULTI_SSL},
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073900 /* 7.57.0 */
|
|
|
|
{"BROTLI", CURL_VERSION_BROTLI},
|
2008-11-11 12:26:04 +00:00
|
|
|
#endif
|
2009-01-26 15:19:55 +00:00
|
|
|
{NULL, 0}
|
2009-01-25 17:12:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
php_info_print_table_row(1, "Features");
|
|
|
|
for(i=0; i<sizeof(feats)/sizeof(feats[0]); i++) {
|
|
|
|
if (feats[i].name) {
|
|
|
|
php_info_print_table_row(2, feats[i].name, d->features & feats[i].bitmask ? "Yes" : "No");
|
|
|
|
}
|
|
|
|
}
|
2008-11-11 12:26:04 +00:00
|
|
|
}
|
2009-01-25 17:12:36 +00:00
|
|
|
|
2008-11-11 12:26:04 +00:00
|
|
|
n = 0;
|
|
|
|
p = (char **) d->protocols;
|
|
|
|
while (*p != NULL) {
|
|
|
|
n += sprintf(str + n, "%s%s", *p, *(p + 1) != NULL ? ", " : "");
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
php_info_print_table_row(2, "Protocols", str);
|
|
|
|
|
|
|
|
php_info_print_table_row(2, "Host", d->host);
|
|
|
|
|
|
|
|
if (d->ssl_version) {
|
|
|
|
php_info_print_table_row(2, "SSL Version", d->ssl_version);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->libz_version) {
|
|
|
|
php_info_print_table_row(2, "ZLib Version", d->libz_version);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CURLVERSION_SECOND) && CURLVERSION_NOW >= CURLVERSION_SECOND
|
|
|
|
if (d->ares) {
|
|
|
|
php_info_print_table_row(2, "ZLib Version", d->ares);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CURLVERSION_THIRD) && CURLVERSION_NOW >= CURLVERSION_THIRD
|
|
|
|
if (d->libidn) {
|
|
|
|
php_info_print_table_row(2, "libIDN Version", d->libidn);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (d->iconv_ver_num) {
|
|
|
|
php_info_print_table_row(2, "IconV Version", d->iconv_ver_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->libssh_version) {
|
|
|
|
php_info_print_table_row(2, "libSSH Version", d->libssh_version);
|
|
|
|
}
|
2020-01-18 09:05:07 +00:00
|
|
|
|
2000-08-13 19:32:09 +00:00
|
|
|
php_info_print_table_end();
|
2018-06-30 12:10:31 +00:00
|
|
|
|
|
|
|
DISPLAY_INI_ENTRIES();
|
2000-07-16 19:37:33 +00:00
|
|
|
}
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2000-07-16 19:37:33 +00:00
|
|
|
|
2014-08-25 17:24:55 +00:00
|
|
|
#define REGISTER_CURL_CONSTANT(__c) REGISTER_LONG_CONSTANT(#__c, __c, CONST_CS | CONST_PERSISTENT)
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ PHP_MINIT_FUNCTION */
|
2000-07-16 19:37:33 +00:00
|
|
|
PHP_MINIT_FUNCTION(curl)
|
|
|
|
{
|
2011-04-01 17:10:52 +00:00
|
|
|
REGISTER_INI_ENTRIES();
|
|
|
|
|
2009-05-04 14:11:45 +00:00
|
|
|
/* See http://curl.haxx.se/lxr/source/docs/libcurl/symbols-in-versions
|
2009-05-26 15:49:15 +00:00
|
|
|
or curl src/docs/libcurl/symbols-in-versions for a (almost) complete list
|
2009-05-04 14:11:45 +00:00
|
|
|
of options and which version they were introduced */
|
|
|
|
|
2000-08-15 16:50:14 +00:00
|
|
|
/* Constants for curl_setopt() */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_AUTOREFERER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_BINARYTRANSFER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_BUFFERSIZE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CAINFO);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CAPATH);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_COOKIE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_COOKIEFILE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_COOKIEJAR);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_COOKIESESSION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CRLF);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CUSTOMREQUEST);
|
2002-07-31 22:10:58 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DNS_CACHE_TIMEOUT);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DNS_USE_GLOBAL_CACHE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_EGDSOCKET);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_ENCODING);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FAILONERROR);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FILE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FILETIME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FOLLOWLOCATION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FORBID_REUSE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FRESH_CONNECT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTPAPPEND);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTPLISTONLY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTPPORT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPRT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPSV);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HEADER);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HEADERFUNCTION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HTTP200ALIASES);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HTTPGET);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HTTPHEADER);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HTTPPROXYTUNNEL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_VERSION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_INFILE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_INFILESIZE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_INTERFACE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_KRB4LEVEL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_LIMIT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_TIME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_MAXCONNECTS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_MAXREDIRS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_NETRC);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_NOBODY);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_NOPROGRESS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_NOSIGNAL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PORT);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_POST);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_POSTFIELDS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_POSTQUOTE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PREQUOTE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PRIVATE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROGRESSFUNCTION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXYPORT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXYTYPE);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERPWD);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PUT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_QUOTE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RANDOM_FILE);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RANGE);
|
2012-09-22 14:04:51 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_READDATA);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_READFUNCTION);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_REFERER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RESUME_FROM);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RETURNTRANSFER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SHARE);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTPASSWD);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTTYPE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE_DEFAULT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYPASSWD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYTYPE);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSLVERSION);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSL_CIPHER_LIST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYHOST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYPEER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_STDERR);
|
2012-12-28 05:51:04 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TELNETOPTIONS);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TIMECONDITION);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TIMEVALUE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TRANSFERTEXT);
|
2003-06-19 22:12:21 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_UNRESTRICTED_AUTH);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_UPLOAD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_URL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_USERAGENT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_USERPWD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_VERBOSE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_WRITEFUNCTION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_WRITEHEADER);
|
2004-08-18 21:27:24 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_ABORTED_BY_CALLBACK);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_BAD_CALLING_ORDER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_BAD_CONTENT_ENCODING);
|
2012-08-25 05:21:17 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_BAD_DOWNLOAD_RESUME);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_BAD_FUNCTION_ARGUMENT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_BAD_PASSWORD_ENTERED);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_COULDNT_CONNECT);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_HOST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_PROXY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FAILED_INIT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FILE_COULDNT_READ_FILE);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_ACCESS_DENIED);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_BAD_DOWNLOAD_RESUME);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_GET_HOST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_RECONNECT);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_GET_SIZE);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_RETR_FILE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_ASCII);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_BINARY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_STOR_FILE);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_USE_REST);
|
2012-12-28 05:51:04 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_PARTIAL_FILE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_PORT_FAILED);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_QUOTE_ERROR);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_USER_PASSWORD_INCORRECT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_227_FORMAT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASS_REPLY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASV_REPLY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_SERVER_REPLY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_USER_REPLY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_WRITE_ERROR);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FUNCTION_NOT_FOUND);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_GOT_NOTHING);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_HTTP_NOT_FOUND);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_HTTP_PORT_FAILED);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_HTTP_POST_ERROR);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_HTTP_RANGE_ERROR);
|
2012-08-25 05:21:17 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_HTTP_RETURNED_ERROR);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_LDAP_CANNOT_BIND);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_LDAP_SEARCH_FAILED);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_LIBRARY_NOT_FOUND);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_MALFORMAT_USER);
|
2001-09-22 00:38:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_OBSOLETE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_OK);
|
2012-08-25 05:21:17 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEDOUT);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEOUTED);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_OUT_OF_MEMORY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_PARTIAL_FILE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_READ_ERROR);
|
2004-04-29 16:25:42 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_RECV_ERROR);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SEND_ERROR);
|
2004-04-29 16:25:42 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SHARE_IN_USE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT);
|
2004-04-29 16:25:42 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSL_CERTPROBLEM);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSL_CIPHER);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSL_CONNECT_ERROR);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_NOTFOUND);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_SETFAILED);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE);
|
2016-09-15 10:13:46 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072700 /* Available since 7.39.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSL_PINNEDPUBKEYNOTMATCH);
|
|
|
|
#endif
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_TELNET_OPTION_SYNTAX);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_TOO_MANY_REDIRECTS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_UNKNOWN_TELNET_OPTION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_UNSUPPORTED_PROTOCOL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT_USER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_WRITE_ERROR);
|
|
|
|
|
|
|
|
/* cURL info constants */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_CONNECT_TIME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_UPLOAD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_TYPE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_EFFECTIVE_URL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_FILETIME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_HEADER_OUT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_HEADER_SIZE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CODE);
|
2012-08-25 05:21:17 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_LASTONE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_NAMELOOKUP_TIME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_PRETRANSFER_TIME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_PRIVATE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_TIME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_REQUEST_SIZE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SIZE_DOWNLOAD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SIZE_UPLOAD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SPEED_DOWNLOAD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SPEED_UPLOAD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SSL_VERIFYRESULT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_STARTTRANSFER_TIME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_TOTAL_TIME);
|
|
|
|
|
2013-01-29 06:22:59 +00:00
|
|
|
/* Other */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLMSG_DONE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLVERSION_NOW);
|
|
|
|
|
|
|
|
/* Curl Multi Constants */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLM_BAD_EASY_HANDLE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLM_BAD_HANDLE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLM_CALL_MULTI_PERFORM);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLM_INTERNAL_ERROR);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLM_OK);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLM_OUT_OF_MEMORY);
|
2016-03-01 06:30:04 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072001 /* Available since 7.32.1 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLM_ADDED_ALREADY);
|
|
|
|
#endif
|
2011-12-01 21:48:07 +00:00
|
|
|
|
|
|
|
/* Curl proxy constants */
|
2002-11-13 22:25:33 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROXY_HTTP);
|
2009-05-18 11:18:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS4);
|
2002-11-13 22:25:33 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS5);
|
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* Curl Share constants */
|
2012-08-26 13:03:45 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLSHOPT_NONE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLSHOPT_SHARE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSHOPT_UNSHARE);
|
2002-11-09 13:52:00 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* Curl Http Version constants (CURLOPT_HTTP_VERSION) */
|
2002-11-09 13:52:00 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_0);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_1);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_NONE);
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* Curl Lock constants */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_COOKIE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_DNS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_SSL_SESSION);
|
2002-11-13 22:25:33 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* Curl NETRC constants (CURLOPT_NETRC) */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_NETRC_IGNORED);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_NETRC_OPTIONAL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_NETRC_REQUIRED);
|
|
|
|
|
|
|
|
/* Curl SSL Version constants (CURLOPT_SSLVERSION) */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_DEFAULT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv2);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv3);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1);
|
2013-01-29 06:22:59 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* Curl TIMECOND constants (CURLOPT_TIMECONDITION) */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFMODSINCE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD);
|
2012-08-26 13:03:45 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_TIMECOND_NONE);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
|
|
|
/* Curl version constants */
|
2018-10-08 14:15:20 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_ASYNCHDNS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_CONV);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_DEBUG);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_GSSNEGOTIATE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_IDN);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS4);
|
2018-10-08 14:15:20 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_LARGEFILE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_LIBZ);
|
2018-10-08 14:15:20 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_NTLM);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_SPNEGO);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_SSL);
|
2018-10-08 14:15:20 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_SSPI);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2017-12-19 22:16:06 +00:00
|
|
|
/* Available since 7.10.6 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH);
|
|
|
|
/* http authentication options */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_ANY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_ANYSAFE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_BASIC);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_GSSNEGOTIATE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_NONE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_NTLM);
|
|
|
|
|
2017-12-19 22:16:06 +00:00
|
|
|
/* Available since 7.10.7 */
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CONNECTCODE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_CREATE_MISSING_DIRS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXYAUTH);
|
|
|
|
|
2017-12-19 22:16:06 +00:00
|
|
|
/* Available since 7.10.8 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FILESIZE_EXCEEDED);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_LDAP_INVALID_URL);
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_HTTPAUTH_AVAIL);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_RESPONSE_CODE);
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_PROXYAUTH_AVAIL);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_RESPONSE_TIMEOUT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_IPRESOLVE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_MAXFILESIZE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V4);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V6);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_WHATEVER);
|
|
|
|
|
2017-12-19 22:16:06 +00:00
|
|
|
/* Available since 7.11.0 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_FTP_SSL_FAILED);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPSSL_CONTROL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPSSL_NONE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPSSL_TRY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_NETRC_FILE);
|
2017-12-19 22:16:06 +00:00
|
|
|
|
|
|
|
/* Available since 7.11.2 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.12.2 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPAUTH_DEFAULT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPAUTH_SSL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPAUTH_TLS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTPSSLAUTH);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.13.0 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_ACCOUNT);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.12.2 */
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_OS_ERRNO);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.12.3 */
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_NUM_CONNECTS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SSL_ENGINES);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.14.1 */
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_COOKIELIST);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_COOKIELIST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_IGNORE_CONTENT_LENGTH);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.15.0 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_SKIP_PASV_IP);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.15.1 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_FILEMETHOD);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.15.2 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CONNECT_ONLY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORTRANGE);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.15.3 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPMETHOD_MULTICWD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPMETHOD_NOCWD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPMETHOD_SINGLECWD);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.15.4 */
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_FTP_ENTRY_PATH);
|
|
|
|
|
2018-02-03 20:02:52 +00:00
|
|
|
/* Available since 7.15.5 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_ALTERNATIVE_TO_USER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.16.0 */
|
2016-04-24 02:55:00 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT_BADFILE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSL_SESSIONID_CACHE);
|
2012-12-23 19:59:41 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLMOPT_PIPELINING);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.16.1 */
|
2012-08-24 22:04:16 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLE_SSH);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL_CCC);
|
2012-08-24 22:04:16 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSH_AUTH_TYPES);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSH_PRIVATE_KEYFILE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSH_PUBLIC_KEYFILE);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_ACTIVE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_NONE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_PASSIVE);
|
2004-11-14 20:00:16 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.16.2 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT_MS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_CONTENT_DECODING);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_TRANSFER_DECODING);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT_MS);
|
2004-11-14 20:00:16 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.16.3 */
|
2012-12-23 19:59:41 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLMOPT_MAXCONNECTS);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.16.4 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_KRBLEVEL);
|
2012-08-24 22:04:16 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_NEW_DIRECTORY_PERMS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_NEW_FILE_PERMS);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.17.0 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_APPEND);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DIRLISTONLY);
|
2011-11-22 17:33:48 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_USE_SSL);
|
2011-12-01 21:48:07 +00:00
|
|
|
/* Curl SSL Constants */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLUSESSL_ALL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLUSESSL_CONTROL);
|
2011-11-22 17:33:48 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLUSESSL_NONE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLUSESSL_TRY);
|
2009-09-24 18:20:49 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.17.1 */
|
2012-08-24 22:04:16 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.18.0 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TRANSFER_MODE);
|
2012-12-23 22:13:49 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPAUSE_ALL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPAUSE_CONT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPAUSE_RECV);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPAUSE_RECV_CONT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPAUSE_SEND);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPAUSE_SEND_CONT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_READFUNC_PAUSE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_WRITEFUNC_PAUSE);
|
2016-04-27 22:43:41 +00:00
|
|
|
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS4A);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS5_HOSTNAME);
|
2006-09-18 16:11:50 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.18.2 */
|
2011-12-23 21:01:05 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.19.0 */
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_APPCONNECT_TIME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_IP);
|
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_ADDRESS_SCOPE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CRLFILE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_ISSUERCERT);
|
- MFH
- [DOC] Add support for SSH via libssh2
- new constants: CURLE_SSH, CURLSSH_AUTH_NONE, CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, CURLSSH_AUTH_KEYBOARD, CURLSSH_AUTH_DEFAULT, CURLOPT_SSH_AUTH_TYPES, CURLOPT_KEYPASSWD, CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html fortheir roles or usages
2009-01-25 16:28:18 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_KEYPASSWD);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_ANY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_DEFAULT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_HOST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_KEYBOARD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_NONE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PASSWORD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PUBLICKEY);
|
- MFH
- [DOC] Add support for SSH via libssh2
- new constants: CURLE_SSH, CURLSSH_AUTH_NONE, CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, CURLSSH_AUTH_KEYBOARD, CURLSSH_AUTH_DEFAULT, CURLOPT_SSH_AUTH_TYPES, CURLOPT_KEYPASSWD, CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html fortheir roles or usages
2009-01-25 16:28:18 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.19.1 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CERTINFO);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PASSWORD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_POSTREDIR);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXYPASSWORD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERNAME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_USERNAME);
|
2016-04-27 22:43:41 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_REDIR_POST_301);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_REDIR_POST_302);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_REDIR_POST_ALL);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.19.3 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST_IE);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.19.4 */
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_CONDITION_UNMET);
|
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_NOPROXY);
|
2009-03-13 19:39:49 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROTOCOLS);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_REDIR_PROTOCOLS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_NEC);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_SERVICE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TFTP_BLKSIZE);
|
2011-12-03 20:16:32 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_ALL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_DICT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_FILE);
|
2009-03-13 19:39:49 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_FTP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_FTPS);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_HTTP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_HTTPS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_LDAP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_LDAPS);
|
2009-03-13 19:39:49 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_SCP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_SFTP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_TELNET);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_TFTP);
|
2016-04-27 22:43:41 +00:00
|
|
|
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROXY_HTTP_1_0);
|
|
|
|
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTP_CREATE_DIR);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTP_CREATE_DIR_NONE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLFTP_CREATE_DIR_RETRY);
|
2009-03-13 19:39:49 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.19.6 */
|
2019-04-30 17:12:39 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_CURLDEBUG);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSH_KNOWNHOSTS);
|
2009-07-17 00:25:54 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.20.0 */
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CLIENT_CSEQ);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CSEQ_RECV);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SERVER_CSEQ);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SESSION_ID);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_PRET);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_MAIL_FROM);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_MAIL_RCPT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_CLIENT_CSEQ);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_REQUEST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SERVER_CSEQ);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SESSION_ID);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_STREAM_URI);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_TRANSPORT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_IMAP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_IMAPS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_POP3);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_POP3S);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_RTSP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_SMTP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_SMTPS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_ANNOUNCE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_DESCRIBE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_GET_PARAMETER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_OPTIONS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PAUSE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PLAY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECEIVE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECORD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SET_PARAMETER);
|
2016-04-27 22:43:41 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SETUP);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_TEARDOWN);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.21.0 */
|
2011-12-03 20:16:32 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_IP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_PORT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_PORT);
|
2011-12-04 00:19:12 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_FNMATCH_FUNCTION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_WILDCARDMATCH);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_RTMP);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTE);
|
2011-12-04 00:19:12 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_FAIL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_MATCH);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_NOMATCH);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.21.2 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_GOPHER);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.21.3 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_ONLY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_RESOLVE);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.21.4 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_PASSWORD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_TYPE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_USERNAME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_TLSAUTH_SRP);
|
2018-10-08 14:15:20 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_TLSAUTH_SRP);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.21.6 */
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_ACCEPT_ENCODING);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TRANSFER_ENCODING);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.22.0 */
|
2016-04-27 22:43:41 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_NTLM_WB);
|
2012-12-28 05:51:04 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLGSSAPI_DELEGATION_FLAG);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLGSSAPI_DELEGATION_POLICY_FLAG);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_GSSAPI_DELEGATION);
|
2018-10-08 14:15:20 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_NTLM_WB);
|
2012-12-28 05:51:04 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.24.0 */
|
2012-12-28 05:51:04 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_ACCEPTTIMEOUT_MS);
|
2011-12-01 21:48:07 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DNS_SERVERS);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.25.0 */
|
2012-05-27 07:21:08 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_MAIL_AUTH);
|
2012-12-28 05:51:04 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSL_OPTIONS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPALIVE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPIDLE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPINTVL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSLOPT_ALLOW_BEAST);
|
2012-05-27 07:21:08 +00:00
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.25.1 */
|
2016-04-27 22:43:41 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_REDIR_POST_303);
|
|
|
|
|
2020-01-18 09:05:07 +00:00
|
|
|
/* Available since 7.28.0 */
|
2016-04-27 22:43:41 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_AGENT);
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x071e00 /* Available since 7.30.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLMOPT_MAX_HOST_CONNECTIONS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLMOPT_MAX_PIPELINE_LENGTH);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLMOPT_MAX_TOTAL_CONNECTIONS);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x071f00 /* Available since 7.31.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SASL_IR);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072100 /* Available since 7.33.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DNS_INTERFACE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DNS_LOCAL_IP4);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DNS_LOCAL_IP6);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_XOAUTH2_BEARER);
|
|
|
|
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_2_0);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_HTTP2);
|
|
|
|
#endif
|
|
|
|
|
2014-10-17 04:25:29 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072200 /* Available since 7.34.0 */
|
2016-04-27 22:43:41 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_LOGIN_OPTIONS);
|
|
|
|
|
2014-10-17 04:25:29 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_0);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_1);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_2);
|
|
|
|
#endif
|
|
|
|
|
2016-04-27 22:43:41 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072400 /* Available since 7.36.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_EXPECT_100_TIMEOUT_MS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSL_ENABLE_ALPN);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSL_ENABLE_NPN);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072500 /* Available since 7.37.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLHEADER_SEPARATE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLHEADER_UNIFIED);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HEADEROPT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXYHEADER);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072600 /* Available since 7.38.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_NEGOTIATE);
|
2018-10-08 14:15:20 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_GSSAPI);
|
2016-04-27 22:43:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072700 /* Available since 7.39.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PINNEDPUBLICKEY);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072800 /* Available since 7.40.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_UNIX_SOCKET_PATH);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_SMB);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROTO_SMBS);
|
2018-10-08 14:15:20 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS5);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_UNIX_SOCKETS);
|
2016-04-27 22:43:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072900 /* Available since 7.41.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYSTATUS);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072a00 /* Available since 7.42.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PATH_AS_IS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSL_FALSESTART);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072b00 /* Available since 7.43.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_2);
|
|
|
|
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PIPEWAIT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SERVICE_NAME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SERVICE_NAME);
|
|
|
|
|
2015-09-02 04:06:31 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLPIPE_NOTHING);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPIPE_HTTP1);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPIPE_MULTIPLEX);
|
|
|
|
#endif
|
|
|
|
|
2016-04-27 22:43:41 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072c00 /* Available since 7.44.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSLOPT_NO_REVOKE);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072d00 /* Available since 7.45.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DEFAULT_PROTOCOL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072e00 /* Available since 7.46.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_STREAM_WEIGHT);
|
2015-10-02 07:31:10 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLMOPT_PUSHFUNCTION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_PUSH_OK);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_PUSH_DENY);
|
2016-04-27 22:43:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072f00 /* Available since 7.47.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_2TLS);
|
2019-04-30 17:12:39 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_PSL);
|
2016-04-27 22:43:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073000 /* Available since 7.48.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TFTP_NO_OPTIONS);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073100 /* Available since 7.49.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_CONNECT_TO);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TCP_FASTOPEN);
|
|
|
|
#endif
|
|
|
|
|
2018-10-03 23:43:59 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073200 /* Available since 7.50.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_HTTP_VERSION);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073300 /* Available since 7.51.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLE_WEIRD_SERVER_REPLY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_KEEP_SENDING_ON_ERROR);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073400 /* Available since 7.52.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_3);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_HTTPS_PROXY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_PROTOCOL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_PROXY_SSL_VERIFYRESULT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SCHEME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PRE_PROXY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_CAINFO);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_CAPATH);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_CRLFILE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_KEYPASSWD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_PINNEDPUBLICKEY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SSL_CIPHER_LIST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SSL_OPTIONS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SSL_VERIFYHOST);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SSL_VERIFYPEER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SSLCERT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SSLCERTTYPE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SSLKEY);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SSLKEYTYPE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_SSLVERSION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TLSAUTH_PASSWORD);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TLSAUTH_TYPE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TLSAUTH_USERNAME);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLPROXY_HTTPS);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073500 /* Available since 7.53.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_MAX_READ_SIZE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_ABSTRACT_UNIX_SOCKET);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073600 /* Available since 7.54.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_MAX_DEFAULT);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_MAX_NONE);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_MAX_TLSv1_0);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_MAX_TLSv1_1);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_MAX_TLSv1_2);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_MAX_TLSv1_3);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SUPPRESS_CONNECT_HEADERS);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073601 /* Available since 7.54.1 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_GSSAPI);
|
|
|
|
#endif
|
|
|
|
|
2017-12-06 02:35:12 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073700 /* Available since 7.55.0 */
|
2018-10-03 23:43:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_UPLOAD_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SIZE_DOWNLOAD_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SIZE_UPLOAD_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SPEED_DOWNLOAD_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_SPEED_UPLOAD_T);
|
2017-12-06 02:35:12 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_REQUEST_TARGET);
|
2018-10-03 23:43:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_AUTH);
|
2017-12-06 02:35:12 +00:00
|
|
|
#endif
|
|
|
|
|
2018-10-08 14:15:20 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* Available since 7.56.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SSH_COMPRESSION);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_MULTI_SSL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073900 /* Available since 7.57.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_BROTLI);
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_CONNECT);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073a00 /* Available since 7.58.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_GSSAPI);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073b00 /* Available since 7.59.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_FILETIME_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TIMEVALUE_LARGE);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073c00 /* Available since 7.60.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DNS_SHUFFLE_ADDRESSES);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HAPROXYPROTOCOL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073d00 /* Available since 7.61.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_PSL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLAUTH_BEARER);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_APPCONNECT_TIME_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_CONNECT_TIME_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_NAMELOOKUP_TIME_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_PRETRANSFER_TIME_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_TIME_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_STARTTRANSFER_TIME_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLINFO_TOTAL_TIME_T);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_DISALLOW_USERNAME_IN_URL);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TLS13_CIPHERS);
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_TLS13_CIPHERS);
|
|
|
|
#endif
|
|
|
|
|
2020-01-26 04:18:57 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x074000 /* Available since 7.64.0 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_HTTP09_ALLOWED);
|
|
|
|
#endif
|
|
|
|
|
2019-04-30 17:12:39 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */
|
|
|
|
REGISTER_CURL_CONSTANT(CURL_VERSION_ALTSVC);
|
|
|
|
#endif
|
|
|
|
|
2013-01-29 06:22:59 +00:00
|
|
|
REGISTER_CURL_CONSTANT(CURLOPT_SAFE_UPLOAD);
|
2009-05-04 14:09:28 +00:00
|
|
|
|
2006-01-26 13:23:33 +00:00
|
|
|
#ifdef PHP_CURL_NEED_OPENSSL_TSL
|
2006-12-19 21:41:25 +00:00
|
|
|
if (!CRYPTO_get_id_callback()) {
|
2006-01-26 13:23:33 +00:00
|
|
|
int i, c = CRYPTO_num_locks();
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2006-01-26 13:23:33 +00:00
|
|
|
php_curl_openssl_tsl = malloc(c * sizeof(MUTEX_T));
|
2011-07-28 10:31:34 +00:00
|
|
|
if (!php_curl_openssl_tsl) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2006-01-26 13:23:33 +00:00
|
|
|
for (i = 0; i < c; ++i) {
|
|
|
|
php_curl_openssl_tsl[i] = tsrm_mutex_alloc();
|
|
|
|
}
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2006-01-26 13:23:33 +00:00
|
|
|
CRYPTO_set_id_callback(php_curl_ssl_id);
|
|
|
|
CRYPTO_set_locking_callback(php_curl_ssl_lock);
|
|
|
|
}
|
2005-10-25 14:32:33 +00:00
|
|
|
#endif
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2015-02-22 13:04:55 +00:00
|
|
|
if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK) {
|
2001-09-22 00:38:59 +00:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
zend_class_entry ce;
|
|
|
|
INIT_CLASS_ENTRY(ce, "CurlHandle", class_CurlHandle_methods);
|
|
|
|
curl_ce = zend_register_internal_class(&ce);
|
Add flag to forbid dynamic property creation on internal classes
While performing resource -> object migrations, we're adding
defensive classes that are final, non-serializable and non-clonable
(unless they are, of course). This path adds a ZEND_ACC_NO_DYNAMIC_PROPERTIES
flag, that also forbids the creation of dynamic properties on these objects.
This is a subset of #3931 and targeted at internal usage only
(though may be extended to userland at some point in the future).
It's already possible to achieve this (what the removed
WeakRef/WeakMap code does), but there's some caveats: First, this
simple approach is only possible if the class has no declared
properties, otherwise it's necessary to special-case those
properties. Second, it's easy to make it overly strict, e.g. by
forbidding isset($obj->prop) as well. And finally, it requires a
lot of boilerplate code for each class.
Closes GH-5572.
2020-05-14 09:51:36 +00:00
|
|
|
curl_ce->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES;
|
2020-06-17 14:05:55 +00:00
|
|
|
curl_ce->create_object = curl_create_object;
|
|
|
|
curl_ce->serialize = zend_class_serialize_deny;
|
|
|
|
curl_ce->unserialize = zend_class_unserialize_deny;
|
|
|
|
|
|
|
|
memcpy(&curl_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
|
|
|
|
curl_object_handlers.offset = XtOffsetOf(php_curl, std);
|
|
|
|
curl_object_handlers.free_obj = curl_free_obj;
|
|
|
|
curl_object_handlers.get_gc = curl_get_gc;
|
|
|
|
curl_object_handlers.get_constructor = curl_get_constructor;
|
|
|
|
curl_object_handlers.clone_obj = curl_clone_obj;
|
2020-06-19 14:50:59 +00:00
|
|
|
curl_object_handlers.cast_object = curl_cast_object;
|
2020-06-17 14:05:55 +00:00
|
|
|
|
|
|
|
curl_multi_register_class(class_CurlMultiHandle_methods);
|
|
|
|
curl_share_register_class(class_CurlShareHandle_methods);
|
2014-12-13 22:06:14 +00:00
|
|
|
curlfile_register_class();
|
2013-01-29 06:22:59 +00:00
|
|
|
|
2001-09-22 00:38:59 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
/* CurlHandle class */
|
|
|
|
|
|
|
|
static zend_object *curl_create_object(zend_class_entry *class_type) {
|
|
|
|
php_curl *intern = zend_object_alloc(sizeof(php_curl), class_type);
|
|
|
|
|
|
|
|
zend_object_std_init(&intern->std, class_type);
|
|
|
|
object_properties_init(&intern->std, class_type);
|
|
|
|
intern->std.handlers = &curl_object_handlers;
|
|
|
|
|
|
|
|
return &intern->std;
|
|
|
|
}
|
|
|
|
|
|
|
|
static zend_function *curl_get_constructor(zend_object *object) {
|
|
|
|
zend_throw_error(NULL, "Cannot directly construct CurlHandle, use curl_init() instead");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static zend_object *curl_clone_obj(zend_object *object) {
|
|
|
|
php_curl *ch;
|
|
|
|
CURL *cp;
|
|
|
|
zval *postfields;
|
|
|
|
zend_object *clone_object;
|
|
|
|
php_curl *clone_ch;
|
|
|
|
|
|
|
|
clone_object = curl_create_object(curl_ce);
|
|
|
|
clone_ch = curl_from_obj(clone_object);
|
|
|
|
init_curl_handle(clone_ch);
|
|
|
|
|
|
|
|
ch = curl_from_obj(object);
|
|
|
|
cp = curl_easy_duphandle(ch->cp);
|
|
|
|
if (!cp) {
|
|
|
|
zend_throw_exception(NULL, "Failed to clone CurlHandle", 0);
|
|
|
|
return &clone_ch->std;
|
|
|
|
}
|
|
|
|
|
|
|
|
clone_ch->cp = cp;
|
|
|
|
_php_setup_easy_copy_handlers(clone_ch, ch);
|
|
|
|
|
|
|
|
postfields = &clone_ch->postfields;
|
|
|
|
if (Z_TYPE_P(postfields) != IS_UNDEF) {
|
|
|
|
if (build_mime_structure_from_hash(clone_ch, postfields) != SUCCESS) {
|
|
|
|
zend_throw_exception(NULL, "Failed to clone CurlHandle", 0);
|
|
|
|
return &clone_ch->std;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &clone_ch->std;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HashTable *curl_get_gc(zend_object *object, zval **table, int *n)
|
|
|
|
{
|
|
|
|
php_curl *curl = curl_from_obj(object);
|
|
|
|
|
|
|
|
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->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->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);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers->std_err);
|
|
|
|
}
|
|
|
|
|
|
|
|
zend_get_gc_buffer_use(gc_buffer, table, n);
|
|
|
|
|
|
|
|
return zend_std_get_properties(object);
|
|
|
|
}
|
|
|
|
|
2020-06-22 13:09:22 +00:00
|
|
|
int curl_cast_object(zend_object *obj, zval *result, int type)
|
2020-06-19 14:50:59 +00:00
|
|
|
{
|
|
|
|
if (type == IS_LONG) {
|
|
|
|
/* For better backward compatibility, make (int) $curl_handle return the object ID,
|
|
|
|
* similar to how it previously returned the resource ID. */
|
|
|
|
ZVAL_LONG(result, obj->handle);
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return zend_std_cast_object_tostring(obj, result, type);
|
|
|
|
}
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ PHP_MSHUTDOWN_FUNCTION */
|
2001-09-22 00:38:59 +00:00
|
|
|
PHP_MSHUTDOWN_FUNCTION(curl)
|
|
|
|
{
|
|
|
|
curl_global_cleanup();
|
2006-01-26 13:23:33 +00:00
|
|
|
#ifdef PHP_CURL_NEED_OPENSSL_TSL
|
|
|
|
if (php_curl_openssl_tsl) {
|
|
|
|
int i, c = CRYPTO_num_locks();
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2006-01-26 13:23:33 +00:00
|
|
|
CRYPTO_set_id_callback(NULL);
|
|
|
|
CRYPTO_set_locking_callback(NULL);
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2006-01-26 13:23:33 +00:00
|
|
|
for (i = 0; i < c; ++i) {
|
|
|
|
tsrm_mutex_free(php_curl_openssl_tsl[i]);
|
|
|
|
}
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2006-01-26 13:23:33 +00:00
|
|
|
free(php_curl_openssl_tsl);
|
|
|
|
php_curl_openssl_tsl = NULL;
|
|
|
|
}
|
2005-10-25 14:32:33 +00:00
|
|
|
#endif
|
2011-04-01 17:10:52 +00:00
|
|
|
UNREGISTER_INI_ENTRIES();
|
2000-10-22 17:29:33 +00:00
|
|
|
return SUCCESS;
|
2000-08-15 16:50:14 +00:00
|
|
|
}
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2000-08-15 16:50:14 +00:00
|
|
|
|
2012-12-23 00:03:24 +00:00
|
|
|
/* {{{ curl_write_nothing
|
|
|
|
* Used as a work around. See _php_curl_close_ex
|
|
|
|
*/
|
2013-01-29 06:22:59 +00:00
|
|
|
static size_t curl_write_nothing(char *data, size_t size, size_t nmemb, void *ctx)
|
2012-12-23 00:03:24 +00:00
|
|
|
{
|
|
|
|
return size * nmemb;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_write */
|
2001-10-18 19:24:51 +00:00
|
|
|
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
|
2001-04-30 14:36:19 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
php_curl *ch = (php_curl *) ctx;
|
|
|
|
php_curl_write *t = ch->handlers->write;
|
|
|
|
size_t length = size * nmemb;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2002-11-13 22:25:33 +00:00
|
|
|
#if PHP_CURL_DEBUG
|
|
|
|
fprintf(stderr, "curl_write() called\n");
|
2003-03-17 15:06:11 +00:00
|
|
|
fprintf(stderr, "data = %s, size = %d, nmemb = %d, ctx = %x\n", data, size, nmemb, ctx);
|
2002-11-13 22:25:33 +00:00
|
|
|
#endif
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2001-04-30 14:36:19 +00:00
|
|
|
switch (t->method) {
|
2003-03-17 15:06:11 +00:00
|
|
|
case PHP_CURL_STDOUT:
|
2003-05-17 14:12:36 +00:00
|
|
|
PHPWRITE(data, length);
|
2003-03-17 15:06:11 +00:00
|
|
|
break;
|
|
|
|
case PHP_CURL_FILE:
|
|
|
|
return fwrite(data, size, nmemb, t->fp);
|
|
|
|
case PHP_CURL_RETURN:
|
2007-02-23 20:51:02 +00:00
|
|
|
if (length > 0) {
|
|
|
|
smart_str_appendl(&t->buf, data, (int) length);
|
|
|
|
}
|
2003-03-17 15:06:11 +00:00
|
|
|
break;
|
|
|
|
case PHP_CURL_USER: {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval argv[2];
|
|
|
|
zval retval;
|
|
|
|
int error;
|
2003-08-05 10:29:03 +00:00
|
|
|
zend_fcall_info fci;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
GC_ADDREF(&ch->std);
|
|
|
|
ZVAL_OBJ(&argv[0], &ch->std);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_STRINGL(&argv[1], data, length);
|
2003-03-17 15:06:11 +00:00
|
|
|
|
2003-08-05 10:29:03 +00:00
|
|
|
fci.size = sizeof(fci);
|
2014-05-09 04:17:09 +00:00
|
|
|
fci.object = NULL;
|
|
|
|
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
|
|
|
|
fci.retval = &retval;
|
2003-08-05 10:29:03 +00:00
|
|
|
fci.param_count = 2;
|
|
|
|
fci.params = argv;
|
2020-04-06 10:46:52 +00:00
|
|
|
fci.named_params = NULL;
|
2003-08-05 10:29:03 +00:00
|
|
|
|
2005-06-02 21:04:12 +00:00
|
|
|
ch->in_callback = 1;
|
2014-12-13 22:06:14 +00:00
|
|
|
error = zend_call_function(&fci, &t->fci_cache);
|
2005-06-02 21:04:12 +00:00
|
|
|
ch->in_callback = 0;
|
2003-03-17 15:06:11 +00:00
|
|
|
if (error == FAILURE) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Could not call the CURLOPT_WRITEFUNCTION");
|
2003-03-17 15:06:11 +00:00
|
|
|
length = -1;
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (!Z_ISUNDEF(retval)) {
|
2015-04-14 08:20:31 +00:00
|
|
|
_php_curl_verify_handlers(ch, 1);
|
2015-05-05 10:22:38 +00:00
|
|
|
length = zval_get_long(&retval);
|
2003-03-17 15:06:11 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&argv[0]);
|
|
|
|
zval_ptr_dtor(&argv[1]);
|
2003-03-17 15:06:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-04-30 14:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_fnmatch */
|
2011-12-04 00:19:12 +00:00
|
|
|
static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
|
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
php_curl *ch = (php_curl *) ctx;
|
2011-12-04 00:19:12 +00:00
|
|
|
php_curl_fnmatch *t = ch->handlers->fnmatch;
|
|
|
|
int rval = CURL_FNMATCHFUNC_FAIL;
|
|
|
|
switch (t->method) {
|
|
|
|
case PHP_CURL_USER: {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval argv[3];
|
|
|
|
zval retval;
|
|
|
|
int error;
|
2011-12-04 00:19:12 +00:00
|
|
|
zend_fcall_info fci;
|
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
GC_ADDREF(&ch->std);
|
|
|
|
ZVAL_OBJ(&argv[0], &ch->std);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_STRING(&argv[1], pattern);
|
|
|
|
ZVAL_STRING(&argv[2], string);
|
2011-12-04 00:19:12 +00:00
|
|
|
|
|
|
|
fci.size = sizeof(fci);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
|
|
|
|
fci.object = NULL;
|
|
|
|
fci.retval = &retval;
|
2011-12-04 00:19:12 +00:00
|
|
|
fci.param_count = 3;
|
|
|
|
fci.params = argv;
|
2020-04-06 10:46:52 +00:00
|
|
|
fci.named_params = NULL;
|
2011-12-04 00:19:12 +00:00
|
|
|
|
|
|
|
ch->in_callback = 1;
|
2014-12-13 22:06:14 +00:00
|
|
|
error = zend_call_function(&fci, &t->fci_cache);
|
2011-12-04 00:19:12 +00:00
|
|
|
ch->in_callback = 0;
|
|
|
|
if (error == FAILURE) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION");
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (!Z_ISUNDEF(retval)) {
|
2015-04-14 08:20:31 +00:00
|
|
|
_php_curl_verify_handlers(ch, 1);
|
2015-05-05 10:22:38 +00:00
|
|
|
rval = zval_get_long(&retval);
|
2011-12-04 00:19:12 +00:00
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&argv[0]);
|
|
|
|
zval_ptr_dtor(&argv[1]);
|
|
|
|
zval_ptr_dtor(&argv[2]);
|
2011-12-04 00:19:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_progress */
|
2009-05-18 12:51:05 +00:00
|
|
|
static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
2009-05-03 14:59:46 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
php_curl *ch = (php_curl *)clientp;
|
|
|
|
php_curl_progress *t = ch->handlers->progress;
|
2009-05-03 14:59:46 +00:00
|
|
|
size_t rval = 0;
|
|
|
|
|
|
|
|
#if PHP_CURL_DEBUG
|
|
|
|
fprintf(stderr, "curl_progress() called\n");
|
|
|
|
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: {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval argv[5];
|
|
|
|
zval retval;
|
|
|
|
int error;
|
2009-05-03 14:59:46 +00:00
|
|
|
zend_fcall_info fci;
|
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
GC_ADDREF(&ch->std);
|
|
|
|
ZVAL_OBJ(&argv[0], &ch->std);
|
2014-08-26 09:23:25 +00:00
|
|
|
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);
|
2009-05-03 14:59:46 +00:00
|
|
|
|
|
|
|
fci.size = sizeof(fci);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
|
|
|
|
fci.object = NULL;
|
|
|
|
fci.retval = &retval;
|
2011-12-03 23:53:27 +00:00
|
|
|
fci.param_count = 5;
|
2009-05-03 14:59:46 +00:00
|
|
|
fci.params = argv;
|
2020-04-06 10:46:52 +00:00
|
|
|
fci.named_params = NULL;
|
2009-05-03 14:59:46 +00:00
|
|
|
|
|
|
|
ch->in_callback = 1;
|
2014-12-13 22:06:14 +00:00
|
|
|
error = zend_call_function(&fci, &t->fci_cache);
|
2009-05-03 14:59:46 +00:00
|
|
|
ch->in_callback = 0;
|
|
|
|
if (error == FAILURE) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (!Z_ISUNDEF(retval)) {
|
2015-04-14 08:20:31 +00:00
|
|
|
_php_curl_verify_handlers(ch, 1);
|
2015-05-05 10:22:38 +00:00
|
|
|
if (0 != zval_get_long(&retval)) {
|
2009-05-03 14:59:46 +00:00
|
|
|
rval = 1;
|
2009-05-18 12:51:05 +00:00
|
|
|
}
|
2009-05-03 14:59:46 +00:00
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&argv[0]);
|
2009-05-03 14:59:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_read */
|
2001-05-04 04:20:38 +00:00
|
|
|
static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
|
2001-04-30 14:36:19 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
php_curl *ch = (php_curl *)ctx;
|
|
|
|
php_curl_read *t = ch->handlers->read;
|
|
|
|
int length = 0;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
|
|
|
switch (t->method) {
|
2003-03-17 15:06:11 +00:00
|
|
|
case PHP_CURL_DIRECT:
|
|
|
|
if (t->fp) {
|
|
|
|
length = fread(data, size, nmemb, t->fp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PHP_CURL_USER: {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval argv[3];
|
|
|
|
zval retval;
|
|
|
|
int error;
|
2003-08-05 10:29:03 +00:00
|
|
|
zend_fcall_info fci;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
GC_ADDREF(&ch->std);
|
|
|
|
ZVAL_OBJ(&argv[0], &ch->std);
|
2015-01-30 05:12:58 +00:00
|
|
|
if (t->res) {
|
2018-01-07 11:46:21 +00:00
|
|
|
GC_ADDREF(t->res);
|
2015-01-30 05:12:58 +00:00
|
|
|
ZVAL_RES(&argv[1], t->res);
|
|
|
|
} else {
|
|
|
|
ZVAL_NULL(&argv[1]);
|
|
|
|
}
|
2014-08-25 17:24:55 +00:00
|
|
|
ZVAL_LONG(&argv[2], (int)size * nmemb);
|
2003-05-21 23:27:12 +00:00
|
|
|
|
2003-08-05 10:29:03 +00:00
|
|
|
fci.size = sizeof(fci);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
|
|
|
|
fci.object = NULL;
|
|
|
|
fci.retval = &retval;
|
2003-08-05 10:29:03 +00:00
|
|
|
fci.param_count = 3;
|
|
|
|
fci.params = argv;
|
2020-04-06 10:46:52 +00:00
|
|
|
fci.named_params = NULL;
|
2003-08-05 10:29:03 +00:00
|
|
|
|
2005-06-02 21:04:12 +00:00
|
|
|
ch->in_callback = 1;
|
2014-12-13 22:06:14 +00:00
|
|
|
error = zend_call_function(&fci, &t->fci_cache);
|
2005-06-02 21:04:12 +00:00
|
|
|
ch->in_callback = 0;
|
2003-03-17 15:06:11 +00:00
|
|
|
if (error == FAILURE) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_READFUNCTION");
|
2008-07-12 21:16:50 +00:00
|
|
|
length = CURL_READFUNC_ABORT;
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (!Z_ISUNDEF(retval)) {
|
2015-04-14 08:20:31 +00:00
|
|
|
_php_curl_verify_handlers(ch, 1);
|
2014-05-09 04:17:09 +00:00
|
|
|
if (Z_TYPE(retval) == IS_STRING) {
|
2014-08-25 17:24:55 +00:00
|
|
|
length = MIN((int) (size * nmemb), Z_STRLEN(retval));
|
2014-05-09 04:17:09 +00:00
|
|
|
memcpy(data, Z_STRVAL(retval), length);
|
2004-03-12 16:08:11 +00:00
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&retval);
|
2003-03-17 15:06:11 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&argv[0]);
|
|
|
|
zval_ptr_dtor(&argv[1]);
|
2003-03-17 15:06:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-04-30 14:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_write_header */
|
2001-10-18 19:24:51 +00:00
|
|
|
static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx)
|
2001-04-30 14:36:19 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
php_curl *ch = (php_curl *) ctx;
|
|
|
|
php_curl_write *t = ch->handlers->write_header;
|
|
|
|
size_t length = size * nmemb;
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2001-06-25 15:14:20 +00:00
|
|
|
switch (t->method) {
|
2002-07-03 12:02:17 +00:00
|
|
|
case PHP_CURL_STDOUT:
|
|
|
|
/* Handle special case write when we're returning the entire transfer
|
|
|
|
*/
|
2007-02-23 20:51:02 +00:00
|
|
|
if (ch->handlers->write->method == PHP_CURL_RETURN && length > 0) {
|
2002-07-03 12:02:17 +00:00
|
|
|
smart_str_appendl(&ch->handlers->write->buf, data, (int) length);
|
2003-03-17 15:06:11 +00:00
|
|
|
} else {
|
2003-05-17 14:12:36 +00:00
|
|
|
PHPWRITE(data, length);
|
2003-03-17 15:06:11 +00:00
|
|
|
}
|
2002-07-03 12:02:17 +00:00
|
|
|
break;
|
|
|
|
case PHP_CURL_FILE:
|
|
|
|
return fwrite(data, size, nmemb, t->fp);
|
|
|
|
case PHP_CURL_USER: {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval argv[2];
|
|
|
|
zval retval;
|
|
|
|
int error;
|
2003-08-05 10:29:03 +00:00
|
|
|
zend_fcall_info fci;
|
2002-07-03 12:02:17 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
GC_ADDREF(&ch->std);
|
|
|
|
ZVAL_OBJ(&argv[0], &ch->std);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_STRINGL(&argv[1], data, length);
|
2003-08-05 10:29:03 +00:00
|
|
|
|
|
|
|
fci.size = sizeof(fci);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
|
|
|
|
fci.object = NULL;
|
|
|
|
fci.retval = &retval;
|
2003-08-05 10:29:03 +00:00
|
|
|
fci.param_count = 2;
|
|
|
|
fci.params = argv;
|
2020-04-06 10:46:52 +00:00
|
|
|
fci.named_params = NULL;
|
2003-08-05 10:29:03 +00:00
|
|
|
|
2005-06-02 21:04:12 +00:00
|
|
|
ch->in_callback = 1;
|
2014-12-13 22:06:14 +00:00
|
|
|
error = zend_call_function(&fci, &t->fci_cache);
|
2005-06-02 21:04:12 +00:00
|
|
|
ch->in_callback = 0;
|
2002-07-03 12:02:17 +00:00
|
|
|
if (error == FAILURE) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Could not call the CURLOPT_HEADERFUNCTION");
|
2002-07-03 12:02:17 +00:00
|
|
|
length = -1;
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (!Z_ISUNDEF(retval)) {
|
2015-04-14 08:20:31 +00:00
|
|
|
_php_curl_verify_handlers(ch, 1);
|
2015-05-05 10:22:38 +00:00
|
|
|
length = zval_get_long(&retval);
|
2002-07-03 12:02:17 +00:00
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&argv[0]);
|
|
|
|
zval_ptr_dtor(&argv[1]);
|
2002-07-03 12:02:17 +00:00
|
|
|
break;
|
2001-06-25 15:14:20 +00:00
|
|
|
}
|
2004-03-12 17:31:10 +00:00
|
|
|
|
2002-07-03 12:02:17 +00:00
|
|
|
case PHP_CURL_IGNORE:
|
|
|
|
return length;
|
2004-03-12 17:31:10 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return -1;
|
2001-04-30 14:36:19 +00:00
|
|
|
}
|
2003-03-17 15:06:11 +00:00
|
|
|
|
2001-04-30 14:36:19 +00:00
|
|
|
return length;
|
|
|
|
}
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2007-12-04 08:56:07 +00:00
|
|
|
static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, void *ctx) /* {{{ */
|
2006-01-24 20:11:14 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
php_curl *ch = (php_curl *)ctx;
|
2006-01-24 20:11:14 +00:00
|
|
|
|
|
|
|
if (type == CURLINFO_HEADER_OUT) {
|
2014-05-09 06:14:09 +00:00
|
|
|
if (ch->header.str) {
|
2018-05-28 13:27:12 +00:00
|
|
|
zend_string_release_ex(ch->header.str, 0);
|
2006-01-24 20:11:14 +00:00
|
|
|
}
|
|
|
|
if (buf_len > 0) {
|
2014-08-25 17:24:55 +00:00
|
|
|
ch->header.str = zend_string_init(buf, buf_len, 0);
|
2006-01-24 20:11:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-12-04 08:56:07 +00:00
|
|
|
/* }}} */
|
2006-01-24 20:11:14 +00:00
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_free_string */
|
2001-04-30 14:36:19 +00:00
|
|
|
static void curl_free_string(void **string)
|
|
|
|
{
|
2014-05-09 05:54:42 +00:00
|
|
|
efree((char *)*string);
|
2009-05-03 15:16:10 +00:00
|
|
|
}
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2000-08-15 16:50:14 +00:00
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_free_post */
|
2001-04-30 14:36:19 +00:00
|
|
|
static void curl_free_post(void **post)
|
|
|
|
{
|
2019-04-15 16:24:59 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
|
|
|
|
curl_mime_free((curl_mime *)*post);
|
|
|
|
#else
|
2014-05-09 05:54:42 +00:00
|
|
|
curl_formfree((struct HttpPost *)*post);
|
2019-04-15 16:24:59 +00:00
|
|
|
#endif
|
2001-04-30 14:36:19 +00:00
|
|
|
}
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2001-04-30 14:36:19 +00:00
|
|
|
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
struct mime_data_cb_arg {
|
|
|
|
zend_string *filename;
|
|
|
|
php_stream *stream;
|
|
|
|
};
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_free_cb_arg */
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
static void curl_free_cb_arg(void **cb_arg_p)
|
2019-04-29 08:21:07 +00:00
|
|
|
{
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) *cb_arg_p;
|
|
|
|
|
|
|
|
ZEND_ASSERT(cb_arg->stream == NULL);
|
|
|
|
zend_string_release(cb_arg->filename);
|
|
|
|
efree(cb_arg);
|
2019-04-29 08:21:07 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ curl_free_slist */
|
2014-05-09 04:17:09 +00:00
|
|
|
static void curl_free_slist(zval *el)
|
2001-04-30 14:36:19 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
curl_slist_free_all(((struct curl_slist *)Z_PTR_P(el)));
|
2001-04-30 14:36:19 +00:00
|
|
|
}
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Return cURL version information. */
|
2000-10-20 04:57:14 +00:00
|
|
|
PHP_FUNCTION(curl_version)
|
2000-07-25 22:15:26 +00:00
|
|
|
{
|
2002-11-13 22:25:33 +00:00
|
|
|
curl_version_info_data *d;
|
|
|
|
|
2020-06-18 07:26:58 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_NONE();
|
2019-05-13 06:53:41 +00:00
|
|
|
|
|
|
|
d = curl_version_info(CURLVERSION_NOW);
|
2002-11-13 22:25:33 +00:00
|
|
|
if (d == NULL) {
|
|
|
|
RETURN_FALSE;
|
2001-08-13 07:55:39 +00:00
|
|
|
}
|
2001-08-13 06:43:47 +00:00
|
|
|
|
2002-11-13 22:25:33 +00:00
|
|
|
array_init(return_value);
|
|
|
|
|
|
|
|
CAAL("version_number", d->version_num);
|
|
|
|
CAAL("age", d->age);
|
|
|
|
CAAL("features", d->features);
|
|
|
|
CAAL("ssl_version_number", d->ssl_version_num);
|
|
|
|
CAAS("version", d->version);
|
|
|
|
CAAS("host", d->host);
|
|
|
|
CAAS("ssl_version", d->ssl_version);
|
|
|
|
CAAS("libz_version", d->libz_version);
|
|
|
|
/* Add an array of protocols */
|
|
|
|
{
|
|
|
|
char **p = (char **) d->protocols;
|
2014-05-09 04:17:09 +00:00
|
|
|
zval protocol_list;
|
2002-11-13 22:25:33 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
array_init(&protocol_list);
|
2002-11-13 22:25:33 +00:00
|
|
|
|
|
|
|
while (*p != NULL) {
|
2014-05-09 04:17:09 +00:00
|
|
|
add_next_index_string(&protocol_list, *p);
|
2009-05-20 09:26:12 +00:00
|
|
|
p++;
|
2002-11-13 22:25:33 +00:00
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
CAAZ("protocols", &protocol_list);
|
2002-11-13 22:25:33 +00:00
|
|
|
}
|
2018-10-08 14:15:20 +00:00
|
|
|
if (d->age >= 1) {
|
|
|
|
CAAS("ares", d->ares);
|
|
|
|
CAAL("ares_num", d->ares_num);
|
|
|
|
}
|
|
|
|
if (d->age >= 2) {
|
|
|
|
CAAS("libidn", d->libidn);
|
|
|
|
}
|
|
|
|
if (d->age >= 3) {
|
|
|
|
CAAL("iconv_ver_num", d->iconv_ver_num);
|
|
|
|
CAAS("libssh_version", d->libssh_version);
|
|
|
|
}
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073900 /* Available since 7.57.0 */
|
|
|
|
if (d->age >= 4) {
|
|
|
|
CAAL("brotli_ver_num", d->brotli_ver_num);
|
|
|
|
CAAS("brotli_version", d->brotli_version);
|
|
|
|
}
|
|
|
|
#endif
|
2000-07-25 22:15:26 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
php_curl *init_curl_handle_into_zval(zval *curl)
|
|
|
|
{
|
|
|
|
php_curl *ch;
|
|
|
|
|
|
|
|
object_init_ex(curl, curl_ce);
|
|
|
|
ch = Z_CURL_P(curl);
|
|
|
|
|
|
|
|
init_curl_handle(ch);
|
|
|
|
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_curl_handle(php_curl *ch)
|
2001-05-06 22:24:25 +00:00
|
|
|
{
|
2014-05-09 05:54:42 +00:00
|
|
|
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;
|
2015-08-23 05:01:47 +00:00
|
|
|
ch->clone = emalloc(sizeof(uint32_t));
|
|
|
|
*ch->clone = 1;
|
2003-03-17 15:06:11 +00:00
|
|
|
|
2014-05-09 05:54:42 +00:00
|
|
|
memset(&ch->err, 0, sizeof(struct _php_curl_error));
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2014-05-09 06:14:09 +00:00
|
|
|
zend_llist_init(&ch->to_free->str, sizeof(char *), (llist_dtor_func_t)curl_free_string, 0);
|
2016-02-03 15:02:58 +00:00
|
|
|
zend_llist_init(&ch->to_free->post, sizeof(struct HttpPost *), (llist_dtor_func_t)curl_free_post, 0);
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
zend_llist_init(&ch->to_free->stream, sizeof(struct mime_data_cb_arg *), (llist_dtor_func_t)curl_free_cb_arg, 0);
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2014-05-09 05:54:42 +00:00
|
|
|
ch->to_free->slist = emalloc(sizeof(HashTable));
|
|
|
|
zend_hash_init(ch->to_free->slist, 4, NULL, curl_free_slist, 0);
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
ZVAL_UNDEF(&ch->postfields);
|
2001-05-06 22:24:25 +00:00
|
|
|
}
|
2020-06-17 14:05:55 +00:00
|
|
|
|
2001-06-05 13:12:10 +00:00
|
|
|
/* }}} */
|
2001-05-06 22:24:25 +00:00
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ create_certinfo */
|
2014-12-13 22:06:14 +00:00
|
|
|
static void create_certinfo(struct curl_certinfo *ci, zval *listcode)
|
2009-09-15 15:47:06 +00:00
|
|
|
{
|
|
|
|
int i;
|
2013-01-29 06:22:59 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
if (ci) {
|
|
|
|
zval certhash;
|
2013-01-29 06:22:59 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
for (i=0; i<ci->num_of_certs; i++) {
|
2009-09-15 15:47:06 +00:00
|
|
|
struct curl_slist *slist;
|
2013-01-29 06:22:59 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
array_init(&certhash);
|
|
|
|
for (slist = ci->certinfo[i]; slist; slist = slist->next) {
|
2009-09-15 15:47:06 +00:00
|
|
|
int len;
|
|
|
|
char s[64];
|
|
|
|
char *tmp;
|
2016-08-29 19:03:03 +00:00
|
|
|
strncpy(s, slist->data, sizeof(s));
|
|
|
|
s[sizeof(s)-1] = '\0';
|
|
|
|
tmp = memchr(s, ':', sizeof(s));
|
2009-09-15 15:47:06 +00:00
|
|
|
if(tmp) {
|
|
|
|
*tmp = '\0';
|
|
|
|
len = strlen(s);
|
2016-07-28 03:36:22 +00:00
|
|
|
add_assoc_string(&certhash, s, &slist->data[len+1]);
|
2009-09-15 15:47:06 +00:00
|
|
|
} else {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Could not extract hash key from certificate info");
|
2009-09-15 15:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
add_next_index_zval(listcode, &certhash);
|
2009-09-15 15:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* {{{ _php_curl_set_default_options()
|
|
|
|
Set default options for a handle */
|
|
|
|
static void _php_curl_set_default_options(php_curl *ch)
|
|
|
|
{
|
|
|
|
char *cainfo;
|
|
|
|
|
|
|
|
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);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_READFUNCTION, curl_read);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
|
2020-05-12 20:36:08 +00:00
|
|
|
#ifndef ZTS
|
2011-12-01 21:48:07 +00:00
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
|
2015-12-18 16:29:19 +00:00
|
|
|
#endif
|
2011-12-01 21:48:07 +00:00
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
|
|
|
|
|
2014-02-24 20:55:55 +00:00
|
|
|
cainfo = INI_STR("openssl.cafile");
|
2014-09-14 20:07:38 +00:00
|
|
|
if (!(cainfo && cainfo[0] != '\0')) {
|
2014-02-24 20:55:55 +00:00
|
|
|
cainfo = INI_STR("curl.cainfo");
|
|
|
|
}
|
2014-09-14 20:07:38 +00:00
|
|
|
if (cainfo && cainfo[0] != '\0') {
|
2011-12-01 21:48:07 +00:00
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo);
|
|
|
|
}
|
|
|
|
|
2020-05-12 20:36:08 +00:00
|
|
|
#ifdef ZTS
|
2011-12-01 21:48:07 +00:00
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Initialize a cURL session */
|
2000-08-13 19:32:09 +00:00
|
|
|
PHP_FUNCTION(curl_init)
|
2000-07-16 19:37:33 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
php_curl *ch;
|
|
|
|
CURL *cp;
|
2016-12-28 16:38:01 +00:00
|
|
|
zend_string *url = NULL;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2016-12-28 16:38:01 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(0,1)
|
|
|
|
Z_PARAM_OPTIONAL
|
2020-06-18 07:26:09 +00:00
|
|
|
Z_PARAM_STR_OR_NULL(url)
|
2016-12-28 16:38:01 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2000-11-22 15:46:13 +00:00
|
|
|
|
2004-03-12 18:41:19 +00:00
|
|
|
cp = curl_easy_init();
|
|
|
|
if (!cp) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Could not initialize a new cURL handle");
|
2000-07-16 19:37:33 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2004-03-12 18:41:19 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = init_curl_handle_into_zval(return_value);
|
2004-03-12 18:41:19 +00:00
|
|
|
|
|
|
|
ch->cp = cp;
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2001-05-04 04:20:38 +00:00
|
|
|
ch->handlers->write->method = PHP_CURL_STDOUT;
|
|
|
|
ch->handlers->read->method = PHP_CURL_DIRECT;
|
2001-07-18 10:47:54 +00:00
|
|
|
ch->handlers->write_header->method = PHP_CURL_IGNORE;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
_php_curl_set_default_options(ch);
|
2002-07-31 22:10:58 +00:00
|
|
|
|
2008-02-07 02:08:45 +00:00
|
|
|
if (url) {
|
2016-12-28 16:38:01 +00:00
|
|
|
if (php_curl_option_url(ch, ZSTR_VAL(url), ZSTR_LEN(url)) == FAILURE) {
|
2020-06-17 14:05:55 +00:00
|
|
|
zval_ptr_dtor(return_value);
|
2009-05-18 10:31:08 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2000-07-16 19:37:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2015-12-02 21:47:28 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
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->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;
|
2020-02-11 08:45:05 +00:00
|
|
|
|
2015-12-02 21:47:28 +00:00
|
|
|
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->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);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
ch->handlers->fnmatch->method = source->handlers->fnmatch->method;
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, (void *) ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
efree(ch->to_free->slist);
|
|
|
|
efree(ch->to_free);
|
|
|
|
ch->to_free = source->to_free;
|
|
|
|
efree(ch->clone);
|
|
|
|
ch->clone = source->clone;
|
|
|
|
|
|
|
|
/* Keep track of cloned copies to avoid invoking curl destructors for every clone */
|
|
|
|
(*source->clone)++;
|
|
|
|
}
|
|
|
|
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
|
|
|
|
static size_t read_cb(char *buffer, size_t size, size_t nitems, void *arg) /* {{{ */
|
2004-03-12 18:37:55 +00:00
|
|
|
{
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) arg;
|
|
|
|
ssize_t numread;
|
2009-05-18 12:51:05 +00:00
|
|
|
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
if (cb_arg->stream == NULL) {
|
|
|
|
if (!(cb_arg->stream = php_stream_open_wrapper(ZSTR_VAL(cb_arg->filename), "rb", IGNORE_PATH, NULL))) {
|
|
|
|
return CURL_READFUNC_ABORT;
|
|
|
|
}
|
2015-02-02 05:23:16 +00:00
|
|
|
}
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
numread = php_stream_read(cb_arg->stream, buffer, nitems * size);
|
|
|
|
if (numread < 0) {
|
|
|
|
php_stream_close(cb_arg->stream);
|
|
|
|
cb_arg->stream = NULL;
|
|
|
|
return CURL_READFUNC_ABORT;
|
2004-03-12 18:37:55 +00:00
|
|
|
}
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
return numread;
|
2004-03-12 18:37:55 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
static int seek_cb(void *arg, curl_off_t offset, int origin) /* {{{ */
|
2019-04-29 08:21:07 +00:00
|
|
|
{
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) arg;
|
|
|
|
int res;
|
2019-04-29 08:21:07 +00:00
|
|
|
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
if (cb_arg->stream == NULL) {
|
|
|
|
return CURL_SEEKFUNC_CANTSEEK;
|
2019-04-29 08:21:07 +00:00
|
|
|
}
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
res = php_stream_seek(cb_arg->stream, offset, origin);
|
|
|
|
return res == SUCCESS ? CURL_SEEKFUNC_OK : CURL_SEEKFUNC_CANTSEEK;
|
2019-04-29 08:21:07 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
static void free_cb(void *arg) /* {{{ */
|
2019-04-29 08:21:07 +00:00
|
|
|
{
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) arg;
|
2019-04-29 08:21:07 +00:00
|
|
|
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
if (cb_arg->stream != NULL) {
|
|
|
|
php_stream_close(cb_arg->stream);
|
|
|
|
cb_arg->stream = NULL;
|
2019-04-29 08:21:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
#endif
|
|
|
|
|
2020-01-08 15:54:31 +00:00
|
|
|
static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields) /* {{{ */
|
|
|
|
{
|
2020-06-26 10:35:52 +00:00
|
|
|
HashTable *postfields = Z_ARRVAL_P(zpostfields);
|
2020-01-08 15:54:31 +00:00
|
|
|
CURLcode error = CURLE_OK;
|
|
|
|
zval *current;
|
|
|
|
zend_string *string_key;
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
zend_ulong num_key;
|
2020-01-08 15:54:31 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
|
|
|
|
curl_mime *mime = NULL;
|
|
|
|
curl_mimepart *part;
|
|
|
|
CURLcode form_error;
|
|
|
|
#else
|
|
|
|
struct HttpPost *first = NULL;
|
|
|
|
struct HttpPost *last = NULL;
|
|
|
|
CURLFORMcode form_error;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
|
|
|
|
if (zend_hash_num_elements(postfields) > 0) {
|
|
|
|
mime = curl_mime_init(ch->cp);
|
|
|
|
if (mime == NULL) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-06-26 10:35:52 +00:00
|
|
|
ZEND_HASH_FOREACH_KEY_VAL(postfields, num_key, string_key, current) {
|
2020-01-08 15:54:31 +00:00
|
|
|
zend_string *postval, *tmp_postval;
|
|
|
|
/* Pretend we have a string_key here */
|
|
|
|
if (!string_key) {
|
|
|
|
string_key = zend_long_to_str(num_key);
|
|
|
|
} else {
|
|
|
|
zend_string_addref(string_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
ZVAL_DEREF(current);
|
|
|
|
if (Z_TYPE_P(current) == IS_OBJECT &&
|
|
|
|
instanceof_function(Z_OBJCE_P(current), curl_CURLFile_class)) {
|
|
|
|
/* new-style file upload */
|
|
|
|
zval *prop, rv;
|
|
|
|
char *type = NULL, *filename = NULL;
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
struct mime_data_cb_arg *cb_arg;
|
2020-03-02 17:45:12 +00:00
|
|
|
php_stream *stream;
|
|
|
|
php_stream_statbuf ssb;
|
|
|
|
size_t filesize = -1;
|
|
|
|
curl_seek_callback seekfunc = seek_cb;
|
2020-01-08 15:54:31 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv);
|
|
|
|
if (Z_TYPE_P(prop) != IS_STRING) {
|
|
|
|
php_error_docref(NULL, E_WARNING, "Invalid filename for key %s", ZSTR_VAL(string_key));
|
|
|
|
} else {
|
|
|
|
postval = Z_STR_P(prop);
|
|
|
|
|
|
|
|
if (php_check_open_basedir(ZSTR_VAL(postval))) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = zend_read_property(curl_CURLFile_class, current, "mime", sizeof("mime")-1, 0, &rv);
|
|
|
|
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
|
|
|
|
type = Z_STRVAL_P(prop);
|
|
|
|
}
|
|
|
|
prop = zend_read_property(curl_CURLFile_class, current, "postname", sizeof("postname")-1, 0, &rv);
|
|
|
|
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
|
|
|
|
filename = Z_STRVAL_P(prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
zval_ptr_dtor(&ch->postfields);
|
|
|
|
ZVAL_COPY(&ch->postfields, zpostfields);
|
|
|
|
|
2020-03-02 17:45:12 +00:00
|
|
|
if ((stream = php_stream_open_wrapper(ZSTR_VAL(postval), "rb", STREAM_MUST_SEEK, NULL))) {
|
|
|
|
if (!stream->readfilters.head && !php_stream_stat(stream, &ssb)) {
|
|
|
|
filesize = ssb.sb.st_size;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
seekfunc = NULL;
|
|
|
|
}
|
|
|
|
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
cb_arg = emalloc(sizeof *cb_arg);
|
|
|
|
cb_arg->filename = zend_string_copy(postval);
|
2020-03-02 17:45:12 +00:00
|
|
|
cb_arg->stream = stream;
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
|
2020-01-08 15:54:31 +00:00
|
|
|
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
|
2020-03-02 17:45:12 +00:00
|
|
|
|| (form_error = curl_mime_data_cb(part, filesize, read_cb, seekfunc, free_cb, cb_arg)) != CURLE_OK
|
2020-01-08 15:54:31 +00:00
|
|
|
|| (form_error = curl_mime_filename(part, filename ? filename : ZSTR_VAL(postval))) != CURLE_OK
|
|
|
|
|| (form_error = curl_mime_type(part, type ? type : "application/octet-stream")) != CURLE_OK) {
|
|
|
|
error = form_error;
|
|
|
|
}
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
zend_llist_add_element(&ch->to_free->stream, &cb_arg);
|
2020-01-08 15:54:31 +00:00
|
|
|
#else
|
|
|
|
form_error = curl_formadd(&first, &last,
|
|
|
|
CURLFORM_COPYNAME, ZSTR_VAL(string_key),
|
|
|
|
CURLFORM_NAMELENGTH, ZSTR_LEN(string_key),
|
|
|
|
CURLFORM_FILENAME, filename ? filename : ZSTR_VAL(postval),
|
|
|
|
CURLFORM_CONTENTTYPE, type ? type : "application/octet-stream",
|
|
|
|
CURLFORM_FILE, ZSTR_VAL(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 */
|
|
|
|
part = curl_mime_addpart(mime);
|
|
|
|
if (part == NULL) {
|
|
|
|
zend_tmp_string_release(tmp_postval);
|
|
|
|
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) {
|
|
|
|
error = form_error;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
/* The arguments after _NAMELENGTH and _CONTENTSLENGTH
|
|
|
|
* must be explicitly cast to long in curl_formadd
|
|
|
|
* use since curl needs a long not an int. */
|
|
|
|
form_error = curl_formadd(&first, &last,
|
|
|
|
CURLFORM_COPYNAME, ZSTR_VAL(string_key),
|
|
|
|
CURLFORM_NAMELENGTH, ZSTR_LEN(string_key),
|
|
|
|
CURLFORM_COPYCONTENTS, ZSTR_VAL(postval),
|
|
|
|
CURLFORM_CONTENTSLENGTH, 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_tmp_string_release(tmp_postval);
|
|
|
|
zend_string_release_ex(string_key, 0);
|
|
|
|
} ZEND_HASH_FOREACH_END();
|
|
|
|
|
|
|
|
SAVE_CURL_ERROR(ch, error);
|
|
|
|
if (error != CURLE_OK) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*ch->clone) == 1) {
|
|
|
|
zend_llist_clean(&ch->to_free->post);
|
|
|
|
}
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
|
|
|
|
zend_llist_add_element(&ch->to_free->post, &mime);
|
|
|
|
error = curl_easy_setopt(ch->cp, CURLOPT_MIMEPOST, mime);
|
|
|
|
#else
|
|
|
|
zend_llist_add_element(&ch->to_free->post, &first);
|
|
|
|
error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first);
|
|
|
|
#endif
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
|
2020-01-08 15:54:31 +00:00
|
|
|
SAVE_CURL_ERROR(ch, error);
|
|
|
|
return error == CURLE_OK ? SUCCESS : FAILURE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Copy a cURL handle along with all of it's preferences */
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
PHP_FUNCTION(curl_copy_handle)
|
|
|
|
{
|
2020-06-17 14:05:55 +00:00
|
|
|
php_curl *ch;
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
CURL *cp;
|
|
|
|
zval *zid;
|
2020-06-17 14:05:55 +00:00
|
|
|
php_curl *dupch;
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
zval *postfields;
|
|
|
|
|
|
|
|
ZEND_PARSE_PARAMETERS_START(1,1)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
|
|
|
|
cp = curl_easy_duphandle(ch->cp);
|
|
|
|
if (!cp) {
|
|
|
|
php_error_docref(NULL, E_WARNING, "Cannot duplicate cURL handle");
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
dupch = init_curl_handle_into_zval(return_value);
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
dupch->cp = cp;
|
|
|
|
|
|
|
|
_php_setup_easy_copy_handlers(dupch, ch);
|
|
|
|
|
|
|
|
postfields = &ch->postfields;
|
|
|
|
if (Z_TYPE_P(postfields) != IS_UNDEF) {
|
|
|
|
if (build_mime_structure_from_hash(dupch, postfields) != SUCCESS) {
|
2020-06-17 14:05:55 +00:00
|
|
|
zval_ptr_dtor(return_value);
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Cannot rebuild mime structure");
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ */
|
2000-07-16 19:37:33 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
CURLcode error = CURLE_OK;
|
2015-02-10 21:02:45 +00:00
|
|
|
zend_long lval;
|
2002-07-26 22:57:14 +00:00
|
|
|
|
2001-04-30 14:36:19 +00:00
|
|
|
switch (option) {
|
2011-12-01 21:48:07 +00:00
|
|
|
/* Long options */
|
2012-10-25 04:47:47 +00:00
|
|
|
case CURLOPT_SSL_VERIFYHOST:
|
2015-02-10 21:02:45 +00:00
|
|
|
lval = zval_get_long(zvalue);
|
|
|
|
if (lval == 1) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_NOTICE, "CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value 2 will be used instead");
|
2012-12-22 00:27:51 +00:00
|
|
|
error = curl_easy_setopt(ch->cp, option, 2);
|
|
|
|
break;
|
2012-10-25 04:47:47 +00:00
|
|
|
}
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_AUTOREFERER:
|
|
|
|
case CURLOPT_BUFFERSIZE:
|
2002-07-31 22:10:58 +00:00
|
|
|
case CURLOPT_CONNECTTIMEOUT:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_COOKIESESSION:
|
|
|
|
case CURLOPT_CRLF:
|
|
|
|
case CURLOPT_DNS_CACHE_TIMEOUT:
|
2002-07-31 22:10:58 +00:00
|
|
|
case CURLOPT_DNS_USE_GLOBAL_CACHE:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_FAILONERROR:
|
|
|
|
case CURLOPT_FILETIME:
|
|
|
|
case CURLOPT_FORBID_REUSE:
|
|
|
|
case CURLOPT_FRESH_CONNECT:
|
|
|
|
case CURLOPT_FTP_USE_EPRT:
|
|
|
|
case CURLOPT_FTP_USE_EPSV:
|
|
|
|
case CURLOPT_HEADER:
|
2002-11-09 13:52:00 +00:00
|
|
|
case CURLOPT_HTTPGET:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_HTTPPROXYTUNNEL:
|
2002-11-09 13:52:00 +00:00
|
|
|
case CURLOPT_HTTP_VERSION:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_INFILESIZE:
|
|
|
|
case CURLOPT_LOW_SPEED_LIMIT:
|
|
|
|
case CURLOPT_LOW_SPEED_TIME:
|
|
|
|
case CURLOPT_MAXCONNECTS:
|
|
|
|
case CURLOPT_MAXREDIRS:
|
|
|
|
case CURLOPT_NETRC:
|
|
|
|
case CURLOPT_NOBODY:
|
|
|
|
case CURLOPT_NOPROGRESS:
|
|
|
|
case CURLOPT_NOSIGNAL:
|
|
|
|
case CURLOPT_PORT:
|
|
|
|
case CURLOPT_POST:
|
2003-06-19 22:12:21 +00:00
|
|
|
case CURLOPT_PROXYPORT:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_PROXYTYPE:
|
|
|
|
case CURLOPT_PUT:
|
|
|
|
case CURLOPT_RESUME_FROM:
|
|
|
|
case CURLOPT_SSLVERSION:
|
|
|
|
case CURLOPT_SSL_VERIFYPEER:
|
|
|
|
case CURLOPT_TIMECONDITION:
|
|
|
|
case CURLOPT_TIMEOUT:
|
|
|
|
case CURLOPT_TIMEVALUE:
|
|
|
|
case CURLOPT_TRANSFERTEXT:
|
|
|
|
case CURLOPT_UNRESTRICTED_AUTH:
|
|
|
|
case CURLOPT_UPLOAD:
|
|
|
|
case CURLOPT_VERBOSE:
|
2003-06-19 22:12:21 +00:00
|
|
|
case CURLOPT_HTTPAUTH:
|
2007-04-23 14:36:56 +00:00
|
|
|
case CURLOPT_FTP_CREATE_MISSING_DIRS:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_PROXYAUTH:
|
|
|
|
case CURLOPT_FTP_RESPONSE_TIMEOUT:
|
|
|
|
case CURLOPT_IPRESOLVE:
|
|
|
|
case CURLOPT_MAXFILESIZE:
|
2007-01-09 23:13:05 +00:00
|
|
|
case CURLOPT_TCP_NODELAY:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_FTPSSLAUTH:
|
|
|
|
case CURLOPT_IGNORE_CONTENT_LENGTH:
|
2010-01-23 01:37:32 +00:00
|
|
|
case CURLOPT_FTP_SKIP_PASV_IP:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_FTP_FILEMETHOD:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_CONNECT_ONLY:
|
|
|
|
case CURLOPT_LOCALPORT:
|
|
|
|
case CURLOPT_LOCALPORTRANGE:
|
|
|
|
case CURLOPT_SSL_SESSIONID_CACHE:
|
|
|
|
case CURLOPT_FTP_SSL_CCC:
|
2012-08-24 22:04:16 +00:00
|
|
|
case CURLOPT_SSH_AUTH_TYPES:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_CONNECTTIMEOUT_MS:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_HTTP_CONTENT_DECODING:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_HTTP_TRANSFER_DECODING:
|
|
|
|
case CURLOPT_TIMEOUT_MS:
|
2012-08-24 22:04:16 +00:00
|
|
|
case CURLOPT_NEW_DIRECTORY_PERMS:
|
|
|
|
case CURLOPT_NEW_FILE_PERMS:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_USE_SSL:
|
|
|
|
case CURLOPT_APPEND:
|
|
|
|
case CURLOPT_DIRLISTONLY:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_PROXY_TRANSFER_MODE:
|
|
|
|
case CURLOPT_ADDRESS_SCOPE:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_CERTINFO:
|
|
|
|
case CURLOPT_PROTOCOLS:
|
|
|
|
case CURLOPT_REDIR_PROTOCOLS:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_SOCKS5_GSSAPI_NEC:
|
|
|
|
case CURLOPT_TFTP_BLKSIZE:
|
|
|
|
case CURLOPT_FTP_USE_PRET:
|
|
|
|
case CURLOPT_RTSP_CLIENT_CSEQ:
|
|
|
|
case CURLOPT_RTSP_REQUEST:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_RTSP_SERVER_CSEQ:
|
2011-12-04 00:19:12 +00:00
|
|
|
case CURLOPT_WILDCARDMATCH:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_TLSAUTH_TYPE:
|
2012-12-28 05:51:04 +00:00
|
|
|
case CURLOPT_GSSAPI_DELEGATION:
|
|
|
|
case CURLOPT_ACCEPTTIMEOUT_MS:
|
|
|
|
case CURLOPT_SSL_OPTIONS:
|
|
|
|
case CURLOPT_TCP_KEEPALIVE:
|
|
|
|
case CURLOPT_TCP_KEEPIDLE:
|
|
|
|
case CURLOPT_TCP_KEEPINTVL:
|
2016-04-27 22:43:41 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x071f00 /* Available since 7.31.0 */
|
|
|
|
case CURLOPT_SASL_IR:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072400 /* Available since 7.36.0 */
|
|
|
|
case CURLOPT_EXPECT_100_TIMEOUT_MS:
|
|
|
|
case CURLOPT_SSL_ENABLE_ALPN:
|
|
|
|
case CURLOPT_SSL_ENABLE_NPN:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072500 /* Available since 7.37.0 */
|
|
|
|
case CURLOPT_HEADEROPT:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072900 /* Available since 7.41.0 */
|
|
|
|
case CURLOPT_SSL_VERIFYSTATUS:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072a00 /* Available since 7.42.0 */
|
|
|
|
case CURLOPT_PATH_AS_IS:
|
|
|
|
case CURLOPT_SSL_FALSESTART:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072b00 /* Available since 7.43.0 */
|
|
|
|
case CURLOPT_PIPEWAIT:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072e00 /* Available since 7.46.0 */
|
|
|
|
case CURLOPT_STREAM_WEIGHT:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073000 /* Available since 7.48.0 */
|
|
|
|
case CURLOPT_TFTP_NO_OPTIONS:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073100 /* Available since 7.49.0 */
|
|
|
|
case CURLOPT_TCP_FASTOPEN:
|
2011-11-22 17:33:48 +00:00
|
|
|
#endif
|
2018-10-03 23:43:59 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073300 /* Available since 7.51.0 */
|
|
|
|
case CURLOPT_KEEP_SENDING_ON_ERROR:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073400 /* Available since 7.52.0 */
|
|
|
|
case CURLOPT_PROXY_SSL_OPTIONS:
|
|
|
|
case CURLOPT_PROXY_SSL_VERIFYHOST:
|
|
|
|
case CURLOPT_PROXY_SSL_VERIFYPEER:
|
|
|
|
case CURLOPT_PROXY_SSLVERSION:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073600 /* Available since 7.54.0 */
|
|
|
|
case CURLOPT_SUPPRESS_CONNECT_HEADERS:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073700 /* Available since 7.55.0 */
|
|
|
|
case CURLOPT_SOCKS5_AUTH:
|
|
|
|
#endif
|
2018-10-08 14:15:20 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073800 /* Available since 7.56.0 */
|
|
|
|
case CURLOPT_SSH_COMPRESSION:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073b00 /* Available since 7.59.0 */
|
|
|
|
case CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073c00 /* Available since 7.60.0 */
|
|
|
|
case CURLOPT_DNS_SHUFFLE_ADDRESSES:
|
|
|
|
case CURLOPT_HAPROXYPROTOCOL:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073d00 /* Available since 7.61.0 */
|
|
|
|
case CURLOPT_DISALLOW_USERNAME_IN_URL:
|
2020-01-26 04:18:57 +00:00
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x074000 /* Available since 7.64.0 */
|
|
|
|
case CURLOPT_HTTP09_ALLOWED:
|
2018-10-08 14:15:20 +00:00
|
|
|
#endif
|
2015-02-10 21:02:45 +00:00
|
|
|
lval = zval_get_long(zvalue);
|
2009-09-23 02:08:19 +00:00
|
|
|
if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) &&
|
2015-02-10 21:02:45 +00:00
|
|
|
(PG(open_basedir) && *PG(open_basedir)) && (lval & CURLPROTO_FILE)) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "CURLPROTO_FILE cannot be activated when an open_basedir is set");
|
2009-05-18 10:31:08 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2015-12-18 16:29:19 +00:00
|
|
|
# if defined(ZTS)
|
2018-06-17 03:39:08 +00:00
|
|
|
if (option == CURLOPT_DNS_USE_GLOBAL_CACHE && lval) {
|
2016-02-18 06:44:05 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled");
|
2015-12-18 16:29:19 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
# endif
|
2015-02-10 21:02:45 +00:00
|
|
|
error = curl_easy_setopt(ch->cp, option, lval);
|
2002-07-31 22:10:58 +00:00
|
|
|
break;
|
2013-01-29 06:22:59 +00:00
|
|
|
case CURLOPT_SAFE_UPLOAD:
|
2016-12-13 21:52:16 +00:00
|
|
|
if (!zend_is_true(zvalue)) {
|
2015-03-09 10:00:04 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Disabling safe uploads is no longer supported");
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2013-01-29 06:22:59 +00:00
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
|
|
|
/* String options */
|
|
|
|
case CURLOPT_CAINFO:
|
|
|
|
case CURLOPT_CAPATH:
|
|
|
|
case CURLOPT_COOKIE:
|
|
|
|
case CURLOPT_EGDSOCKET:
|
|
|
|
case CURLOPT_INTERFACE:
|
2002-07-31 22:10:58 +00:00
|
|
|
case CURLOPT_PROXY:
|
|
|
|
case CURLOPT_PROXYUSERPWD:
|
|
|
|
case CURLOPT_REFERER:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_SSLCERTTYPE:
|
2009-05-03 15:16:10 +00:00
|
|
|
case CURLOPT_SSLENGINE:
|
2003-02-02 20:56:51 +00:00
|
|
|
case CURLOPT_SSLENGINE_DEFAULT:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_SSLKEY:
|
|
|
|
case CURLOPT_SSLKEYPASSWD:
|
|
|
|
case CURLOPT_SSLKEYTYPE:
|
|
|
|
case CURLOPT_SSL_CIPHER_LIST:
|
|
|
|
case CURLOPT_USERAGENT:
|
|
|
|
case CURLOPT_USERPWD:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_COOKIELIST:
|
|
|
|
case CURLOPT_FTP_ALTERNATIVE_TO_USER:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_PASSWORD:
|
|
|
|
case CURLOPT_PROXYPASSWORD:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_PROXYUSERNAME:
|
|
|
|
case CURLOPT_USERNAME:
|
2016-03-18 12:29:01 +00:00
|
|
|
case CURLOPT_NOPROXY:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_SOCKS5_GSSAPI_SERVICE:
|
|
|
|
case CURLOPT_MAIL_FROM:
|
|
|
|
case CURLOPT_RTSP_STREAM_URI:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_RTSP_TRANSPORT:
|
|
|
|
case CURLOPT_TLSAUTH_PASSWORD:
|
|
|
|
case CURLOPT_TLSAUTH_USERNAME:
|
|
|
|
case CURLOPT_ACCEPT_ENCODING:
|
|
|
|
case CURLOPT_TRANSFER_ENCODING:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_DNS_SERVERS:
|
2012-05-27 22:39:45 +00:00
|
|
|
case CURLOPT_MAIL_AUTH:
|
2016-04-27 22:43:41 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072200 /* Available since 7.34.0 */
|
|
|
|
case CURLOPT_LOGIN_OPTIONS:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072700 /* Available since 7.39.0 */
|
|
|
|
case CURLOPT_PINNEDPUBLICKEY:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072b00 /* Available since 7.43.0 */
|
|
|
|
case CURLOPT_PROXY_SERVICE_NAME:
|
|
|
|
case CURLOPT_SERVICE_NAME:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072d00 /* Available since 7.45.0 */
|
|
|
|
case CURLOPT_DEFAULT_PROTOCOL:
|
2017-12-06 02:35:12 +00:00
|
|
|
#endif
|
2018-10-03 23:43:59 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073400 /* Available since 7.52.0 */
|
|
|
|
case CURLOPT_PRE_PROXY:
|
|
|
|
case CURLOPT_PROXY_CAINFO:
|
|
|
|
case CURLOPT_PROXY_CAPATH:
|
|
|
|
case CURLOPT_PROXY_CRLFILE:
|
|
|
|
case CURLOPT_PROXY_KEYPASSWD:
|
|
|
|
case CURLOPT_PROXY_PINNEDPUBLICKEY:
|
|
|
|
case CURLOPT_PROXY_SSL_CIPHER_LIST:
|
|
|
|
case CURLOPT_PROXY_SSLCERT:
|
|
|
|
case CURLOPT_PROXY_SSLCERTTYPE:
|
|
|
|
case CURLOPT_PROXY_SSLKEY:
|
|
|
|
case CURLOPT_PROXY_SSLKEYTYPE:
|
|
|
|
case CURLOPT_PROXY_TLSAUTH_PASSWORD:
|
|
|
|
case CURLOPT_PROXY_TLSAUTH_TYPE:
|
|
|
|
case CURLOPT_PROXY_TLSAUTH_USERNAME:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073500 /* Available since 7.53.0 */
|
|
|
|
case CURLOPT_ABSTRACT_UNIX_SOCKET:
|
|
|
|
#endif
|
2017-12-06 02:35:12 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073700 /* Available since 7.55.0 */
|
|
|
|
case CURLOPT_REQUEST_TARGET:
|
2018-10-08 14:15:20 +00:00
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073d00 /* Available since 7.61.0 */
|
|
|
|
case CURLOPT_PROXY_TLS13_CIPHERS:
|
|
|
|
case CURLOPT_TLS13_CIPHERS:
|
2012-05-27 07:02:53 +00:00
|
|
|
#endif
|
- MFH
- [DOC] Add support for SSH via libssh2
- new constants: CURLE_SSH, CURLSSH_AUTH_NONE, CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, CURLSSH_AUTH_KEYBOARD, CURLSSH_AUTH_DEFAULT, CURLOPT_SSH_AUTH_TYPES, CURLOPT_KEYPASSWD, CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html fortheir roles or usages
2009-01-25 16:28:18 +00:00
|
|
|
{
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_string *tmp_str;
|
|
|
|
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
2015-06-30 01:05:24 +00:00
|
|
|
int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0);
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_tmp_string_release(tmp_str);
|
2015-02-10 21:02:45 +00:00
|
|
|
return ret;
|
2013-11-18 04:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Curl nullable string options */
|
|
|
|
case CURLOPT_CUSTOMREQUEST:
|
|
|
|
case CURLOPT_FTPPORT:
|
|
|
|
case CURLOPT_RANGE:
|
|
|
|
case CURLOPT_FTP_ACCOUNT:
|
|
|
|
case CURLOPT_RTSP_SESSION_ID:
|
2016-04-27 22:43:41 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072100 /* Available since 7.33.0 */
|
|
|
|
case CURLOPT_DNS_INTERFACE:
|
|
|
|
case CURLOPT_DNS_LOCAL_IP4:
|
|
|
|
case CURLOPT_DNS_LOCAL_IP6:
|
|
|
|
case CURLOPT_XOAUTH2_BEARER:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072800 /* Available since 7.40.0 */
|
|
|
|
case CURLOPT_UNIX_SOCKET_PATH:
|
|
|
|
#endif
|
2013-11-18 04:06:27 +00:00
|
|
|
case CURLOPT_KRBLEVEL:
|
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
if (Z_ISNULL_P(zvalue)) {
|
2013-11-18 04:06:27 +00:00
|
|
|
error = curl_easy_setopt(ch->cp, option, NULL);
|
|
|
|
} else {
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_string *tmp_str;
|
|
|
|
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
2015-06-30 01:05:24 +00:00
|
|
|
int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0);
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_tmp_string_release(tmp_str);
|
2015-02-10 21:02:45 +00:00
|
|
|
return ret;
|
2009-05-18 10:31:08 +00:00
|
|
|
}
|
2002-07-31 22:10:58 +00:00
|
|
|
break;
|
2001-11-20 11:29:54 +00:00
|
|
|
}
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2013-11-18 04:06:27 +00:00
|
|
|
/* Curl private option */
|
|
|
|
case CURLOPT_PRIVATE:
|
2015-02-10 21:02:45 +00:00
|
|
|
{
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_string *tmp_str;
|
|
|
|
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
2015-06-30 01:05:24 +00:00
|
|
|
int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 1);
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_tmp_string_release(tmp_str);
|
2015-02-10 21:02:45 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2013-11-18 04:06:27 +00:00
|
|
|
|
|
|
|
/* Curl url option */
|
|
|
|
case CURLOPT_URL:
|
2015-02-10 21:02:45 +00:00
|
|
|
{
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_string *tmp_str;
|
|
|
|
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
2015-06-30 01:05:24 +00:00
|
|
|
int ret = php_curl_option_url(ch, ZSTR_VAL(str), ZSTR_LEN(str));
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_tmp_string_release(tmp_str);
|
2015-02-10 21:02:45 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2013-11-18 04:06:27 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* Curl file handle options */
|
2001-06-25 15:14:20 +00:00
|
|
|
case CURLOPT_FILE:
|
2009-05-03 15:16:10 +00:00
|
|
|
case CURLOPT_INFILE:
|
2013-01-29 06:22:59 +00:00
|
|
|
case CURLOPT_STDERR:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_WRITEHEADER: {
|
2002-07-31 22:10:58 +00:00
|
|
|
FILE *fp = NULL;
|
2014-05-09 04:17:09 +00:00
|
|
|
php_stream *what = NULL;
|
- MFH
- [DOC] Add support for SSH via libssh2
- new constants: CURLE_SSH, CURLSSH_AUTH_NONE, CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, CURLSSH_AUTH_KEYBOARD, CURLSSH_AUTH_DEFAULT, CURLOPT_SSH_AUTH_TYPES, CURLOPT_KEYPASSWD, CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html fortheir roles or usages
2009-01-25 16:28:18 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
if (Z_TYPE_P(zvalue) != IS_NULL) {
|
2015-02-02 06:45:19 +00:00
|
|
|
what = (php_stream *)zend_fetch_resource2_ex(zvalue, "File-Handle", php_file_le_stream(), php_file_le_pstream());
|
2014-04-30 07:26:50 +00:00
|
|
|
if (!what) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
if (FAILURE == php_stream_cast(what, PHP_STREAM_AS_STDIO, (void *) &fp, REPORT_ERRORS)) {
|
2014-04-30 07:26:50 +00:00
|
|
|
return FAILURE;
|
|
|
|
}
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2014-04-30 07:26:50 +00:00
|
|
|
if (!fp) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
2002-07-31 22:10:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
error = CURLE_OK;
|
|
|
|
switch (option) {
|
|
|
|
case CURLOPT_FILE:
|
2014-04-30 07:26:50 +00:00
|
|
|
if (!what) {
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->write->stream)) {
|
|
|
|
zval_ptr_dtor(&ch->handlers->write->stream);
|
|
|
|
ZVAL_UNDEF(&ch->handlers->write->stream);
|
2014-04-30 07:26:50 +00:00
|
|
|
}
|
|
|
|
ch->handlers->write->fp = NULL;
|
|
|
|
ch->handlers->write->method = PHP_CURL_STDOUT;
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (what->mode[0] != 'r' || what->mode[1] == '+') {
|
|
|
|
zval_ptr_dtor(&ch->handlers->write->stream);
|
2009-05-21 12:52:05 +00:00
|
|
|
ch->handlers->write->fp = fp;
|
|
|
|
ch->handlers->write->method = PHP_CURL_FILE;
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY(&ch->handlers->write->stream, zvalue);
|
2009-05-21 12:52:05 +00:00
|
|
|
} else {
|
2020-01-15 10:27:29 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "The provided file handle is not writable");
|
2013-11-18 04:06:27 +00:00
|
|
|
return FAILURE;
|
2009-05-21 12:52:05 +00:00
|
|
|
}
|
2002-07-31 22:10:58 +00:00
|
|
|
break;
|
|
|
|
case CURLOPT_WRITEHEADER:
|
2014-04-30 07:26:50 +00:00
|
|
|
if (!what) {
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->write_header->stream)) {
|
|
|
|
zval_ptr_dtor(&ch->handlers->write_header->stream);
|
|
|
|
ZVAL_UNDEF(&ch->handlers->write_header->stream);
|
2014-04-30 07:26:50 +00:00
|
|
|
}
|
|
|
|
ch->handlers->write_header->fp = NULL;
|
|
|
|
ch->handlers->write_header->method = PHP_CURL_IGNORE;
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (what->mode[0] != 'r' || what->mode[1] == '+') {
|
|
|
|
zval_ptr_dtor(&ch->handlers->write_header->stream);
|
2009-05-21 12:52:05 +00:00
|
|
|
ch->handlers->write_header->fp = fp;
|
|
|
|
ch->handlers->write_header->method = PHP_CURL_FILE;
|
2017-06-25 21:24:23 +00:00
|
|
|
ZVAL_COPY(&ch->handlers->write_header->stream, zvalue);
|
2009-05-21 12:52:05 +00:00
|
|
|
} else {
|
2020-01-15 10:27:29 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "The provided file handle is not writable");
|
2013-11-18 04:06:27 +00:00
|
|
|
return FAILURE;
|
2009-05-21 12:52:05 +00:00
|
|
|
}
|
2002-07-31 22:10:58 +00:00
|
|
|
break;
|
|
|
|
case CURLOPT_INFILE:
|
2014-04-30 07:26:50 +00:00
|
|
|
if (!what) {
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->read->stream)) {
|
|
|
|
zval_ptr_dtor(&ch->handlers->read->stream);
|
|
|
|
ZVAL_UNDEF(&ch->handlers->read->stream);
|
2014-04-30 07:26:50 +00:00
|
|
|
}
|
|
|
|
ch->handlers->read->fp = NULL;
|
2014-05-09 04:17:09 +00:00
|
|
|
ch->handlers->read->res = NULL;
|
2014-04-30 07:26:50 +00:00
|
|
|
} else {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->read->stream);
|
2014-04-30 07:26:50 +00:00
|
|
|
ch->handlers->read->fp = fp;
|
2014-05-09 04:17:09 +00:00
|
|
|
ch->handlers->read->res = Z_RES_P(zvalue);
|
|
|
|
ZVAL_COPY(&ch->handlers->read->stream, zvalue);
|
2011-11-21 02:29:24 +00:00
|
|
|
}
|
2002-07-31 22:10:58 +00:00
|
|
|
break;
|
2009-05-26 15:49:15 +00:00
|
|
|
case CURLOPT_STDERR:
|
2014-04-30 07:26:50 +00:00
|
|
|
if (!what) {
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->std_err)) {
|
2009-05-27 22:35:26 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->std_err);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_UNDEF(&ch->handlers->std_err);
|
2009-05-26 15:49:15 +00:00
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (what->mode[0] != 'r' || what->mode[1] == '+') {
|
|
|
|
zval_ptr_dtor(&ch->handlers->std_err);
|
|
|
|
ZVAL_COPY(&ch->handlers->std_err, zvalue);
|
2009-05-26 15:49:15 +00:00
|
|
|
} else {
|
2020-01-15 10:27:29 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "The provided file handle is not writable");
|
2013-11-18 04:06:27 +00:00
|
|
|
return FAILURE;
|
2009-05-26 15:49:15 +00:00
|
|
|
}
|
|
|
|
/* break omitted intentionally */
|
2002-07-31 22:10:58 +00:00
|
|
|
default:
|
|
|
|
error = curl_easy_setopt(ch->cp, option, fp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2002-07-26 22:57:14 +00:00
|
|
|
}
|
2002-07-31 22:10:58 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* Curl linked list options */
|
|
|
|
case CURLOPT_HTTP200ALIASES:
|
|
|
|
case CURLOPT_HTTPHEADER:
|
|
|
|
case CURLOPT_POSTQUOTE:
|
|
|
|
case CURLOPT_PREQUOTE:
|
|
|
|
case CURLOPT_QUOTE:
|
2012-12-28 05:51:04 +00:00
|
|
|
case CURLOPT_TELNETOPTIONS:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_MAIL_RCPT:
|
|
|
|
case CURLOPT_RESOLVE:
|
2016-04-27 22:43:41 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072500 /* Available since 7.37.0 */
|
|
|
|
case CURLOPT_PROXYHEADER:
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073100 /* Available since 7.49.0 */
|
|
|
|
case CURLOPT_CONNECT_TO:
|
2011-12-01 21:48:07 +00:00
|
|
|
#endif
|
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
zval *current;
|
|
|
|
HashTable *ph;
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_string *val, *tmp_val;
|
2014-05-09 04:17:09 +00:00
|
|
|
struct curl_slist *slist = NULL;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-06-26 10:35:52 +00:00
|
|
|
if (Z_TYPE_P(zvalue) != IS_ARRAY) {
|
2013-08-20 00:17:54 +00:00
|
|
|
char *name = NULL;
|
2011-12-01 21:48:07 +00:00
|
|
|
switch (option) {
|
|
|
|
case CURLOPT_HTTPHEADER:
|
|
|
|
name = "CURLOPT_HTTPHEADER";
|
|
|
|
break;
|
|
|
|
case CURLOPT_QUOTE:
|
|
|
|
name = "CURLOPT_QUOTE";
|
|
|
|
break;
|
|
|
|
case CURLOPT_HTTP200ALIASES:
|
|
|
|
name = "CURLOPT_HTTP200ALIASES";
|
|
|
|
break;
|
|
|
|
case CURLOPT_POSTQUOTE:
|
|
|
|
name = "CURLOPT_POSTQUOTE";
|
|
|
|
break;
|
|
|
|
case CURLOPT_PREQUOTE:
|
|
|
|
name = "CURLOPT_PREQUOTE";
|
|
|
|
break;
|
2012-12-28 05:51:04 +00:00
|
|
|
case CURLOPT_TELNETOPTIONS:
|
|
|
|
name = "CURLOPT_TELNETOPTIONS";
|
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_MAIL_RCPT:
|
|
|
|
name = "CURLOPT_MAIL_RCPT";
|
|
|
|
break;
|
|
|
|
case CURLOPT_RESOLVE:
|
|
|
|
name = "CURLOPT_RESOLVE";
|
|
|
|
break;
|
2016-04-27 22:43:41 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x072500 /* Available since 7.37.0 */
|
|
|
|
case CURLOPT_PROXYHEADER:
|
|
|
|
name = "CURLOPT_PROXYHEADER";
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073100 /* Available since 7.49.0 */
|
|
|
|
case CURLOPT_CONNECT_TO:
|
|
|
|
name = "CURLOPT_CONNECT_TO";
|
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
#endif
|
|
|
|
}
|
2020-06-26 10:35:52 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "You must pass an array with the %s argument", name);
|
2013-11-18 04:06:27 +00:00
|
|
|
return FAILURE;
|
2011-12-01 21:48:07 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 10:35:52 +00:00
|
|
|
ph = Z_ARRVAL_P(zvalue);
|
|
|
|
ZEND_HASH_FOREACH_VAL(ph, current) {
|
2015-12-27 06:54:39 +00:00
|
|
|
ZVAL_DEREF(current);
|
2017-11-16 14:09:32 +00:00
|
|
|
val = zval_get_tmp_string(current, &tmp_val);
|
2015-06-30 01:05:24 +00:00
|
|
|
slist = curl_slist_append(slist, ZSTR_VAL(val));
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_tmp_string_release(tmp_val);
|
2011-12-01 21:48:07 +00:00
|
|
|
if (!slist) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Could not build curl_slist");
|
2011-12-01 21:48:07 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
} ZEND_HASH_FOREACH_END();
|
|
|
|
|
2016-07-26 22:50:15 +00:00
|
|
|
if (slist) {
|
2016-07-26 23:20:12 +00:00
|
|
|
if ((*ch->clone) == 1) {
|
|
|
|
zend_hash_index_update_ptr(ch->to_free->slist, option, slist);
|
2016-07-26 22:50:15 +00:00
|
|
|
} else {
|
2016-07-26 23:20:12 +00:00
|
|
|
zend_hash_next_index_insert_ptr(ch->to_free->slist, slist);
|
2016-07-26 22:50:15 +00:00
|
|
|
}
|
2016-02-05 11:49:26 +00:00
|
|
|
}
|
2011-12-01 21:48:07 +00:00
|
|
|
|
|
|
|
error = curl_easy_setopt(ch->cp, option, slist);
|
|
|
|
|
2002-07-31 22:10:58 +00:00
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-31 22:10:58 +00:00
|
|
|
case CURLOPT_BINARYTRANSFER:
|
2011-11-22 17:13:26 +00:00
|
|
|
/* Do nothing, just backward compatibility */
|
2002-07-31 22:10:58 +00:00
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
|
|
|
case CURLOPT_FOLLOWLOCATION:
|
2016-12-13 21:52:16 +00:00
|
|
|
lval = zend_is_true(zvalue);
|
2015-02-10 21:02:45 +00:00
|
|
|
error = curl_easy_setopt(ch->cp, option, lval);
|
2009-05-03 14:59:46 +00:00
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2002-07-31 22:10:58 +00:00
|
|
|
case CURLOPT_HEADERFUNCTION:
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->write_header->func_name)) {
|
2003-05-21 23:15:28 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->write_header->func_name);
|
2008-07-29 10:42:44 +00:00
|
|
|
ch->handlers->write_header->fci_cache = empty_fcall_info_cache;
|
2002-11-08 17:58:43 +00:00
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY(&ch->handlers->write_header->func_name, zvalue);
|
2002-07-31 22:10:58 +00:00
|
|
|
ch->handlers->write_header->method = PHP_CURL_USER;
|
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2002-07-31 22:10:58 +00:00
|
|
|
case CURLOPT_POSTFIELDS:
|
2020-06-26 10:35:52 +00:00
|
|
|
if (Z_TYPE_P(zvalue) == IS_ARRAY) {
|
2020-01-08 15:54:31 +00:00
|
|
|
return build_mime_structure_from_hash(ch, zvalue);
|
2003-03-17 15:06:11 +00:00
|
|
|
} else {
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_string *tmp_str;
|
|
|
|
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
2008-12-17 14:13:40 +00:00
|
|
|
/* with curl 7.17.0 and later, we can use COPYPOSTFIELDS, but we have to provide size before */
|
2015-06-30 01:05:24 +00:00
|
|
|
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, ZSTR_LEN(str));
|
|
|
|
error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, ZSTR_VAL(str));
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_tmp_string_release(tmp_str);
|
2002-07-31 22:10:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_PROGRESSFUNCTION:
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION, curl_progress);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch);
|
2011-12-04 00:19:12 +00:00
|
|
|
if (ch->handlers->progress == NULL) {
|
2011-12-03 23:43:44 +00:00
|
|
|
ch->handlers->progress = ecalloc(1, sizeof(php_curl_progress));
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (!Z_ISUNDEF(ch->handlers->progress->func_name)) {
|
2011-12-01 21:48:07 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->progress->func_name);
|
|
|
|
ch->handlers->progress->fci_cache = empty_fcall_info_cache;
|
2002-07-31 22:10:58 +00:00
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY(&ch->handlers->progress->func_name, zvalue);
|
2011-12-01 21:48:07 +00:00
|
|
|
ch->handlers->progress->method = PHP_CURL_USER;
|
|
|
|
break;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_READFUNCTION:
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->read->func_name)) {
|
2011-12-01 21:48:07 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->read->func_name);
|
|
|
|
ch->handlers->read->fci_cache = empty_fcall_info_cache;
|
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY(&ch->handlers->read->func_name, zvalue);
|
2011-12-01 21:48:07 +00:00
|
|
|
ch->handlers->read->method = PHP_CURL_USER;
|
|
|
|
break;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_RETURNTRANSFER:
|
2016-12-13 21:52:16 +00:00
|
|
|
if (zend_is_true(zvalue)) {
|
2011-12-01 21:48:07 +00:00
|
|
|
ch->handlers->write->method = PHP_CURL_RETURN;
|
|
|
|
} else {
|
|
|
|
ch->handlers->write->method = PHP_CURL_STDOUT;
|
2000-10-20 04:57:14 +00:00
|
|
|
}
|
2011-12-01 21:48:07 +00:00
|
|
|
break;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_WRITEFUNCTION:
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->write->func_name)) {
|
2011-12-01 21:48:07 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->write->func_name);
|
|
|
|
ch->handlers->write->fci_cache = empty_fcall_info_cache;
|
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY(&ch->handlers->write->func_name, zvalue);
|
2011-12-01 21:48:07 +00:00
|
|
|
ch->handlers->write->method = PHP_CURL_USER;
|
|
|
|
break;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2018-10-08 14:15:20 +00:00
|
|
|
/* Curl off_t options */
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_MAX_RECV_SPEED_LARGE:
|
|
|
|
case CURLOPT_MAX_SEND_SPEED_LARGE:
|
2018-10-08 14:15:20 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073b00 /* Available since 7.59.0 */
|
|
|
|
case CURLOPT_TIMEVALUE_LARGE:
|
|
|
|
#endif
|
2015-02-10 21:02:45 +00:00
|
|
|
lval = zval_get_long(zvalue);
|
|
|
|
error = curl_easy_setopt(ch->cp, option, (curl_off_t)lval);
|
2003-06-19 22:12:21 +00:00
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
|
|
|
case CURLOPT_POSTREDIR:
|
2015-02-10 21:02:45 +00:00
|
|
|
lval = zval_get_long(zvalue);
|
|
|
|
error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, lval & CURL_REDIR_POST_ALL);
|
2011-12-01 21:48:07 +00:00
|
|
|
break;
|
|
|
|
|
2010-04-26 23:53:30 +00:00
|
|
|
/* the following options deal with files, therefore the open_basedir check
|
|
|
|
* is required.
|
2003-06-19 22:12:21 +00:00
|
|
|
*/
|
2013-01-29 06:22:59 +00:00
|
|
|
case CURLOPT_COOKIEFILE:
|
2003-06-19 22:12:21 +00:00
|
|
|
case CURLOPT_COOKIEJAR:
|
|
|
|
case CURLOPT_RANDOM_FILE:
|
2011-12-01 21:48:07 +00:00
|
|
|
case CURLOPT_SSLCERT:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_NETRC_FILE:
|
2012-08-24 22:04:16 +00:00
|
|
|
case CURLOPT_SSH_PRIVATE_KEYFILE:
|
|
|
|
case CURLOPT_SSH_PUBLIC_KEYFILE:
|
2011-11-22 17:33:48 +00:00
|
|
|
case CURLOPT_CRLFILE:
|
|
|
|
case CURLOPT_ISSUERCERT:
|
|
|
|
case CURLOPT_SSH_KNOWNHOSTS:
|
|
|
|
{
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_string *tmp_str;
|
|
|
|
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
2015-02-10 21:02:45 +00:00
|
|
|
int ret;
|
2003-06-19 22:12:21 +00:00
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
if (ZSTR_LEN(str) && php_check_open_basedir(ZSTR_VAL(str))) {
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_tmp_string_release(tmp_str);
|
2013-11-18 04:06:27 +00:00
|
|
|
return FAILURE;
|
2003-06-19 22:12:21 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0);
|
2017-11-16 14:09:32 +00:00
|
|
|
zend_tmp_string_release(tmp_str);
|
2015-02-10 21:02:45 +00:00
|
|
|
return ret;
|
2002-07-31 22:10:58 +00:00
|
|
|
}
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2006-01-24 20:11:14 +00:00
|
|
|
case CURLINFO_HEADER_OUT:
|
2016-12-13 21:52:16 +00:00
|
|
|
if (zend_is_true(zvalue)) {
|
2006-01-24 20:11:14 +00:00
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, curl_debug);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *)ch);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 1);
|
|
|
|
} else {
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, NULL);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, NULL);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
|
|
|
|
}
|
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
|
|
|
case CURLOPT_SHARE:
|
|
|
|
{
|
2020-06-17 14:05:55 +00:00
|
|
|
if (Z_TYPE_P(zvalue) == IS_OBJECT && Z_OBJCE_P(zvalue) == curl_share_ce) {
|
|
|
|
php_curlsh *sh = Z_CURL_SHARE_P(zvalue);
|
2011-12-01 21:48:07 +00:00
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
|
|
|
|
}
|
|
|
|
}
|
2015-01-08 08:09:02 +00:00
|
|
|
break;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2011-12-04 00:19:12 +00:00
|
|
|
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));
|
2014-05-09 04:17:09 +00:00
|
|
|
} else if (!Z_ISUNDEF(ch->handlers->fnmatch->func_name)) {
|
2011-12-04 00:19:12 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
|
|
|
|
ch->handlers->fnmatch->fci_cache = empty_fcall_info_cache;
|
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_COPY(&ch->handlers->fnmatch->func_name, zvalue);
|
2011-12-04 00:19:12 +00:00
|
|
|
ch->handlers->fnmatch->method = PHP_CURL_USER;
|
|
|
|
break;
|
|
|
|
|
2000-09-30 03:09:54 +00:00
|
|
|
}
|
2002-04-03 23:59:36 +00:00
|
|
|
|
|
|
|
SAVE_CURL_ERROR(ch, error);
|
2001-04-30 14:36:19 +00:00
|
|
|
if (error != CURLE_OK) {
|
2013-11-18 04:06:27 +00:00
|
|
|
return FAILURE;
|
2000-09-30 03:09:54 +00:00
|
|
|
} else {
|
2013-11-18 04:06:27 +00:00
|
|
|
return SUCCESS;
|
2006-01-24 20:11:14 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-04 08:56:07 +00:00
|
|
|
/* }}} */
|
2006-01-24 20:11:14 +00:00
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Set an option for a cURL transfer */
|
2006-01-24 20:11:14 +00:00
|
|
|
PHP_FUNCTION(curl_setopt)
|
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
zval *zid, *zvalue;
|
2014-08-25 17:24:55 +00:00
|
|
|
zend_long options;
|
2009-05-18 12:51:05 +00:00
|
|
|
php_curl *ch;
|
2006-01-24 20:11:14 +00:00
|
|
|
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(3, 3)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-25 00:00:02 +00:00
|
|
|
Z_PARAM_LONG(options)
|
|
|
|
Z_PARAM_ZVAL(zvalue)
|
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2006-01-24 20:11:14 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2006-01-24 20:11:14 +00:00
|
|
|
|
2013-01-29 06:22:59 +00:00
|
|
|
if (options <= 0 && options != CURLOPT_SAFE_UPLOAD) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Invalid curl configuration option");
|
2010-03-02 12:54:23 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
if (_php_curl_setopt(ch, options, zvalue) == SUCCESS) {
|
2000-09-30 03:09:54 +00:00
|
|
|
RETURN_TRUE;
|
2006-01-24 20:11:14 +00:00
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
2000-09-30 03:09:54 +00:00
|
|
|
}
|
2000-07-16 19:37:33 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Set an array of option for a cURL transfer */
|
2006-01-24 20:11:14 +00:00
|
|
|
PHP_FUNCTION(curl_setopt_array)
|
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
zval *zid, *arr, *entry;
|
2006-01-24 20:11:14 +00:00
|
|
|
php_curl *ch;
|
2014-08-25 17:24:55 +00:00
|
|
|
zend_ulong option;
|
2014-05-09 04:17:09 +00:00
|
|
|
zend_string *string_key;
|
2006-01-24 20:11:14 +00:00
|
|
|
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(2, 2)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-25 00:00:02 +00:00
|
|
|
Z_PARAM_ARRAY(arr)
|
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2006-01-24 20:11:14 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2006-01-24 20:11:14 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(arr), option, string_key, entry) {
|
|
|
|
if (string_key) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING,
|
2014-05-09 04:17:09 +00:00
|
|
|
"Array keys must be CURLOPT constants or equivalent integer values");
|
2006-01-24 20:11:14 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2017-06-19 15:08:50 +00:00
|
|
|
ZVAL_DEREF(entry);
|
2014-12-13 22:06:14 +00:00
|
|
|
if (_php_curl_setopt(ch, (zend_long) option, entry) == FAILURE) {
|
2006-01-24 20:11:14 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2014-05-09 04:17:09 +00:00
|
|
|
} ZEND_HASH_FOREACH_END();
|
|
|
|
|
2006-01-24 20:11:14 +00:00
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2009-05-03 15:16:10 +00:00
|
|
|
/* {{{ _php_curl_cleanup_handle(ch)
|
2002-11-08 17:58:43 +00:00
|
|
|
Cleanup an execution phase */
|
2003-03-17 15:06:11 +00:00
|
|
|
void _php_curl_cleanup_handle(php_curl *ch)
|
2002-11-08 17:58:43 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
smart_str_free(&ch->handlers->write->buf);
|
2014-05-09 06:14:09 +00:00
|
|
|
if (ch->header.str) {
|
2018-05-28 13:27:12 +00:00
|
|
|
zend_string_release_ex(ch->header.str, 0);
|
2014-05-09 06:14:09 +00:00
|
|
|
ch->header.str = NULL;
|
2006-01-24 20:11:14 +00:00
|
|
|
}
|
2002-11-08 17:58:43 +00:00
|
|
|
|
|
|
|
memset(ch->err.str, 0, CURL_ERROR_SIZE + 1);
|
|
|
|
ch->err.no = 0;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Perform a cURL session */
|
2000-08-27 22:53:33 +00:00
|
|
|
PHP_FUNCTION(curl_exec)
|
2000-07-16 19:37:33 +00:00
|
|
|
{
|
2009-05-18 12:51:05 +00:00
|
|
|
CURLcode error;
|
|
|
|
zval *zid;
|
|
|
|
php_curl *ch;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(1, 1)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2003-03-17 15:06:11 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2000-08-27 22:53:33 +00:00
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
_php_curl_verify_handlers(ch, 1);
|
2011-09-12 09:16:04 +00:00
|
|
|
|
2002-11-13 22:25:33 +00:00
|
|
|
_php_curl_cleanup_handle(ch);
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2001-04-30 14:36:19 +00:00
|
|
|
error = curl_easy_perform(ch->cp);
|
2002-04-03 23:59:36 +00:00
|
|
|
SAVE_CURL_ERROR(ch, error);
|
2019-03-06 23:06:00 +00:00
|
|
|
|
|
|
|
if (error != CURLE_OK) {
|
2014-05-09 04:17:09 +00:00
|
|
|
smart_str_free(&ch->handlers->write->buf);
|
2001-04-30 14:36:19 +00:00
|
|
|
RETURN_FALSE;
|
2000-08-17 02:14:41 +00:00
|
|
|
}
|
2000-09-30 03:09:54 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->std_err)) {
|
2011-09-12 09:16:04 +00:00
|
|
|
php_stream *stream;
|
2015-02-02 06:45:19 +00:00
|
|
|
stream = (php_stream*)zend_fetch_resource2_ex(&ch->handlers->std_err, NULL, php_file_le_stream(), php_file_le_pstream());
|
2011-09-12 09:16:04 +00:00
|
|
|
if (stream) {
|
|
|
|
php_stream_flush(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.s) {
|
2006-04-13 11:26:10 +00:00
|
|
|
smart_str_0(&ch->handlers->write->buf);
|
2015-03-12 13:53:51 +00:00
|
|
|
RETURN_STR_COPY(ch->handlers->write->buf.s);
|
2000-08-27 22:53:33 +00:00
|
|
|
}
|
2009-06-15 12:37:37 +00:00
|
|
|
|
2009-06-28 09:50:14 +00:00
|
|
|
/* 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_header->method == PHP_CURL_FILE && ch->handlers->write_header->fp) {
|
|
|
|
fflush(ch->handlers->write_header->fp);
|
|
|
|
}
|
|
|
|
|
2006-10-10 23:12:59 +00:00
|
|
|
if (ch->handlers->write->method == PHP_CURL_RETURN) {
|
|
|
|
RETURN_EMPTY_STRING();
|
|
|
|
} else {
|
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
2000-07-16 19:37:33 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Get information regarding a specific transfer */
|
2000-10-20 04:57:14 +00:00
|
|
|
PHP_FUNCTION(curl_getinfo)
|
|
|
|
{
|
2009-05-18 12:51:05 +00:00
|
|
|
zval *zid;
|
|
|
|
php_curl *ch;
|
2020-06-18 07:26:09 +00:00
|
|
|
zend_long option;
|
|
|
|
zend_bool option_is_null = 1;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(1, 2)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-25 00:00:02 +00:00
|
|
|
Z_PARAM_OPTIONAL
|
2020-06-18 07:26:09 +00:00
|
|
|
Z_PARAM_LONG_OR_NULL(option, option_is_null)
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2003-03-17 15:06:11 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2000-10-20 04:57:14 +00:00
|
|
|
|
2020-06-18 07:26:09 +00:00
|
|
|
if (option_is_null) {
|
2014-05-09 04:17:09 +00:00
|
|
|
char *s_code;
|
2015-07-13 22:12:35 +00:00
|
|
|
/* libcurl expects long datatype. So far no cases are known where
|
|
|
|
it would be an issue. Using zend_long would truncate a 64-bit
|
|
|
|
var on Win64, so the exact long datatype fits everywhere, as
|
|
|
|
long as there's no 32-bit int overflow. */
|
2015-07-13 19:46:51 +00:00
|
|
|
long l_code;
|
2014-05-09 04:17:09 +00:00
|
|
|
double d_code;
|
2009-09-15 15:47:06 +00:00
|
|
|
struct curl_certinfo *ci = NULL;
|
2014-05-09 04:17:09 +00:00
|
|
|
zval listcode;
|
2018-12-09 16:05:02 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073d00 /* 7.61.0 */
|
2018-10-03 23:43:59 +00:00
|
|
|
curl_off_t co;
|
|
|
|
#endif
|
2000-10-20 04:57:14 +00:00
|
|
|
|
|
|
|
array_init(return_value);
|
|
|
|
|
2003-02-28 07:34:45 +00:00
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_URL, &s_code) == CURLE_OK) {
|
|
|
|
CAAS("url", s_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_TYPE, &s_code) == CURLE_OK) {
|
|
|
|
if (s_code != NULL) {
|
|
|
|
CAAS("content_type", s_code);
|
2008-12-04 13:13:22 +00:00
|
|
|
} else {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval retnull;
|
|
|
|
ZVAL_NULL(&retnull);
|
|
|
|
CAAZ("content_type", &retnull);
|
2003-02-28 07:34:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_HTTP_CODE, &l_code) == CURLE_OK) {
|
|
|
|
CAAL("http_code", l_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_HEADER_SIZE, &l_code) == CURLE_OK) {
|
|
|
|
CAAL("header_size", l_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_REQUEST_SIZE, &l_code) == CURLE_OK) {
|
|
|
|
CAAL("request_size", l_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_FILETIME, &l_code) == CURLE_OK) {
|
|
|
|
CAAL("filetime", l_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_SSL_VERIFYRESULT, &l_code) == CURLE_OK) {
|
|
|
|
CAAL("ssl_verify_result", l_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_COUNT, &l_code) == CURLE_OK) {
|
|
|
|
CAAL("redirect_count", l_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("total_time", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("namelookup_time", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("connect_time", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("pretransfer_time", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_UPLOAD, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("size_upload", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("size_download", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("speed_download", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_UPLOAD, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("speed_upload", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("download_content_length", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("upload_content_length", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("starttransfer_time", d_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) {
|
|
|
|
CAAD("redirect_time", d_code);
|
|
|
|
}
|
2011-12-03 20:16:32 +00:00
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) {
|
|
|
|
CAAS("redirect_url", s_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) {
|
|
|
|
CAAS("primary_ip", s_code);
|
|
|
|
}
|
2009-09-15 15:47:06 +00:00
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
|
2014-05-09 04:17:09 +00:00
|
|
|
array_init(&listcode);
|
2014-12-13 22:06:14 +00:00
|
|
|
create_certinfo(ci, &listcode);
|
2014-05-09 04:17:09 +00:00
|
|
|
CAAZ("certinfo", &listcode);
|
2009-09-15 15:47:06 +00:00
|
|
|
}
|
2010-12-10 01:45:55 +00:00
|
|
|
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);
|
|
|
|
}
|
2018-10-03 23:43:59 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073200 /* Available since 7.50.0 */
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_HTTP_VERSION, &l_code) == CURLE_OK) {
|
|
|
|
CAAL("http_version", l_code);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073400 /* Available since 7.52.0 */
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_PROTOCOL, &l_code) == CURLE_OK) {
|
|
|
|
CAAL("protocol", l_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_PROXY_SSL_VERIFYRESULT, &l_code) == CURLE_OK) {
|
|
|
|
CAAL("ssl_verifyresult", l_code);
|
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_SCHEME, &s_code) == CURLE_OK) {
|
|
|
|
CAAS("scheme", s_code);
|
|
|
|
}
|
|
|
|
#endif
|
2018-10-08 14:15:20 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073d00 /* Available since 7.61.0 */
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_APPCONNECT_TIME_T, &co) == CURLE_OK) {
|
2018-12-08 20:09:43 +00:00
|
|
|
CAAL("appconnect_time_us", co);
|
2018-10-08 14:15:20 +00:00
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME_T, &co) == CURLE_OK) {
|
2018-12-08 20:09:43 +00:00
|
|
|
CAAL("connect_time_us", co);
|
2018-10-08 14:15:20 +00:00
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME_T, &co) == CURLE_OK) {
|
2018-12-08 20:09:43 +00:00
|
|
|
CAAL("namelookup_time_us", co);
|
2018-10-08 14:15:20 +00:00
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME_T, &co) == CURLE_OK) {
|
2018-12-08 20:09:43 +00:00
|
|
|
CAAL("pretransfer_time_us", co);
|
2018-10-08 14:15:20 +00:00
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME_T, &co) == CURLE_OK) {
|
2018-12-08 20:09:43 +00:00
|
|
|
CAAL("redirect_time_us", co);
|
2018-10-08 14:15:20 +00:00
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME_T, &co) == CURLE_OK) {
|
2018-12-08 20:09:43 +00:00
|
|
|
CAAL("starttransfer_time_us", co);
|
2018-10-08 14:15:20 +00:00
|
|
|
}
|
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME_T, &co) == CURLE_OK) {
|
2018-12-08 20:09:43 +00:00
|
|
|
CAAL("total_time_us", co);
|
2018-10-08 14:15:20 +00:00
|
|
|
}
|
2009-09-15 15:47:06 +00:00
|
|
|
#endif
|
2014-05-09 06:14:09 +00:00
|
|
|
if (ch->header.str) {
|
2016-02-08 11:36:14 +00:00
|
|
|
CAASTR("request_header", ch->header.str);
|
2006-01-24 20:11:14 +00:00
|
|
|
}
|
2000-10-20 04:57:14 +00:00
|
|
|
} else {
|
2001-04-30 14:36:19 +00:00
|
|
|
switch (option) {
|
2006-01-24 20:11:14 +00:00
|
|
|
case CURLINFO_HEADER_OUT:
|
2014-05-09 06:14:09 +00:00
|
|
|
if (ch->header.str) {
|
2015-03-12 13:53:51 +00:00
|
|
|
RETURN_STR_COPY(ch->header.str);
|
2006-01-24 20:11:14 +00:00
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2009-09-15 15:47:06 +00:00
|
|
|
case CURLINFO_CERTINFO: {
|
|
|
|
struct curl_certinfo *ci = NULL;
|
|
|
|
|
|
|
|
array_init(return_value);
|
2013-01-29 06:22:59 +00:00
|
|
|
|
2009-09-15 15:47:06 +00:00
|
|
|
if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
|
2014-12-13 22:06:14 +00:00
|
|
|
create_certinfo(ci, return_value);
|
2009-09-15 15:47:06 +00:00
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-12-03 20:16:32 +00:00
|
|
|
default: {
|
|
|
|
int type = CURLINFO_TYPEMASK & option;
|
|
|
|
switch (type) {
|
|
|
|
case CURLINFO_STRING:
|
|
|
|
{
|
|
|
|
char *s_code = NULL;
|
2013-01-29 06:22:59 +00:00
|
|
|
|
2011-12-03 20:16:32 +00:00
|
|
|
if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) {
|
2014-05-09 04:17:09 +00:00
|
|
|
RETURN_STRING(s_code);
|
2011-12-03 20:16:32 +00:00
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CURLINFO_LONG:
|
|
|
|
{
|
2014-08-25 17:24:55 +00:00
|
|
|
zend_long code = 0;
|
2013-01-29 06:22:59 +00:00
|
|
|
|
2011-12-03 20:16:32 +00:00
|
|
|
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
|
2014-08-25 17:24:55 +00:00
|
|
|
RETURN_LONG(code);
|
2011-12-03 20:16:32 +00:00
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CURLINFO_DOUBLE:
|
|
|
|
{
|
|
|
|
double code = 0.0;
|
|
|
|
|
|
|
|
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
|
|
|
|
RETURN_DOUBLE(code);
|
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CURLINFO_SLIST:
|
|
|
|
{
|
|
|
|
struct curl_slist *slist;
|
|
|
|
if (curl_easy_getinfo(ch->cp, option, &slist) == CURLE_OK) {
|
2019-06-25 11:17:39 +00:00
|
|
|
struct curl_slist *current = slist;
|
|
|
|
array_init(return_value);
|
|
|
|
while (current) {
|
|
|
|
add_next_index_string(return_value, current->data);
|
|
|
|
current = current->next;
|
2011-12-03 20:16:32 +00:00
|
|
|
}
|
2011-12-05 22:23:19 +00:00
|
|
|
curl_slist_free_all(slist);
|
2011-12-03 20:16:32 +00:00
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2018-10-03 23:43:59 +00:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x073700 /* Available since 7.55.0 */
|
|
|
|
case CURLINFO_OFF_T:
|
|
|
|
{
|
|
|
|
curl_off_t c_off;
|
|
|
|
if (curl_easy_getinfo(ch->cp, option, &c_off) == CURLE_OK) {
|
|
|
|
RETURN_LONG((long) c_off);
|
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2011-12-03 20:16:32 +00:00
|
|
|
default:
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2000-10-20 04:57:14 +00:00
|
|
|
}
|
2003-03-17 15:06:11 +00:00
|
|
|
}
|
2000-10-20 04:57:14 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Return a string contain the last error for the current session */
|
2000-09-30 03:09:54 +00:00
|
|
|
PHP_FUNCTION(curl_error)
|
2000-07-16 19:37:33 +00:00
|
|
|
{
|
2009-05-18 12:51:05 +00:00
|
|
|
zval *zid;
|
|
|
|
php_curl *ch;
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(1, 1)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2003-03-17 15:06:11 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2001-03-03 01:06:55 +00:00
|
|
|
|
2019-03-01 06:37:00 +00:00
|
|
|
if (ch->err.no) {
|
|
|
|
ch->err.str[CURL_ERROR_SIZE] = 0;
|
|
|
|
RETURN_STRING(ch->err.str);
|
|
|
|
} else {
|
|
|
|
RETURN_EMPTY_STRING();
|
|
|
|
}
|
2000-07-16 19:37:33 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Return an integer containing the last error number */
|
2000-09-30 03:09:54 +00:00
|
|
|
PHP_FUNCTION(curl_errno)
|
|
|
|
{
|
2009-05-18 12:51:05 +00:00
|
|
|
zval *zid;
|
|
|
|
php_curl *ch;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2016-12-28 16:38:01 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(1,1)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-28 16:38:01 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2003-03-17 15:06:11 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2014-08-25 17:24:55 +00:00
|
|
|
RETURN_LONG(ch->err.no);
|
2000-09-30 03:09:54 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
2000-08-13 19:32:09 +00:00
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Close a cURL session */
|
2000-10-20 04:57:14 +00:00
|
|
|
PHP_FUNCTION(curl_close)
|
2000-08-13 19:32:09 +00:00
|
|
|
{
|
2009-05-18 12:51:05 +00:00
|
|
|
zval *zid;
|
|
|
|
php_curl *ch;
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(1, 1)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2003-03-17 15:06:11 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2005-06-02 21:04:12 +00:00
|
|
|
|
|
|
|
if (ch->in_callback) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Attempt to close cURL handle from a callback");
|
2005-06-02 21:04:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-08-13 19:32:09 +00:00
|
|
|
}
|
2000-09-30 03:09:54 +00:00
|
|
|
/* }}} */
|
2000-08-13 19:32:09 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
static void curl_free_obj(zend_object *object)
|
2000-08-15 16:50:14 +00:00
|
|
|
{
|
2020-06-17 14:05:55 +00:00
|
|
|
php_curl *ch = curl_from_obj(object);
|
|
|
|
|
2002-11-13 22:25:33 +00:00
|
|
|
#if PHP_CURL_DEBUG
|
|
|
|
fprintf(stderr, "DTOR CALLED, ch = %x\n", ch);
|
|
|
|
#endif
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
_php_curl_verify_handlers(ch, 0);
|
2012-12-23 00:03:24 +00:00
|
|
|
|
2013-01-29 06:22:59 +00:00
|
|
|
/*
|
2012-12-23 00:03:24 +00:00
|
|
|
* Libcurl is doing connection caching. When easy handle is cleaned up,
|
2013-01-29 06:22:59 +00:00
|
|
|
* if the handle was previously used by the curl_multi_api, the connection
|
2012-12-23 00:03:24 +00:00
|
|
|
* remains open un the curl multi handle is cleaned up. Some protocols are
|
2013-01-29 06:22:59 +00:00
|
|
|
* sending content like the FTP one, and libcurl try to use the
|
2012-12-23 00:03:24 +00:00
|
|
|
* WRITEFUNCTION or the HEADERFUNCTION. Since structures used in those
|
|
|
|
* callback are freed, we need to use an other callback to which avoid
|
|
|
|
* segfaults.
|
|
|
|
*
|
2013-01-29 06:22:59 +00:00
|
|
|
* Libcurl commit d021f2e8a00 fix this issue and should be part of 7.28.2
|
2012-12-23 00:03:24 +00:00
|
|
|
*/
|
2015-10-02 07:31:10 +00:00
|
|
|
if (ch->cp != NULL) {
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_nothing);
|
|
|
|
curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write_nothing);
|
2012-12-23 00:03:24 +00:00
|
|
|
|
2015-10-02 07:31:10 +00:00
|
|
|
curl_easy_cleanup(ch->cp);
|
|
|
|
}
|
2009-07-21 20:32:32 +00:00
|
|
|
|
|
|
|
/* cURL destructors should be invoked only by last curl handle */
|
2015-08-23 05:01:47 +00:00
|
|
|
if (--(*ch->clone) == 0) {
|
2011-11-22 05:19:37 +00:00
|
|
|
zend_llist_clean(&ch->to_free->str);
|
|
|
|
zend_llist_clean(&ch->to_free->post);
|
2019-04-29 08:21:07 +00:00
|
|
|
zend_llist_clean(&ch->to_free->stream);
|
2013-08-19 18:58:57 +00:00
|
|
|
zend_hash_destroy(ch->to_free->slist);
|
|
|
|
efree(ch->to_free->slist);
|
2011-11-22 05:19:37 +00:00
|
|
|
efree(ch->to_free);
|
2015-08-23 05:01:47 +00:00
|
|
|
efree(ch->clone);
|
2009-07-21 20:32:32 +00:00
|
|
|
}
|
2001-04-30 14:36:19 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
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);
|
2014-05-09 06:14:09 +00:00
|
|
|
if (ch->header.str) {
|
2018-05-28 13:27:12 +00:00
|
|
|
zend_string_release_ex(ch->header.str, 0);
|
2006-01-24 20:11:14 +00:00
|
|
|
}
|
2009-05-03 15:16:10 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->write_header->stream);
|
|
|
|
zval_ptr_dtor(&ch->handlers->write->stream);
|
|
|
|
zval_ptr_dtor(&ch->handlers->read->stream);
|
2009-09-30 02:34:17 +00:00
|
|
|
|
2001-05-04 04:20:38 +00:00
|
|
|
efree(ch->handlers->write);
|
2001-06-25 15:14:20 +00:00
|
|
|
efree(ch->handlers->write_header);
|
2001-05-04 04:20:38 +00:00
|
|
|
efree(ch->handlers->read);
|
2011-12-03 23:43:44 +00:00
|
|
|
|
|
|
|
if (ch->handlers->progress) {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->progress->func_name);
|
2011-12-03 23:43:44 +00:00
|
|
|
efree(ch->handlers->progress);
|
|
|
|
}
|
|
|
|
|
2011-12-04 00:19:12 +00:00
|
|
|
if (ch->handlers->fnmatch) {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
|
2011-12-04 00:19:12 +00:00
|
|
|
efree(ch->handlers->fnmatch);
|
|
|
|
}
|
|
|
|
|
2001-04-30 14:36:19 +00:00
|
|
|
efree(ch->handlers);
|
Fix #79019: Copied cURL handles upload empty file
To cater to `curl_copy_handle()` of cURL handles with attached
`CURLFile`s, we must not attach the opened stream, because the stream
may not be seekable, so that we could rewind, when the same stream is
going to be uploaded multiple times. Instead, we're opening the stream
lazily in the read callback.
Since `curl_multi_perfom()` processes easy handles asynchronously, we
have no control of the operation sequence. Since duplicated cURL
handles may be used with multi handles, we cannot use a single arg
structure, but actually have to rebuild the whole mime structure on
handle duplication and attach this to the new handle.
In order to better test this behavior, we extend the test responder to
print the size of the upload, and patch the existing tests accordingly.
2020-02-04 10:01:33 +00:00
|
|
|
zval_ptr_dtor(&ch->postfields);
|
2000-08-15 16:50:14 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
zend_object_std_dtor(&ch->std);
|
2009-05-18 10:31:08 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ return string describing error code */
|
2012-12-23 20:45:39 +00:00
|
|
|
PHP_FUNCTION(curl_strerror)
|
|
|
|
{
|
2014-08-25 17:24:55 +00:00
|
|
|
zend_long code;
|
2012-12-23 20:45:39 +00:00
|
|
|
const char *str;
|
|
|
|
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(1, 1)
|
|
|
|
Z_PARAM_LONG(code)
|
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2012-12-23 20:45:39 +00:00
|
|
|
|
|
|
|
str = curl_easy_strerror(code);
|
|
|
|
if (str) {
|
2014-05-09 04:17:09 +00:00
|
|
|
RETURN_STRING(str);
|
2012-12-23 20:45:39 +00:00
|
|
|
} else {
|
|
|
|
RETURN_NULL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
/* {{{ _php_curl_reset_handlers()
|
|
|
|
Reset all handlers of a given php_curl */
|
2012-08-27 11:56:54 +00:00
|
|
|
static void _php_curl_reset_handlers(php_curl *ch)
|
2011-12-01 21:48:07 +00:00
|
|
|
{
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->write->stream)) {
|
|
|
|
zval_ptr_dtor(&ch->handlers->write->stream);
|
|
|
|
ZVAL_UNDEF(&ch->handlers->write->stream);
|
2011-12-01 21:48:07 +00:00
|
|
|
}
|
|
|
|
ch->handlers->write->fp = NULL;
|
|
|
|
ch->handlers->write->method = PHP_CURL_STDOUT;
|
2013-01-29 06:22:59 +00:00
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->write_header->stream)) {
|
|
|
|
zval_ptr_dtor(&ch->handlers->write_header->stream);
|
|
|
|
ZVAL_UNDEF(&ch->handlers->write_header->stream);
|
2011-12-01 21:48:07 +00:00
|
|
|
}
|
|
|
|
ch->handlers->write_header->fp = NULL;
|
|
|
|
ch->handlers->write_header->method = PHP_CURL_IGNORE;
|
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->read->stream)) {
|
|
|
|
zval_ptr_dtor(&ch->handlers->read->stream);
|
|
|
|
ZVAL_UNDEF(&ch->handlers->read->stream);
|
2011-12-01 21:48:07 +00:00
|
|
|
}
|
|
|
|
ch->handlers->read->fp = NULL;
|
2014-05-09 04:17:09 +00:00
|
|
|
ch->handlers->read->res = NULL;
|
2011-12-01 21:48:07 +00:00
|
|
|
ch->handlers->read->method = PHP_CURL_DIRECT;
|
|
|
|
|
2014-05-09 04:17:09 +00:00
|
|
|
if (!Z_ISUNDEF(ch->handlers->std_err)) {
|
2011-12-01 21:48:07 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->std_err);
|
2014-05-09 04:17:09 +00:00
|
|
|
ZVAL_UNDEF(&ch->handlers->std_err);
|
2011-12-01 21:48:07 +00:00
|
|
|
}
|
|
|
|
|
2011-12-03 23:43:44 +00:00
|
|
|
if (ch->handlers->progress) {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->progress->func_name);
|
2011-12-03 23:43:44 +00:00
|
|
|
efree(ch->handlers->progress);
|
|
|
|
ch->handlers->progress = NULL;
|
2011-12-01 21:48:07 +00:00
|
|
|
}
|
2011-12-04 00:19:12 +00:00
|
|
|
|
|
|
|
if (ch->handlers->fnmatch) {
|
2014-05-09 04:17:09 +00:00
|
|
|
zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
|
2011-12-04 00:19:12 +00:00
|
|
|
efree(ch->handlers->fnmatch);
|
|
|
|
ch->handlers->fnmatch = NULL;
|
|
|
|
}
|
|
|
|
|
2011-12-01 21:48:07 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ Reset all options of a libcurl session handle */
|
2011-12-01 21:48:07 +00:00
|
|
|
PHP_FUNCTION(curl_reset)
|
|
|
|
{
|
|
|
|
zval *zid;
|
|
|
|
php_curl *ch;
|
|
|
|
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(1, 1)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-25 00:00:02 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
|
|
|
if (ch->in_callback) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_error_docref(NULL, E_WARNING, "Attempt to reset cURL handle from a callback");
|
2011-12-01 21:48:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
curl_easy_reset(ch->cp);
|
|
|
|
_php_curl_reset_handlers(ch);
|
|
|
|
_php_curl_set_default_options(ch);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ URL encodes the given string */
|
2011-12-01 21:48:07 +00:00
|
|
|
PHP_FUNCTION(curl_escape)
|
|
|
|
{
|
2016-12-28 16:38:01 +00:00
|
|
|
zend_string *str;
|
|
|
|
char *res;
|
|
|
|
zval *zid;
|
|
|
|
php_curl *ch;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2016-12-28 16:38:01 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(2,2)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-28 16:38:01 +00:00
|
|
|
Z_PARAM_STR(str)
|
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2016-12-28 16:38:01 +00:00
|
|
|
if (ZEND_SIZE_T_INT_OVFL(ZSTR_LEN(str))) {
|
2016-08-03 07:58:55 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-12-28 16:38:01 +00:00
|
|
|
if ((res = curl_easy_escape(ch->cp, ZSTR_VAL(str), ZSTR_LEN(str)))) {
|
2014-05-09 04:17:09 +00:00
|
|
|
RETVAL_STRING(res);
|
2013-02-17 19:29:20 +00:00
|
|
|
curl_free(res);
|
2011-12-01 21:48:07 +00:00
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ URL decodes the given string */
|
2013-01-29 06:22:59 +00:00
|
|
|
PHP_FUNCTION(curl_unescape)
|
2011-12-01 21:48:07 +00:00
|
|
|
{
|
2016-12-28 16:38:01 +00:00
|
|
|
char *out = NULL;
|
|
|
|
int out_len;
|
|
|
|
zval *zid;
|
|
|
|
zend_string *str;
|
|
|
|
php_curl *ch;
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2016-12-28 16:38:01 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(2,2)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-28 16:38:01 +00:00
|
|
|
Z_PARAM_STR(str)
|
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2011-12-01 21:48:07 +00:00
|
|
|
|
2016-12-28 16:38:01 +00:00
|
|
|
if (ZEND_SIZE_T_INT_OVFL(ZSTR_LEN(str))) {
|
2016-07-13 05:59:19 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-12-28 16:38:01 +00:00
|
|
|
if ((out = curl_easy_unescape(ch->cp, ZSTR_VAL(str), ZSTR_LEN(str), &out_len))) {
|
2014-05-09 04:17:09 +00:00
|
|
|
RETVAL_STRINGL(out, out_len);
|
2013-02-17 19:29:20 +00:00
|
|
|
curl_free(out);
|
2011-12-01 21:48:07 +00:00
|
|
|
} else {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2012-12-23 22:13:49 +00:00
|
|
|
/* }}} */
|
|
|
|
|
2020-07-01 13:32:55 +00:00
|
|
|
/* {{{ pause and unpause a connection */
|
2012-12-23 22:13:49 +00:00
|
|
|
PHP_FUNCTION(curl_pause)
|
|
|
|
{
|
2014-08-25 17:24:55 +00:00
|
|
|
zend_long bitmask;
|
2012-12-23 22:13:49 +00:00
|
|
|
zval *zid;
|
|
|
|
php_curl *ch;
|
|
|
|
|
2016-12-28 16:38:01 +00:00
|
|
|
ZEND_PARSE_PARAMETERS_START(2,2)
|
2020-06-17 14:05:55 +00:00
|
|
|
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
|
2016-12-28 16:38:01 +00:00
|
|
|
Z_PARAM_LONG(bitmask)
|
|
|
|
ZEND_PARSE_PARAMETERS_END();
|
2012-12-23 22:13:49 +00:00
|
|
|
|
2020-06-17 14:05:55 +00:00
|
|
|
ch = Z_CURL_P(zid);
|
2012-12-23 22:13:49 +00:00
|
|
|
|
2014-08-25 17:24:55 +00:00
|
|
|
RETURN_LONG(curl_easy_pause(ch->cp, bitmask));
|
2012-12-23 22:13:49 +00:00
|
|
|
}
|
2011-12-01 21:48:07 +00:00
|
|
|
/* }}} */
|
2012-12-23 22:13:49 +00:00
|
|
|
|
2005-10-25 14:32:33 +00:00
|
|
|
#endif /* HAVE_CURL */
|