new curlinfo
authorMichael Wallner <mike@php.net>
Wed, 14 Sep 2016 06:05:22 +0000 (08:05 +0200)
committerMichael Wallner <mike@php.net>
Wed, 14 Sep 2016 06:05:22 +0000 (08:05 +0200)
scripts/gen_curlinfo.php
src/php_http_client_curl.c

index 076a10d10f86bd34e1a354ea5a34b028bb9dc6ed..de84b40f3f5870422ba6819a55cc8d3c2c475abc 100755 (executable)
@@ -5,9 +5,7 @@
 error_reporting(0);
 
 function failure() {
 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);
 }
 
        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)',
     '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(
 );
 $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(
 );
 
 $translate = array(
@@ -92,8 +100,8 @@ foreach ($infos as $info) {
        if (isset($ifdefs[$short])) printf("#endif\n");
 }
 
        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',
        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")));
 
 ?>
 
 ?>
index b15fdd47f6c84475be23ff4026816eaf9503af5b..b7c6b05389012f74bc667b2d2a38f23feee855b9 100644 (file)
@@ -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
                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 */
 
 
        /* END::CURLINFO */