typedef struct php_http_curle_storage {
char *url;
char *cookiestore;
+ CURLcode errorcode;
char errorbuffer[0x100];
} php_http_curle_storage_t;
#if PHP_HTTP_CURL_VERSION(7,34,0)
{
- int i;
zval *ti_array;
struct curl_tlssessioninfo *ti;
}
}
#endif
- add_assoc_string_ex(&array, "error", sizeof("error"), php_http_curle_get_storage(ch)->errorbuffer, 1);
+ {
+ php_http_curle_storage_t *st = php_http_curle_get_storage(ch);
+
+ add_assoc_long_ex(&array, "curlcode", sizeof("curlcode"), st->errorcode);
+ add_assoc_string_ex(&array, "error", sizeof("error"), st->errorbuffer, 1);
+ }
return SUCCESS;
}
if (msg && CURLMSG_DONE == msg->msg) {
if (CURLE_OK != msg->data.result) {
php_http_curle_storage_t *st = php_http_curle_get_storage(msg->easy_handle);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s; %s (%s)", curl_easy_strerror(msg->data.result), STR_PTR(st->errorbuffer), STR_PTR(st->url));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s; %s (%s)", curl_easy_strerror(st->errorcode = msg->data.result), STR_PTR(st->errorbuffer), STR_PTR(st->url));
}
if ((enqueue = php_http_client_enqueued(context, msg->easy_handle, compare_queue))) {
#define PHP_HTTP_CURLE_OPTION_CHECK_STRLEN 0x0001
#define PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR 0x0002
#define PHP_HTTP_CURLE_OPTION_TRANSFORM_MS 0x0004
-#define PHP_HTTP_CURLE_OPTION_TRANSFORM_NULLS 0x0006
static STATUS php_http_curle_option_set_ssl_verifyhost(php_http_option_t *opt, zval *val, void *userdata)
{
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
+ php_http_curle_storage_t *storage = php_http_curle_get_storage(curl->handle);
- if (val) {
- php_http_curle_storage_t *storage = php_http_curle_get_storage(curl->handle);
-
- if (storage->cookiestore) {
- pefree(storage->cookiestore, 1);
- }
+ if (storage->cookiestore) {
+ pefree(storage->cookiestore, 1);
+ }
+ if (val && Z_STRLEN_P(val)) {
storage->cookiestore = pestrndup(Z_STRVAL_P(val), Z_STRLEN_P(val), 1);
- if ( CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEFILE, storage->cookiestore)
- || CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEJAR, storage->cookiestore)
- ) {
- return FAILURE;
- }
+ } else {
+ storage->cookiestore = NULL;
+ }
+ if ( CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEFILE, storage->cookiestore)
+ || CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEJAR, storage->cookiestore)
+ ) {
+ return FAILURE;
}
return SUCCESS;
}
}
}
}
+ } else {
+ php_http_buffer_reset(&curl->options.cookies);
+ if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIE, NULL)) {
+ return FAILURE;
+ }
}
return SUCCESS;
}
}
if ((opt = php_http_option_register(registry, ZEND_STRL("certtype"), CURLOPT_SSLCERTTYPE, IS_STRING))) {
opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
- ZVAL_STRING(&opt->defval, "PEM", 1);
+ ZVAL_STRING(&opt->defval, "PEM", 0);
}
if ((opt = php_http_option_register(registry, ZEND_STRL("key"), CURLOPT_SSLKEY, IS_STRING))) {
opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
}
if ((opt = php_http_option_register(registry, ZEND_STRL("keytype"), CURLOPT_SSLKEYTYPE, IS_STRING))) {
opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
- ZVAL_STRING(&opt->defval, "PEM", 1);
+ ZVAL_STRING(&opt->defval, "PEM", 0);
}
if ((opt = php_http_option_register(registry, ZEND_STRL("keypasswd"), CURLOPT_SSLKEYPASSWD, IS_STRING))) {
opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN;
#if PHP_HTTP_HAVE_EVENT
if (curl->timeout) {
+ if (event_initialized(curl->timeout) && event_pending(curl->timeout, EV_TIMEOUT, NULL)) {
+ event_del(curl->timeout);
+ }
efree(curl->timeout);
curl->timeout = NULL;
}