From: Michael Wallner Date: Wed, 14 Sep 2016 06:05:22 +0000 (+0200) Subject: new curlinfo X-Git-Tag: RELEASE_2_6_0_RC1~9 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=061a30e33e42ae9332a56c26cbe15bccc9d0f61f new curlinfo --- diff --git a/scripts/gen_curlinfo.php b/scripts/gen_curlinfo.php index 076a10d..de84b40 100755 --- a/scripts/gen_curlinfo.php +++ b/scripts/gen_curlinfo.php @@ -5,9 +5,7 @@ error_reporting(0); function failure() { - // this is why error_get_last() should return a stdClass object - $error = error_get_last(); - fprintf(STDERR, "FAILURE: %s\n", $error["message"]); + fprintf(STDERR, "FAILURE: %s\n", error_get_last()["message"]); exit(-1); } @@ -38,11 +36,21 @@ $ifdefs = array( 'PRIMARY_PORT' => 'PHP_HTTP_CURL_VERSION(7,21,0)', 'LOCAL_PORT' => 'PHP_HTTP_CURL_VERSION(7,21,0)', 'LOCAL_IP' => 'PHP_HTTP_CURL_VERSION(7,21,0)', + 'HTTP_VERSION' => 'PHP_HTTP_CURL_VERSION(7,50,0)' ); $exclude = array( - 'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH', 'CERTINFO', 'TLS_SESSION', - 'RTSP_SESSION_ID', 'RTSP_CLIENT_CSEQ', 'RTSP_SERVER_CSEQ', 'RTSP_CSEQ_RECV', - 'COOKIELIST' + 'ACTIVESOCKET', + 'CERTINFO', + 'COOKIELIST', + 'FTP_ENTRY_PATH', + 'LASTSOCKET', + 'PRIVATE', + 'RTSP_CLIENT_CSEQ', + 'RTSP_CSEQ_RECV', + 'RTSP_SERVER_CSEQ', + 'RTSP_SESSION_ID', + 'TLS_SESSION', + 'TLS_SSL_PTR', ); $translate = array( @@ -92,8 +100,8 @@ foreach ($infos as $info) { if (isset($ifdefs[$short])) printf("#endif\n"); } -file_put_contents("php_http_client_curl.c", +file_put_contents("src/php_http_client_curl.c", preg_replace('/(\/\* BEGIN::CURLINFO \*\/\n).*(\n\s*\/\* END::CURLINFO \*\/)/s', '$1'. ob_get_contents() .'$2', - file_get_contents("php_http_client_curl.c"))); + file_get_contents("src/php_http_client_curl.c"))); ?> diff --git a/src/php_http_client_curl.c b/src/php_http_client_curl.c index b15fdd4..b7c6b05 100644 --- a/src/php_http_client_curl.c +++ b/src/php_http_client_curl.c @@ -450,6 +450,11 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) add_assoc_long_ex(&array, "local_port", sizeof("local_port"), l); } #endif +#if PHP_HTTP_CURL_VERSION(7,50,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_HTTP_VERSION, &l)) { + add_assoc_long_ex(&array, "http_version", sizeof("http_version"), l); + } +#endif /* END::CURLINFO */