fence new altsvc and hsts features
[m6w6/ext-http] / src / php_http_client_curl.c
index 020cf28d6cf3b1ed1e8b0f19737744555b9bc899..915b8fc31f506ccf1aec46abd6a343bd5d7cd30d 100644 (file)
@@ -1683,18 +1683,30 @@ static void php_http_curle_options_init(php_http_options_t *registry)
        }
 
 #if PHP_HTTP_CURL_VERSION(7,64,1)
+# if !PHP_HTTP_HAVE_LIBCURL_ALT_SVC
+       if (PHP_HTTP_CURL_FEATURE(CURL_VERSION_ALTSVC)) {
+# endif
        if ((opt = php_http_option_register(registry, ZEND_STRL("altsvc_ctrl"), CURLOPT_ALTSVC_CTRL, IS_LONG))) {
                opt->setter = php_http_curle_option_set_altsvc_ctrl;
        }
        if ((opt = php_http_option_register(registry, ZEND_STRL("altsvc"), CURLOPT_ALTSVC, IS_STRING))) {
                opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
        }
+# if !PHP_HTTP_HAVE_LIBCURL_ALT_SVC
+       }
+# endif
 #endif
 #if PHP_HTTP_CURL_VERSION(7,74,0)
+# if !PHP_HTTP_HAVE_LIBCURL_HSTS
+       if (PHP_HTTP_CURL_FEATURE(CURL_VERSION_HSTS)) {
+# endif
        php_http_option_register(registry, ZEND_STRL("hsts_ctrl"), CURLOPT_HSTS_CTRL, IS_LONG);
        if ((opt = php_http_option_register(registry, ZEND_STRL("hsts"), CURLOPT_HSTS, IS_STRING))) {
                opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR;
        }
+# if !PHP_HTTP_HAVE_LIBCURL_HSTS
+       }
+# endif
 #endif
 }
 
@@ -2660,13 +2672,13 @@ php_http_client_ops_t *php_http_client_curl_get_ops(void)
        return &php_http_client_curl_ops;
 }
 
-#define REGISTER_NS_STRING_OR_NULL_CONSTANT(ns, name, str, flags)                              \
-               do {                                                                           \
-                       if ((str) != NULL) {                                                   \
-                               REGISTER_NS_STRING_CONSTANT(ns, name, str, flags);             \
-                       } else {                                                               \
-                               REGISTER_NS_NULL_CONSTANT(ns, name, flags);                    \
-                       }                                                                      \
+#define REGISTER_NS_STRING_OR_NULL_CONSTANT(ns, name, str, flags) \
+               do { \
+                       if ((str) != NULL) { \
+                               REGISTER_NS_STRING_CONSTANT(ns, name, str, flags); \
+                       } else { \
+                               REGISTER_NS_NULL_CONSTANT(ns, name, flags); \
+                       } \
                } while (0)
 
 PHP_MINIT_FUNCTION(http_client_curl)
@@ -2780,11 +2792,13 @@ PHP_MINIT_FUNCTION(http_client_curl)
                REGISTER_NS_STRING_OR_NULL_CONSTANT("http\\Client\\Curl\\Versions", "ARES", info->ares, CONST_CS|CONST_PERSISTENT);
                REGISTER_NS_STRING_OR_NULL_CONSTANT("http\\Client\\Curl\\Versions", "IDN", info->libidn, CONST_CS|CONST_PERSISTENT);
                tmp_ver_init();
-               tmp_ptr = zend_print_ulong_to_buf(tmp_end, info->iconv_ver_num & 0xf);
-               tmp_end = tmp_ptr - 1;
-               tmp_ptr = zend_print_ulong_to_buf(tmp_end, info->iconv_ver_num >> 8);
-               *tmp_end = '.';
-               REGISTER_NS_STRING_OR_NULL_CONSTANT("http\\Client\\Curl\\Versions", "ICONV", tmp_ptr, CONST_CS|CONST_PERSISTENT);
+               if (info->iconv_ver_num) {
+                       tmp_ptr = zend_print_ulong_to_buf(tmp_end, info->iconv_ver_num & 0xf);
+                       tmp_end = tmp_ptr - 1;
+                       tmp_ptr = zend_print_ulong_to_buf(tmp_end, info->iconv_ver_num >> 8);
+                       *tmp_end = '.';
+               }
+               REGISTER_NS_STRING_OR_NULL_CONSTANT("http\\Client\\Curl\\Versions", "ICONV", *tmp_ptr ? tmp_ptr : NULL, CONST_CS|CONST_PERSISTENT);
 #if PHP_HTTP_CURL_VERSION(7,57,0)
                REGISTER_NS_STRING_OR_NULL_CONSTANT("http\\Client\\Curl\\Versions", "BROTLI", info->brotli_version, CONST_CS|CONST_PERSISTENT);
 #endif