X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=src%2Fphp_http_client_curl.c;h=915b8fc31f506ccf1aec46abd6a343bd5d7cd30d;hp=aa79d2947f37683c79f07f1b54ffd63dbe99091a;hb=701840587c7b8ddb35259ac3de5c988e0eefa805;hpb=3d3727416df3f7b51b10a5c5d5af7249d5500222 diff --git a/src/php_http_client_curl.c b/src/php_http_client_curl.c index aa79d29..915b8fc 100644 --- a/src/php_http_client_curl.c +++ b/src/php_http_client_curl.c @@ -330,6 +330,7 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) char *c = NULL; long l = 0; double d = 0; + curl_off_t o = 0; struct curl_slist *s = NULL, *p = NULL; zval tmp; @@ -510,6 +511,12 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) zend_hash_str_update(info, "scheme", lenof("scheme"), &tmp); } #endif +#if PHP_HTTP_CURL_VERSION(7,66,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_RETRY_AFTER, &o)) { + ZVAL_LONG(&tmp, o); + zend_hash_str_update(info, "retry_after", lenof("retry_after"), &tmp); + } +#endif #if PHP_HTTP_CURL_VERSION(7,72,0) if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_EFFECTIVE_METHOD, &c)) { ZVAL_STRING(&tmp, STR_PTR(c)); @@ -1306,6 +1313,11 @@ static void php_http_curle_options_init(php_http_options_t *registry) */ php_http_option_register(registry, ZEND_STRL("fresh_connect"), CURLOPT_FRESH_CONNECT, _IS_BOOL); php_http_option_register(registry, ZEND_STRL("forbid_reuse"), CURLOPT_FORBID_REUSE, _IS_BOOL); +#if PHP_HTTP_CURL_VERSION(7,65,0) + if ((opt = php_http_option_register(registry, ZEND_STRL("maxage_conn"), CURLOPT_MAXAGE_CONN, IS_LONG))) { + ZVAL_LONG(&opt->defval, 118); + } +#endif /* outgoing interface */ php_http_option_register(registry, ZEND_STRL("interface"), CURLOPT_INTERFACE, IS_STRING); @@ -1339,6 +1351,9 @@ static void php_http_curle_options_init(php_http_options_t *registry) opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; } #endif +#if PHP_HTTP_CURL_VERSION(7,75,0) + php_http_option_register(registry, ZEND_STRL("aws_sigv4"), CURLOPT_AWS_SIGV4, IS_STRING); +#endif /* redirects */ if ((opt = php_http_option_register(registry, ZEND_STRL("redirect"), CURLOPT_FOLLOWLOCATION, IS_LONG))) { @@ -1609,6 +1624,12 @@ static void php_http_curle_options_init(php_http_options_t *registry) opt->setter = php_http_curle_option_set_ssl_verifyhost; } php_http_option_register(proxy_registry, ZEND_STRL("cipher_list"), CURLOPT_PROXY_SSL_CIPHER_LIST, IS_STRING); +# if PHP_HTTP_CURL_VERSION(7,71,0) + if ((opt = php_http_option_register(proxy_registry, ZEND_STRL("issuercert"), CURLOPT_PROXY_ISSUERCERT, IS_STRING))) { + opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; + opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR; + } +# endif # if PHP_HTTP_HAVE_LIBCURL_OPENSSL if ((opt = php_http_option_register(proxy_registry, ZEND_STRL("crlfile"), CURLOPT_PROXY_CRLFILE, IS_STRING))) { opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; @@ -1662,12 +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 } @@ -1911,6 +1950,12 @@ static void php_http_curlm_options_init(php_http_options_t *registry) #if PHP_HTTP_CURL_VERSION(7,30,0) php_http_option_register(registry, ZEND_STRL("max_total_connections"), CURLMOPT_MAX_TOTAL_CONNECTIONS, IS_LONG); #endif +#if PHP_HTTP_CURL_VERSION(7,67,0) + if ((opt = php_http_option_register(registry, ZEND_STRL("max_concurrent_streams"), CURLMOPT_MAX_CONCURRENT_STREAMS, IS_LONG))) { + ZVAL_LONG(&opt->defval, 100); + } +#endif + #if !PHP_HTTP_CURL_VERSION(7,62,0) /* enable/disable HTTP pipelining */ php_http_option_register(registry, ZEND_STRL("pipelining"), CURLMOPT_PIPELINING, _IS_BOOL); @@ -2627,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) @@ -2747,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 @@ -2841,6 +2888,9 @@ PHP_MINIT_FUNCTION(http_client_curl) #endif #if PHP_HTTP_CURL_VERSION(7,61,0) REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AUTH_BEARER", CURLAUTH_BEARER, CONST_CS|CONST_PERSISTENT); +#endif +#if PHP_HTTP_CURL_VERSION(7,75,0) + REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AWS_SIGV4", CURLAUTH_AWS_SIGV4, CONST_CS|CONST_PERSISTENT); #endif REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "AUTH_ANY", CURLAUTH_ANY, CONST_CS|CONST_PERSISTENT); @@ -2873,6 +2923,10 @@ PHP_MINIT_FUNCTION(http_client_curl) REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "ALTSVC_H1", CURLALTSVC_H1, CONST_CS|CONST_PERSISTENT); REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "ALTSVC_H2", CURLALTSVC_H2, CONST_CS|CONST_PERSISTENT); REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "ALTSVC_H3", CURLALTSVC_H3, CONST_CS|CONST_PERSISTENT); +#endif +#if PHP_HTTP_CURL_VERSION(7,74,0) + REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "HSTS_ENABLE", CURLHSTS_ENABLE, CONST_CS|CONST_PERSISTENT); + REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "HSTS_READONLYFILE", CURLHSTS_READONLYFILE, CONST_CS|CONST_PERSISTENT); #endif return SUCCESS; }