X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_client_curl.c;h=b688497380aa49e02470be989ec920c2f47ee21f;hp=15d26192cedfdc27dbeff17d8ec7ab23a3e5c7d2;hb=9aaa57412ed0cf724e9dd81f365b02f1d56ad623;hpb=007ef072341b5d6fed93d7f0a4c64369a2536fa5 diff --git a/php_http_client_curl.c b/php_http_client_curl.c index 15d2619..b688497 100644 --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@ -98,6 +98,7 @@ typedef struct php_http_client_curl_handler { typedef struct php_http_curle_storage { char *url; char *cookiestore; + CURLcode errorcode; char errorbuffer[0x100]; } php_http_curle_storage_t; @@ -487,7 +488,6 @@ static STATUS php_http_curle_get_info(CURL *ch, HashTable *info) #if PHP_HTTP_CURL_VERSION(7,34,0) { - int i; zval *ti_array; struct curl_tlssessioninfo *ti; @@ -599,7 +599,12 @@ static STATUS php_http_curle_get_info(CURL *ch, HashTable *info) } } #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; } @@ -622,7 +627,7 @@ static void php_http_curlm_responsehandler(php_http_client_t *context) 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))) { @@ -1309,7 +1314,7 @@ static void php_http_curle_options_init(php_http_options_t *registry TSRMLS_DC) } 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; @@ -1317,7 +1322,7 @@ static void php_http_curle_options_init(php_http_options_t *registry TSRMLS_DC) } 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;