From 80bb9787a447fd8443b824f4b3f38ecf87eca9b6 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 3 Oct 2016 11:48:32 +0200 Subject: [PATCH] update config.m4; allow disabling idna; add idnkit --- .travis.yml | 75 ++-- autoconf/pecl/libcurl.m4 | 190 +++++++++ autoconf/pecl/libevent.m4 | 17 + autoconf/pecl/pecl.m4 | 391 +++++++++++++++++ autoconf/pecl/zlib.m4 | 12 + config9.m4 | 691 +++++++------------------------ scripts/gen_travis_yml.php | 1 + src/php_http.c | 20 +- src/php_http_api.h | 28 +- src/php_http_client_curl.c | 47 ++- src/php_http_client_curl_event.c | 23 +- src/php_http_curl.c | 29 +- src/php_http_etag.c | 12 +- src/php_http_misc.c | 6 +- src/php_http_misc.h | 2 +- src/php_http_querystring.c | 8 +- src/php_http_querystring.h | 2 +- src/php_http_url.c | 137 ++++-- tests/bug66388.phpt | 1 + tests/client025.phpt | 1 + tests/client030.phpt | 1 + tests/serialize001.phpt | 5 +- tests/urlparser006.phpt | 5 +- tests/urlparser007.phpt | 6 +- tests/urlparser012.phpt | 46 ++ tests/urlparser013.phpt | 43 ++ 26 files changed, 1101 insertions(+), 698 deletions(-) create mode 100644 autoconf/pecl/libcurl.m4 create mode 100644 autoconf/pecl/libevent.m4 create mode 100644 autoconf/pecl/pecl.m4 create mode 100644 autoconf/pecl/zlib.m4 create mode 100644 tests/urlparser012.phpt create mode 100644 tests/urlparser013.phpt diff --git a/.travis.yml b/.travis.yml index a281b7e..5524d30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,35 +9,60 @@ addons: - php5-cli - php-pear - libcurl4-openssl-dev - - zlib1g-dev - libidn11-dev + - libidn2-0-dev + - libicu-dev - libevent-dev env: - - PHP=7.0 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - - PHP=7.1 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - - PHP=master enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - - PHP=7.0 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - - PHP=7.1 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - - PHP=master enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes - - PHP=7.0 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - - PHP=7.1 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - - PHP=master enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - - PHP=7.0 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - - PHP=7.1 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - - PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes - - PHP=7.0 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=7.1 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=master enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=7.0 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=7.1 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=master enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=7.0 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=7.1 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=master enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=7.0 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=7.1 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes - - PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes + - PHP=7.0 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.1 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=master enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.0 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.1 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=master enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.0 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.1 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=master enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.0 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.1 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.0 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.1 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=master enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.0 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.1 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=master enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.0 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.1 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=master enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.0 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.1 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=no + - PHP=7.0 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.1 enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=master enable_debug=no enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.0 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.1 enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=master enable_debug=yes enable_maintainer_zts=no enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.0 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.1 enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=master enable_debug=no enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.0 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.1 enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=no enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.0 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.1 enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=master enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.0 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.1 enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=master enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.0 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.1 enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=master enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.0 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=7.1 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes + - PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes # once with gcov - CFLAGS="-O0 -g --coverage" CXXFLAGS="-O0 -g --coverage" PHP=master enable_json=yes enable_hash=yes enable_iconv=yes diff --git a/autoconf/pecl/libcurl.m4 b/autoconf/pecl/libcurl.m4 new file mode 100644 index 0000000..1c09d37 --- /dev/null +++ b/autoconf/pecl/libcurl.m4 @@ -0,0 +1,190 @@ +dnl +dnl PECL_HAVE_LIBCURL_FEATURE(feature[, code-if-yes[, code-if-no]]) +dnl +dnl Checks $CURL_CONFIG --feature. +dnl Defines PHP__HAVE_LIBCURL_ +dnl +AC_DEFUN([PECL_HAVE_LIBCURL_FEATURE], [dnl + AC_REQUIRE([PECL_PROG_EGREP])dnl + AC_CACHE_CHECK([for $1 feature in libcurl], PECL_CACHE_VAR([HAVE_LIBCURL_FEATURE_$1]), [ + if $CURL_CONFIG --feature | $EGREP -q $1; then + PECL_CACHE_VAR([HAVE_LIBCURL_FEATURE_$1])=yes + else + PECL_CACHE_VAR([HAVE_LIBCURL_FEATURE_$1])=no + fi + ]) + PECL_VAR([HAVE_LIBCURL_FEATURE_$1])=$PECL_CACHE_VAR([HAVE_LIBCURL_FEATURE_$1]) + if $PECL_VAR([HAVE_LIBCURL_FEATURE_$1]); then + PECL_DEFINE([HAVE_LIBCURL_$1]) + $2 + else + ifelse([$3],,:,[$3]) + fi +]) +dnl +dnl PECL_HAVE_LIBCURL_PROTOCOL(protocol[, code-if-yes[, code-if-no]]) +dnl +AC_DEFUN([PECL_HAVE_LIBCURL_PROTOCOL], [ + AC_CACHE_CHECK([for $1 protocol in libcurl], PECL_CACHE_VAR([HAVE_LIBCURL_PROTOCOL_$1]), [ + if $CURL_CONFIG --protocols | $EGREP -q $1; then + PECL_CACHE_VAR([HAVE_LIBCURL_PROTOCOL_$1])=yes + else + PECL_CACHE_VAR([HAVE_LIBCURL_PROTOCOL_$1])=no + fi + ]) + PECL_VAR([HAVE_LIBCURL_PROTOCOL_$1])=$PECL_CACHE_VAR([HAVE_LIBCURL_PROTOCOL_$1]) + if $PECL_VAR([HAVE_LIBCURL_PROTOCOL_$1]); then + PECL_DEFINE([HAVE_LIBCURL_$1]) + $2 + else + ifelse([$3],,:,[$3]) + fi +]) +dnl +dnl PECL_HAVE_LIBCURL_SSLLIB(ssllib-name, headers, libs) +dnl +AC_DEFUN([PECL_HAVE_LIBCURL_SSLLIB], [ + AC_CACHE_CHECK([for $1 providing SSL in libcurl], PECL_CACHE_VAR([HAVE_LIBCURL_$1]), [ + AC_TRY_RUN([ + #include + int main(int argc, char *argv[]) { + curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); + if (data && data->ssl_version && *data->ssl_version) { + const char *ptr = data->ssl_version; + while(*ptr == ' ') ++ptr; + return strncasecmp(ptr, "$1", sizeof("$1")-1); + } + return 1; + } + ], [ + PECL_CACHE_VAR([HAVE_LIBCURL_$1])=yes + ], [ + PECL_CACHE_VAR([HAVE_LIBCURL_$1])=no + ]) + ]) + PECL_VAR([HAVE_LIBCURL_$1])=$PECL_CACHE_VAR([HAVE_LIBCURL_$1]) + if $PECL_VAR([HAVE_LIBCURL_$1]); then + PECL_DEFINE([HAVE_LIBCURL_$1]) + m4_foreach_w(header, $2, [AC_CHECK_HEADER(header,, [ + PECL_VAR([HAVE_LIBCURL_$1])=false + ])]) + ifelse([$3],,,[ + if $PECL_VAR([HAVE_LIBCURL_$1]); then + m4_foreach_w(lib, $3, [ + PHP_ADD_LIBRARY(lib, true, [AS_TR_CPP(PECL_NAME[_SHARED_LIBADD])]) + ]) + fi + ]) + fi +]) +dnl +dnl PECL_HAVE_LIBCURL_SSL +dnl +AC_DEFUN([PECL_HAVE_LIBCURL_SSL], [ + PECL_HAVE_LIBCURL_FEATURE([SSL], [ + PECL_HAVE_LIBCURL_SSLLIB([OpenSSL], [openssl/ssl.h openssl/crypto.h], [ssl crypto]) + PECL_HAVE_LIBCURL_SSLLIB([GnuTLS], [gnutls.h gcrypt.h], [gnutls gcrypt]) + PECL_HAVE_LIBCURL_SSLLIB([NSS]) + PECL_HAVE_LIBCURL_SSLLIB([SecureTransport]) + PECL_HAVE_LIBCURL_SSLLIB([GSKit]) + + PECL_HAVE_CONST([curl/curl.h], [CURLOPT_TLSAUTH_TYPE], int, [ + PECL_DEFINE([HAVE_LIBCURL_TLSAUTH_TYPE]) + AC_CACHE_CHECK([whether CURLOPT_TLSAUTH_TYPE expects CURL_TLSAUTH_SRP], PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP]), [ + PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])= + AC_TRY_RUN([ + #include + int main(int argc, char *argv[]) { + CURL *ch = curl_easy_init(); + return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, CURL_TLSAUTH_SRP); + } + ], [ + PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=yes + ], [ + AC_TRY_RUN([ + #include + int main(int argc, char *argv[]) { + CURL *ch = curl_easy_init(); + return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, "SRP"); + } + ], [ + PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=no + ]) + ]) + ]) + if test -n "$PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])"; then + if $PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP]); then + PECL_DEFINE([LIBCURL_TLSAUTH_SRP], [CURL_TLSAUTH_SRP]) + PECL_DEFINE([LIBCURL_TLSAUTH_DEF], [CURL_TLSAUTH_NONE]) + else + PECL_DEFINE([LIBCURL_TLSAUTH_SRP], ["SRP"]) + PECL_DEFINE([LIBCURL_TLSAUTH_DEF], [""]) + fi + fi + ]) + ]) +]) +dnl +dnl PECL_HAVE_LIBCURL_ARES +dnl +AC_DEFUN([PECL_HAVE_LIBCURL_ARES], [ + AC_CACHE_CHECK([for c-ares providing AsynchDNS in libcurl], PECL_CACHE_VAR([HAVE_LIBCURL_ARES]), [ + AC_TRY_RUN([ + #include + int main(int argc, char *argv[]) { + curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); + if (data && data->ares && data->ares_num0) { + return 0; + } + return 1; + } + ], [ + PECL_CACHE_VAR([HAVE_LIBCURL_ARES])=yes + ], [ + PECL_CACHE_VAR([HAVE_LIBCURL_ARES])=no + ]) + ]) + PECL_VAR([HAVE_LIBCURL_ARES])=$PECL_CACHE_VAR([HAVE_LIBCURL_ARES]) + if $PECL_VAR([HAVE_LIBCURL_ARES]); then + PECL_DEFINE([HAVE_LIBCURL_ARES]) + fi +]) +dnl +dnl PECL_HAVE_LIBCURL_CA +dnl +dnl Checks for any installed default CA path/info with PECL_CHECK_CA providing curl's ca config. +dnl Defines shell vars PHP__LIBCURL_CAPATH and PHP__LIBCURL_CAINFO +dnl additionally to those defined in PECL_CHECK_CA. +dnl +AC_DEFUN([PECL_HAVE_LIBCURL_CA], [ + CURL_CONFIG_CA=$($CURL_CONFIG --ca) + if test -z "$CURL_CONFIG_CA"; then + CURL_CONFIG_CA=$($CURL_CONFIG --configure | $EGREP -o -- "--with-ca@<:@^'@:>@*" | $SED 's/.*=//') + fi + PECL_CHECK_CA($CURL_CONFIG_CA, $CURL_CONFIG_CA) + PECL_VAR([LIBCURL_CAPATH])=$PECL_VAR([CAPATH]) + PECL_VAR([LIBCURL_CAINFO])=$PECL_VAR([CAINFO]) +]) +dnl +dnl PECL_CHECK_LIBCURL(search-dir[, min-version]) +dnl +dnl Defines shell var $CURL_CONFIG (false if curl-config could not be found). +dnl +dnl Calls PECL_CHECK_CONFIG(libcurl ...) for its tests. +dnl Call PECL_CHECK_DONE(libcurl[, success]) yourself when you're done +dnl with any subtests. This is IMPORTANT! +dnl +AC_DEFUN([PECL_CHECK_LIBCURL], [dnl + AC_REQUIRE([PECL_PROG_SED])dnl + AC_REQUIRE([PECL_PROG_EGREP])dnl + AC_PATH_PROG([CURL_CONFIG], [curl-config], false, [$1/bin:$PATH:/usr/local/bin]) + PECL_CHECK_CONFIG(libcurl, $CURL_CONFIG, + [--version | $SED -e 's/@<:@^0-9\.@:>@//g'], + [--cflags], + [--libs | $EGREP -o -- '-L@<:@^ @:>@* ?'], + [--libs | $EGREP -o -- '-l@<:@^ @:>@* ?']dnl + ) + ifelse([$2],,,[ + PECL_HAVE_VERSION([libcurl], [$2]) + ]) +]) \ No newline at end of file diff --git a/autoconf/pecl/libevent.m4 b/autoconf/pecl/libevent.m4 new file mode 100644 index 0000000..bd04296 --- /dev/null +++ b/autoconf/pecl/libevent.m4 @@ -0,0 +1,17 @@ + +AC_DEFUN([PECL_CHECK_LIBEVENT], [ + PECL_CHECK_PKGCONFIG(libevent, [$1]) + PECL_HAVE_VERSION(libevent, 2.0, [ + PECL_DEFINE([HAVE_LIBEVENT2]) + ]) + ifelse([$2],,,[PECL_HAVE_VERSION(libevent, [$2])]) + AC_CHECK_FUNC(event_base_new,,[ + AC_DEFINE([event_base_new], [event_init], [missing event_base_new() in libevent1]) + ]) + AC_CHECK_FUNC(event_assign,,[ + AC_DEFINE([event_assign(e, b, s, a, cb, d)], [do {\ + event_set(e, s, a, cb, d); \ + event_base_set(b, e);\ + } while(0)], [missing event_assign() in libevent1]) + ]) +]) \ No newline at end of file diff --git a/autoconf/pecl/pecl.m4 b/autoconf/pecl/pecl.m4 new file mode 100644 index 0000000..9ab9aed --- /dev/null +++ b/autoconf/pecl/pecl.m4 @@ -0,0 +1,391 @@ + +yes() { + true +} +no() { + false +} +dnl +dnl PECL_INIT(name) +dnl +dnl Start configuring the PECL extension. +dnl +AC_DEFUN([PECL_INIT], [dnl + m4_define([PECL_NAME],[$1])dnl +])dnl +dnl +dnl +dnl PECL_VAR(name) +dnl +AC_DEFUN([PECL_VAR], [dnl +AS_TR_CPP([PHP_]PECL_NAME[_$1])dnl +])dnl +dnl +dnl PECL_CACHE_VAR(name) +dnl +AC_DEFUN([PECL_CACHE_VAR], [dnl +AS_TR_SH([PECL_cv_$1])dnl +])dnl +dnl +dnl PECL_SAVE_VAR(name) +dnl +AC_DEFUN([PECL_SAVE_VAR], [dnl +AS_TR_SH([PECL_sv_$1])dnl +])dnl +dnl +dnl PECL_DEFINE(what, to[, desc]) +dnl +AC_DEFUN([PECL_DEFINE], [dnl + AC_DEFINE(PECL_VAR([$1]), ifelse([$2],,1,[$2]), ifelse([$3],,[ ],[$3])) +])dnl +dnl +dnl PECL_DEFINE_UQ(what, to[, desc]) +dnl +AC_DEFUN([PECL_DEFINE_UQ], [dnl + AC_DEFINE_UNQUOTED(PECL_VAR([$1]), [$2], ifelse([$3],,[ ],[$3])) +])dnl +dnl +dnl PECL_DEFINE_SH(what, to[, desc]) +dnl +AC_DEFUN([PECL_DEFINE_SH], [dnl + PECL_VAR([$1])=$2 + PECL_DEFINE_UQ([$1], [$2], [$3]) +]) +dnl +dnl PECL_DEFINE_FN(fn) +dnl +AC_DEFUN([PECL_DEFINE_FN], [ + AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1], [ ]) +]) +dnl +dnl PECL_SAVE_ENV(var, ns) +dnl +AC_DEFUN([PECL_SAVE_ENV], [ + PECL_SAVE_VAR([$2_$1])=[$]$1 +]) +dnl +dnl PECL_RESTORE_ENV(var, ns) +dnl +AC_DEFUN([PECL_RESTORE_ENV], [ + $1=$PECL_SAVE_VAR([$2_$1]) +]) +dnl +dnl PECL_PROG_EGREP +dnl +dnl Checks for an egrep. Defines $EGREP. +dnl +AC_DEFUN([PECL_PROG_EGREP], [ + ifdef([AC_PROG_EGREP], [ + AC_PROG_EGREP + ], [ + AC_CHECK_PROG(EGREP, egrep, egrep) + ]) +]) +dnl +dnl PECL_PROG_AWK +dnl +dnl Checks for an awk. Defines $AWK. +dnl +AC_DEFUN([PECL_PROG_AWK], [ + ifdef([AC_PROG_AWK], [ + AC_PROG_AWK + ], [ + AC_CHECK_PROG(AWK, awk, awk) + ]) +]) +dnl +dnl PECL_PROG_SED +dnl +dnl Checks for the sed program. Defines $SED. +dnl +AC_DEFUN([PECL_PROG_SED], [ + ifdef([AC_PROG_SED], [ + AC_PROG_SED + ], [ + ifdef([LT_AC_PROG_SED], [ + LT_AC_PROG_SED + ], [ + AC_CHECK_PROG(SED, sed, sed) + ]) + ]) +]) +dnl +dnl PECL_PROG_PKGCONFIG +dnl +dnl Checks for pkg-config program and defines $PKG_CONFIG (to false if not found). +dnl +AC_DEFUN([PECL_PROG_PKGCONFIG], [ + if test -z "$PKG_CONFIG"; then + AC_PATH_PROG([PKG_CONFIG], [pkg-config], [false]) + fi +]) +dnl +dnl PECL_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]]) +dnl +dnl Check whether ext/$name is enabled in $PHP_EXECUTABLE (PECL build) +dnl or if $PHP_ is defined to anything else than "no" (in-tree build). +dnl Defines shell var PECL_VAR(HAVE_EXT_) to true or false. +dnl +AC_DEFUN([PECL_HAVE_PHP_EXT], [ + AC_REQUIRE([PECL_PROG_EGREP])dnl + AC_CACHE_CHECK([whether ext/$1 is enabled], PECL_CACHE_VAR([HAVE_EXT_$1]), [ + PECL_CACHE_VAR([HAVE_EXT_$1])=no + if test -x "$PHP_EXECUTABLE"; then + if $PHP_EXECUTABLE -m | $EGREP -q ^$1\$; then + PECL_CACHE_VAR([HAVE_EXT_$1])=yes + fi + elif test -n "$AS_TR_CPP([PHP_$1])" && test "$AS_TR_CPP([PHP_$1])" != "no"; then + PECL_CACHE_VAR([HAVE_EXT_$1])=yes + fi + ]) + if $PECL_CACHE_VAR([HAVE_EXT_$1]); then + PECL_VAR([HAVE_EXT_$1])=true + PECL_DEFINE([HAVE_EXT_$1]) + $2 + else + PECL_VAR([HAVE_EXT_$1])=false + $3 + fi +]) +dnl +dnl PECL_HAVE_PHP_EXT_HEADER(ext[, header]) +dnl +dnl Check where to find a header for ext and add the found dir to $INCLUDES. +dnl If header is not specified php_.h is assumed. +dnl Defines shell var PHP__EXT__INCDIR to the found dir. +dnl Defines PHP__HAVE_
to the found path. +dnl +AC_DEFUN([PECL_HAVE_PHP_EXT_HEADER], [dnl + AC_REQUIRE([PECL_PROG_SED])dnl + m4_define([EXT_HEADER], ifelse([$2],,php_$1.h,[$2]))dnl + AC_CACHE_CHECK([for EXT_HEADER of ext/$1], PECL_CACHE_VAR([EXT_$1]_INCDIR), [ + for i in $(printf "%s" "$INCLUDES" | $SED -e's/-I//g') $abs_srcdir ../$1; do + if test -d $i; then + for j in $i/EXT_HEADER $i/ext/$1/EXT_HEADER; do + if test -f $j; then + PECL_CACHE_VAR([EXT_$1]_INCDIR)=$(dirname "$j") + break + fi + done + fi + done + ]) + PECL_VAR([EXT_$1]_INCDIR)=$PECL_CACHE_VAR([EXT_$1]_INCDIR) + PHP_ADD_INCLUDE([$PECL_VAR([EXT_$1]_INCDIR)]) + PECL_DEFINE_UQ([HAVE_]EXT_HEADER, "$PECL_VAR([EXT_$1]_INCDIR)/EXT_HEADER") +]) +dnl +dnl PECL_HAVE_CONST(header, const[, type=int[, code-if-yes[, code-if-mno]]]) +dnl +AC_DEFUN([PECL_HAVE_CONST], [dnl + AC_REQUIRE([PECL_PROG_EGREP])dnl + AC_CACHE_CHECK([for $2 in $1], PECL_CACHE_VAR([HAVE_$1_$2]), [ + AC_TRY_COMPILE([ + #include "$1" + ], [ + ]ifelse([$3],,int,[$3])[ _c = $2; + ], [ + PECL_CACHE_VAR([HAVE_$1_$2])=yes + ], [ + PECL_CACHE_VAR([HAVE_$1_$2])=no + ]) + ]) + if $PECL_CACHE_VAR([HAVE_$1_$2]); then + PECL_DEFINE([HAVE_$2]) + $4 + else + ifelse([$5],,:,[$5]) + fi +]) +dnl +dnl _PECL_TR_VERSION(version) +dnl +AC_DEFUN([_PECL_TR_VERSION], [dnl +AC_REQUIRE([PECL_PROG_AWK])dnl +$(printf "%s" $1 | $AWK -F "[.]" '{print $[]1*1000000 + $[]2*10000 + $[]3*100 + $[]4}') +]) +dnl +dnl PECL_CHECKED_VERSION(name) +dnl +dnl Shell var name of an already checked version. +dnl +AC_DEFUN([PECL_CHECKED_VERSION], [PECL_VAR([$1][_VERSION])]) +dnl +dnl PECL_HAVE_VERSION(name, min-version[, code-if-yes[, code-if-not]]) +dnl +dnl Perform a min-version check while in an PECL_CHECK_* block. +dnl Expands AC_MSG_ERROR when code-if-not is empty and the version check fails. +dnl +AC_DEFUN([PECL_HAVE_VERSION], [ + aversion=_PECL_TR_VERSION([$PECL_CHECKED_VERSION([$1])]) + mversion=_PECL_TR_VERSION([$2]) + AC_MSG_CHECKING([whether $1 version $PECL_CHECKED_VERSION([$1]) >= $2]) + if test "$aversion" -lt "$mversion"; then + ifelse($4,,AC_MSG_ERROR([no]), [ + AC_MSG_RESULT([no]) + $4 + ]) + else + AC_MSG_RESULT([ok]) + $3 + fi +]) +dnl +dnl PECL_CHECK_CUSTOM(name, path, header, lib, version) +dnl +AC_DEFUN([PECL_CHECK_CUSTOM], [ + PECL_SAVE_ENV([CPPFLAGS], [$1]) + PECL_SAVE_ENV([LDFLAGS], [$1]) + PECL_SAVE_ENV([LIBS], [$1]) + + AC_MSG_CHECKING([for $1]) + AC_CACHE_VAL(PECL_CACHE_VAR([$1_prefix]), [ + for path in $2 /usr/local /usr /opt; do + if test "$path" = "" || test "$path" = "yes" || test "$path" = "no"; then + continue + elif test -f "$path/include/$3"; then + PECL_CACHE_VAR([$1_prefix])="$path" + break + fi + done + ]) + if test -n "$PECL_CACHE_VAR([$1_prefix])"; then + CPPFLAGS="-I$PECL_CACHE_VAR([$1_prefix])/include" + LDFLAGS="-L$PECL_CACHE_VAR([$1_prefix])/$PHP_LIBDIR" + LIBS="-l$4" + + AC_CACHE_VAL(PECL_CACHE_VAR([$1_version]), [ + PECL_CACHE_VAR([$1_version])=$5 + ]) + PECL_CHECKED_VERSION([$1])=$PECL_CACHE_VAR([$1_version]) + + if test -n "$PECL_CHECKED_VERSION([$1])"; then + PECL_VAR([HAVE_$1])=true + PECL_DEFINE([HAVE_$1]) + PECL_DEFINE_UQ($1[_VERSION], "$PECL_CHECKED_VERSION([$1])") + else + PECL_VAR([HAVE_$1])=false + fi + fi + AC_MSG_RESULT([${PECL_CHECKED_VERSION([$1]):-no}]) +]) +dnl +dnl PECL_CHECK_CONFIG(name, prog-config, version-flag, cppflags-flag, ldflags-flag, libs-flag) +dnl +AC_DEFUN([PECL_CHECK_CONFIG], [ + PECL_SAVE_ENV([CPPFLAGS], [$1]) + PECL_SAVE_ENV([LDFLAGS], [$1]) + PECL_SAVE_ENV([LIBS], [$1]) + + + AC_MSG_CHECKING([for $1]) + ifelse($2, [$PKG_CONFIG $1], [ + AC_CACHE_VAL(PECL_CACHE_VAR([$1_exists]), [ + if $($2 --exists); then + PECL_CACHE_VAR([$1_exists])=yes + else + PECL_CACHE_VAR([$1_exists])=no + fi + ]) + if $PECL_CACHE_VAR([$1_exists]); then + ]) + AC_CACHE_VAL(PECL_CACHE_VAR([$1_version]), [ + PECL_CACHE_VAR([$1_version])=$($2 $3) + ]) + PECL_CHECKED_VERSION([$1])=$PECL_CACHE_VAR([$1_version]) + AC_CACHE_VAL(PECL_CACHE_VAR([$1_cppflags]), [ + PECL_CACHE_VAR([$1_cppflags])=$($2 $4) + ]) + CPPFLAGS=$PECL_CACHE_VAR([$1_cppflags]) + AC_CACHE_VAL(PECL_CACHE_VAR([$1_ldflags]), [ + PECL_CACHE_VAR([$1_ldflags])=$($2 $5) + ]) + LDFLAGS=$PECL_CACHE_VAR([$1_ldflags]) + AC_CACHE_VAL(PECL_CACHE_VAR([$1_libs]), [ + PECL_CACHE_VAR([$1_libs])=$($2 $6) + ]) + LIBS=$PECL_CACHE_VAR([$1_libs]) + ifelse($2, [$PKG_CONFIG $1], [ + fi + ]) + + if test -n "$PECL_CHECKED_VERSION([$1])"; then + PECL_VAR([HAVE_$1])=true + PECL_DEFINE([HAVE_$1]) + PECL_DEFINE_UQ([$1_VERSION], "$PECL_CHECKED_VERSION([$1])") + else + PECL_VAR([HAVE_$1])=false + fi + + AC_MSG_RESULT([${PECL_CHECKED_VERSION([$1]):-no}]) +]) +dnl +dnl PECL_CHECK_PKGCONFIG(pkg[, additional-pkg-config-path]) +dnl +AC_DEFUN([PECL_CHECK_PKGCONFIG], [dnl + AC_REQUIRE([PECL_PROG_PKGCONFIG])dnl + ifelse($2,,,PKG_CONFIG_PATH="$2/lib/pkgconfig:$PKG_CONFIG_PATH") + PECL_CHECK_CONFIG([$1], [$PKG_CONFIG $1], [--modversion], [--cflags-only-I], [--libs-only-L], [--libs-only-l]) +]) +dnl +dnl PECL_CHECK_DONE(name, success[, incline, libline]) +dnl +AC_DEFUN([PECL_CHECK_DONE], [ + if $2; then + incline=$CPPFLAGS + libline="$LDFLAGS $LIBS" + PECL_DEFINE([HAVE_$1]) + else + incline=$3 + libline=$4 + fi + + PECL_RESTORE_ENV([CPPFLAGS], [$1]) + PECL_RESTORE_ENV([LDFLAGS], [$1]) + PECL_RESTORE_ENV([LIBS], [$1]) + + PHP_EVAL_INCLINE([$incline]) + PHP_EVAL_LIBLINE([$libline], AS_TR_CPP(PECL_NAME[_SHARED_LIBADD])) +]) + +dnl +dnl PECL_CHECK_CA([additional-ca-paths,[ additional-ca-bundles]]) +dnl +AC_DEFUN([PECL_CHECK_CA], [ + AC_CACHE_CHECK([for default CA path], PECL_CACHE_VAR([CAPATH]), [ + PECL_VAR([CAPATH])= + for ca_path in $1 \ + /etc/ssl/certs \ + /System/Library/OpenSSL + do + # check if it's actually a hashed directory + if test -d "$ca_path" && ls "$ca_path"/@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@.0 >/dev/null 2>&1; then + PECL_CACHE_VAR([CAPATH])=$ca_path + break + fi + done + ]) + if test -n "$PECL_CACHE_VAR([CAPATH])"; then + PECL_DEFINE_SH([CAPATH], "$PECL_CACHE_VAR([CAPATH])") + fi + + AC_CACHE_CHECK([for default CA info], PECL_CACHE_VAR([CAINFO]), [ + for ca_info in $2 \ + /etc/ssl/{cert,ca-bundle}.pem \ + /{etc,usr/share}/ssl/certs/ca-{bundle,ceritifcates}.crt \ + /etc/{pki/ca-trust,ca-certificates}/extracted/pem/tls-ca-bundle.pem \ + /etc/pki/tls/certs/ca-bundle{,.trust}.crt \ + /usr/local/etc/{,open}ssl/cert.pem \ + /usr/local/share/certs/ca-root-nss.crt \ + /{usr,usr/local,opt}/local/share/curl/curl-ca-bundle.crt + do + if test -f "$ca_info"; then + PECL_CACHE_VAR([CAINFO])=$ca_info + break + fi + done + ]) + if test -n "$PECL_CACHE_VAR([CAINFO])"; then + PECL_DEFINE_SH([CAINFO], "$PECL_CACHE_VAR([CAINFO])") + fi +]) diff --git a/autoconf/pecl/zlib.m4 b/autoconf/pecl/zlib.m4 new file mode 100644 index 0000000..d3a04c6 --- /dev/null +++ b/autoconf/pecl/zlib.m4 @@ -0,0 +1,12 @@ +dnl +dnl PECL_CHECK_ZLIB( +dnl +dnl Calls PECL_CHECK_CUSTOM(zlib ...) for its tests. +dnl Call PECL_CHECK_DONE(zlib[, success]) yourself when you're done +dnl with any subtests. This is IMPORTANT! +dnl +AC_DEFUN([PECL_CHECK_ZLIB], [ + PECL_CHECK_CUSTOM(zlib, ["$1" "$PHP_ZLIB_DIR" "$PHP_ZLIB"], zlib.h, z, + [$($EGREP "define ZLIB_VERSION" "$path/include/zlib.h" | $SED -e 's/@<:@^0-9\.@:>@//g')]) + ifelse([$2],,,[PECL_HAVE_VERSION(zlib, $2)]) +]) \ No newline at end of file diff --git a/config9.m4 b/config9.m4 index 73290e6..c8e0d45 100644 --- a/config9.m4 +++ b/config9.m4 @@ -1,593 +1,198 @@ -dnl config.m4 for pecl/http -dnl $Id: config9.m4 242664 2007-09-18 19:13:37Z mike $ -dnl vim: noet ts=4 sw=4 + +m4_foreach(dir, [., ext/http], [ + sinclude(dir/autoconf/pecl/pecl.m4) + sinclude(dir/autoconf/pecl/zlib.m4) + sinclude(dir/autoconf/pecl/libcurl.m4) + sinclude(dir/autoconf/pecl/libevent.m4) +]) + +PECL_INIT([http]) PHP_ARG_WITH([http], [whether to enable extended HTTP support], [ --with-http Enable extended HTTP support]) -PHP_ARG_WITH([http-zlib-dir], [], -[ --with-http-zlib-dir[=DIR] HTTP: where to find zlib], $PHP_HTTP, $PHP_HTTP) -PHP_ARG_WITH([http-libcurl-dir], [], -[ --with-http-libcurl-dir[=DIR] HTTP: where to find libcurl], $PHP_HTTP, $PHP_HTTP) -PHP_ARG_WITH([http-libevent-dir], [], -[ --with-http-libevent-dir[=DIR] HTTP: where to find libevent], $PHP_HTTP_LIBCURL_DIR, "") -PHP_ARG_WITH([http-libidn-dir], [], -[ --with-http-libidn-dir[=DIR] HTTP: where to find libidn], $PHP_HTTP_LIBCURL_DIR, "") -PHP_ARG_WITH([http-libidn2-dir], [], -[ --with-http-libidn-dir[=DIR] HTTP: where to find libidn2], $PHP_HTTP_LIBCURL_DIR, "") -PHP_ARG_WITH([http-libicu-dir], [], -[ --with-http-libidn-dir[=DIR] HTTP: where to find libicu], $PHP_HTTP_LIBCURL_DIR, "") - if test "$PHP_HTTP" != "no"; then - - HTTP_HAVE_A_REQUEST_LIB=false - - ifdef([AC_PROG_EGREP], [ - AC_PROG_EGREP - ], [ - AC_CHECK_PROG(EGREP, egrep, egrep) + dnl STDC + AC_TYPE_OFF_T + AC_TYPE_MBSTATE_T + dnl getdomainname() is declared in netdb.h on some platforms: AIX, OSF + AC_CHECK_HEADERS([netdb.h unistd.h wchar.h wctype.h arpa/inet.h]) + AC_CHECK_FUNC(gethostname,,[ + AC_CHECK_LIB(nsl, gethostname) ]) - ifdef([AC_PROG_SED], [ - AC_PROG_SED - ], [ - ifdef([LT_AC_PROG_SED], [ - LT_AC_PROG_SED - ], [ - AC_CHECK_PROG(SED, sed, sed) - ]) + AC_CHECK_FUNC(getdomainname,,[ + AC_CHECK_LIB(nsl, getdomainname) ]) - - if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, false) + AC_CHECK_FUNCS(mbrtowc mbtowc iswalnum inet_pton) + + dnl ZLIB + PHP_ARG_WITH([http-zlib-dir], [whether/where to check for zlib], + [ --with-http-zlib-dir[=DIR] HTTP: where to find zlib], $PHP_HTTP, no) + PECL_CHECK_ZLIB([$PHP_HTTP_ZLIB_DIR], [1.2.0.4]) + PECL_CHECK_DONE(zlib, $PECL_VAR([HAVE_ZLIB])) + + dnl CURL + PHP_ARG_WITH([http-libcurl-dir], [whether/where to check for libcurl], + [ --with-http-libcurl-dir[=DIR] HTTP: where to find libcurl], $PHP_HTTP, no) + if test "$PHP_HTTP_LIBCURL_DIR" != "no"; then + PECL_CHECK_LIBCURL([$PHP_HTTP_LIBCURL_DIR], [7.18.2]) + PECL_HAVE_LIBCURL_PROTOCOL([HTTP], [ + PECL_HAVE_LIBCURL_FEATURE([HTTP2]) + PECL_HAVE_LIBCURL_ARES + PECL_HAVE_LIBCURL_SSL + PECL_HAVE_LIBCURL_CA + PECL_DEFINE([HAVE_CLIENT]) + ]) + PECL_CHECK_DONE(libcurl, [$PECL_VAR([HAVE_LIBCURL_PROTOCOL_HTTP])]) fi - AC_PROG_CPP - - if test "$PHP_HTTP_SHARED_DEPS" != "no"; then - AC_DEFINE([PHP_HTTP_SHARED_DEPS], [1], [ ]) - else - AC_DEFINE([PHP_HTTP_SHARED_DEPS], [0], [ ]) + dnl EVENT + PHP_ARG_WITH([http-libevent-dir], [whether/where to check for libevent], + [ --with-http-libevent-dir[=DIR] HTTP: where to find libevent], $PHP_HTTP_LIBCURL_DIR, no) + if test "$PHP_HTTP_LIBEVENT_DIR" != "no"; then + PECL_CHECK_LIBEVENT([$PHP_HTTP_LIBEVENT_DIR]) + PECL_CHECK_DONE(libevent, [$PECL_VAR([HAVE_LIBEVENT])]) fi - dnl - dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]]) - dnl - AC_DEFUN([HTTP_SHARED_DEP], [ - extname=$1 - haveext=$[PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__) - - AC_MSG_CHECKING([whether to add a dependency on ext/$extname]) - if test "$PHP_HTTP_SHARED_DEPS" = "no"; then - AC_MSG_RESULT([no]) - $3 - elif test "$haveext"; then - AC_MSG_RESULT([yes]) - AC_DEFINE([PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__), [1], [ ]) - ifdef([PHP_ADD_EXTENSION_DEP], [ - PHP_ADD_EXTENSION_DEP([http], $1, true) - ]) - $2 - else - AC_MSG_RESULT([no]) - $3 - fi - ]) - - dnl - dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]]) - dnl - AC_DEFUN([HTTP_HAVE_PHP_EXT], [ - extname=$1 - haveext=$[PHP_]translit($1,a-z_-,A-Z__) - AC_MSG_CHECKING([for ext/$extname support]) - if test -x "$PHP_EXECUTABLE"; then - grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$` - if test "$grepext" = "$extname"; then - [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1 - AC_MSG_RESULT([yes]) - $2 - else - [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)= - AC_MSG_RESULT([no]) - $3 - fi - elif test "$haveext" != "no" && test "x$haveext" != "x"; then - [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1 - AC_MSG_RESULT([yes]) - $2 - else - [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)= - AC_MSG_RESULT([no]) - $3 - fi - ]) - - dnl - dnl HTTP_HAVE_VERSION(name, min-version[, code-if-yes[, code-if-not]]) - dnl - AC_DEFUN([HTTP_HAVE_VERSION], [ - aversion=$(printf "%s" "$AS_TR_CPP([PHP_HTTP_]$1[_VERSION])" | $AWK '{print $[]1*1000000 + $[]2*10000 + $[]3*100 + $[]4}') - mversion=$(printf "%s" "$2" | $AWK '{print $[]1*1000000 + $[]2*10000 + $[]3*100 + $[]4}') - AC_MSG_CHECKING([whether $1 version $]AS_TR_CPP([PHP_HTTP_]$1[_VERSION])[ is at least $2]) - if test "$aversion" -lt "$mversion"; then - ifelse($4,,AC_MSG_ERROR([$1 minimum version $mversion required; got $aversion]), [ - AC_MSG_RESULT([no]) - $4 - ]) - else - AC_MSG_RESULT([ok]) - $3 + dnl GNU IDNA + PHP_ARG_WITH([http-libidn2-dir], [whether/where to check for libidn2], + [ --with-http-libidn2-dir[=DIR] HTTP: where to find libidn2], $PHP_HTTP_LIBCURL_DIR, no) + if test "$PHP_HTTP_LIBIDN2_DIR" != "no"; then + PECL_CHECK_CUSTOM(libidn2, "$PHP_HTTP_LIBIDN2_DIR", idn2.h, idn2, + [$($EGREP "define IDN2_VERSION " "$path/include/idn2.h" | $SED -e's/^.*VERSION //g' -e 's/@<:@^0-9\.@:>@//g')]) + if $PECL_VAR([HAVE_LIBIDN2]); then + PECL_DEFINE([HAVE_IDNA2008]) fi - ]) - - dnl - dnl HTTP_CHECK_CUSTOM(name, path, header, lib, version) - dnl - AC_DEFUN([HTTP_CHECK_CUSTOM], [ - save_CPPFLAGS=$CPPFLAGS - save_LDFLAGS=$LDFLAGS - save_LIBS=$LIBS - - for path in $2 /usr/local /usr /opt; do - if test "$path" = "" || test "$path" = "yes" || test "$path" = "no"; then - continue - fi - AC_MSG_CHECKING([for $1 in $path]) - if test -f "$path/include/$3"; then - CPPFLAGS="-I$path" - LDFLAGS="-L$path" - LIBS="-l$4" - - AS_TR_CPP([PHP_HTTP_][$1][_VERSION])=$5 - AC_MSG_RESULT([${AS_TR_CPP([PHP_HTTP_][$1][_VERSION]):-no}]) - AC_DEFINE_UNQUOTED(AS_TR_CPP([PHP_HTTP_][$1][_VERSION]), "$AS_TR_CPP([PHP_HTTP_][$1][_VERSION])", [ ]) - break - fi - AC_MSG_RESULT([no]) - done - ]) - - dnl - dnl HTTP_CHECK_CONFIG(name, prog-config, version-flag, cppflags-flag, ldflags-flag, libs-flag) - dnl - AC_DEFUN([HTTP_CHECK_CONFIG], [ - AC_MSG_CHECKING([for $1]) - - save_CPPFLAGS=$CPPFLAGS - save_LDFLAGS=$LDFLAGS - save_LIBS=$LIBS - AS_TR_CPP([PHP_HTTP_][$1][_VERSION])=$($2 $3) - CPPFLAGS=$($2 $4) - LDFLAGS=$($2 $5) - LIBS=$($2 $6) - - AC_MSG_RESULT([${AS_TR_CPP([PHP_HTTP_][$1][_VERSION]):-no}]) - AC_DEFINE_UNQUOTED(AS_TR_CPP([PHP_HTTP_][$1][_VERSION]), "$AS_TR_CPP([PHP_HTTP_][$1][_VERSION])", [ ]) - ]) - - dnl - dnl HTTP_CHECK_PKGCONFIG(pkg[, pkg_config_path]) - dnl - AC_DEFUN([HTTP_CHECK_PKGCONFIG], [ - ifelse($2,,,PKG_CONFIG_PATH="$2/lib/pkgconfig:$PKG_CONFIG_PATH") - if $($PKG_CONFIG $1 --exists); then - AS_TR_CPP([PHP_HTTP_HAVE_$1])=true - HTTP_CHECK_CONFIG([$1], [$PKG_CONFIG $1], [--modversion], [--cflags-only-I], [--libs-only-L], [--libs-only-l]) - else - AS_TR_CPP([PHP_HTTP_HAVE_$1])=false - fi - ]) - - dnl - dnl HTTP_CHECK_DONE(name, success[, incline, libline]) - AC_DEFUN([HTTP_CHECK_DONE], [ - if $2; then - incline=$CPPFLAGS - libline="$LDFLAGS $LIBS" - AC_DEFINE(AS_TR_CPP([PHP_HTTP_HAVE_$1]), [1], [ ]) - else - incline=$3 - libline=$4 - fi - - CPPFLAGS=$save_CPPFLAGS - LDFLAGS=$save_LDFLAGS - LIBS=$save_LIBS - - PHP_EVAL_INCLINE([$incline]) - PHP_EVAL_LIBLINE([$libline], HTTP_SHARED_LIBLINE) - ]) - - dnl - dnl HTTP_CURL_SSL_LIB_CHECK(ssllib[, code-if-yes[, code-if-not]) - dnl - AC_DEFUN([HTTP_CURL_SSL_LIB_CHECK], [ - AC_MSG_CHECKING([for $1 support in libcurl]) - AC_TRY_RUN([ - #include - int main(int argc, char *argv[]) { - curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); - if (data && data->ssl_version && *data->ssl_version) { - const char *ptr = data->ssl_version; - while(*ptr == ' ') ++ptr; - return strncasecmp(ptr, "$1", sizeof("$1")-1); - } - return 1; - } - ], [ - AC_MSG_RESULT([yes]) - $2 - ], [ - AC_MSG_RESULT([no]) - $3 - ], [ - AC_MSG_RESULT([no]) - $3 - ]) - ]) - - -dnl ---- -dnl STDC -dnl ---- - AC_TYPE_OFF_T - AC_TYPE_MBSTATE_T - dnl getdomainname() is declared in netdb.h on some platforms: AIX, OSF - AC_CHECK_HEADERS([netdb.h unistd.h wchar.h wctype.h arpa/inet.h]) - PHP_CHECK_FUNC(gethostname, nsl) - PHP_CHECK_FUNC(getdomainname, nsl) - PHP_CHECK_FUNC(mbrtowc) - PHP_CHECK_FUNC(mbtowc) - PHP_CHECK_FUNC(iswalnum) - PHP_CHECK_FUNC(inet_pton) - -dnl ---- -dnl IDN -dnl ---- - - HTTP_CHECK_PKGCONFIG(libidn, [$PHP_HTTP_LIBIDN_DIR]) - if $PHP_HTTP_HAVE_LIBIDN; then - AC_DEFINE([PHP_HTTP_HAVE_IDNA2003], [1], [ ]) + PECL_CHECK_DONE(libidn2, $PECL_VAR([HAVE_LIBIDN2])) fi - HTTP_CHECK_DONE(libidn, $PHP_HTTP_HAVE_LIBIDN) - - HTTP_CHECK_CUSTOM(libidn2, "$PHP_HTTP_LIBIDN2_DIR", idn2.h, idn2, - [$($EGREP "define IDN2_VERSION " $path/include/idn2.h | $SED -e's/^.*VERSION //g' -e 's/@<:@^0-9\.@:>@//g')]) - if test -n "$PHP_HTTP_LIBIDN2_VERSION"; then - AC_DEFINE([PHP_HTTP_HAVE_IDNA2008], [1], [ ]) + PHP_ARG_WITH([http-libidn-dir], [whether/where to check for libidn], + [ --with-http-libidn-dir[=DIR] HTTP: where to find libidn], $PHP_HTTP_LIBCURL_DIR, no) + if test "$PHP_HTTP_LIBIDN_DIR" != "no"; then + PECL_CHECK_PKGCONFIG(libidn, [$PHP_HTTP_LIBIDN_DIR]) + if $PECL_VAR([HAVE_LIBIDN]); then + PECL_DEFINE([HAVE_IDNA2003]) + fi + PECL_CHECK_DONE(libidn, $PECL_VAR([HAVE_LIBIDN])) fi - HTTP_CHECK_DONE(libidn2, test -n "$PHP_HTTP_LIBIDN2_VERSION") - case $host_os in - darwin*) - PHP_CHECK_FUNC(uidna_IDNToASCII, icucore) - ;; - *) + dnl ICU IDNA + PHP_ARG_WITH([http-libicu-dir], [whether/where to check for libicu], + [ --with-http-libidn-dir[=DIR] HTTP: where to find libicu], $PHP_HTTP_LIBCURL_DIR, no) + if test "$PHP_HTTP_LIBICU_DIR" != "no"; then AC_PATH_PROG(ICU_CONFIG, icu-config, false, [$PHP_HTTP_LIBICU_DIR/bin:$PATH:/usr/local/bin]) - HTTP_CHECK_CONFIG(libicu, [$ICU_CONFIG], [--version], [--cppflags], [--ldflags-searchpath], [--ldflags-libsonly]) - AC_MSG_CHECKING([for uidna_IDNToASCII]) - AC_TRY_LINK([ - #include - ], [ - uidna_IDNToASCII(0, 0, 0, 0, 0, 0, 0); - ], [ - AC_MSG_RESULT([yes]) - PHP_HTTP_HAVE_ICU=true - AC_DEFINE([PHP_HTTP_HAVE_IDNA2003], [1], [ ]) - AC_DEFINE([HAVE_UIDNA_IDNTOASCII], [1], [ ]) - ], [ - AC_MSG_RESULT([no]) - ]) - AC_MSG_CHECKING([for uidna_nameToASCII_UTF8]) - AC_TRY_LINK([ - #include - ], [ - uidna_nameToASCII_UTF8(0, 0, 0, 0, 0, 0, 0); - ], [ - AC_MSG_RESULT([yes]) - PHP_HTTP_HAVE_ICU=true - AC_DEFINE([PHP_HTTP_HAVE_IDNA2008], [1], [ ]) - AC_DEFINE([HAVE_UIDNA_NAMETOASCII_UTF8], [1], [ ]) - ], [ - AC_MSG_RESULT([no]) - ]) - HTTP_CHECK_DONE(libicu, [$PHP_HTTP_HAVE_LIBICU]) - ;; - esac - -dnl ---- -dnl ZLIB -dnl ---- - HTTP_CHECK_CUSTOM(zlib, ["$PHP_HTTP_ZLIB_DIR" "$PHP_ZLIB_DIR" "$PHP_ZLIB"], zlib.h, z, - [$($EGREP "define ZLIB_VERSION" "$path/include/zlib.h" | $SED -e 's/@<:@^0-9\.@:>@//g')]) - HTTP_HAVE_VERSION(zlib, 1.2.0.4) - HTTP_CHECK_DONE(zlib, test -n "$PHP_HTTP_ZLIB_VERSION") - -dnl ---- -dnl CURL -dnl ---- - - AC_PATH_PROG([CURL_CONFIG], [curl-config], false, [$PHP_HTTP_LIBCURL_DIR/bin:$PATH:/usr/local/bin]) - - if $CURL_CONFIG --protocols | $EGREP -q HTTP; then - HTTP_CHECK_CONFIG(libcurl, $CURL_CONFIG, - [--version | $SED -e 's/@<:@^0-9\.@:>@//g'], - [--cflags], - [--libs | $EGREP -o -- '-L@<:@^ @:>@* ?'], - [--libs | $EGREP -o -- '-l@<:@^ @:>@* ?'] - ) - HTTP_HAVE_VERSION(libcurl, 7.18.2) - - AC_MSG_CHECKING([for HTTP2 support in libcurl]) - if $CURL_CONFIG --feature | $EGREP -q HTTP2; then - AC_MSG_RESULT([yes]) - AC_DEFINE([PHP_HTTP_HAVE_HTTP2], [1], [ ]) - else - AC_MSG_RESULT([no]) - fi - - AC_MSG_CHECKING([for SSL support in libcurl]) - if $CURL_CONFIG --feature | $EGREP -q SSL; then - AC_MSG_RESULT([yes]) - AC_DEFINE([PHP_HTTP_HAVE_SSL], [1], [ ]) - - HTTP_CURL_SSL_LIB_CHECK(OpenSSL, [ - AC_CHECK_HEADER([openssl/ssl.h], [ - AC_CHECK_HEADER([openssl/crypto.h], [ - AC_DEFINE([PHP_HTTP_HAVE_OPENSSL], [1], [ ]) - LIBS="$LIBS -lssl -lcrypto" - ]) - ]) - ]) - HTTP_CURL_SSL_LIB_CHECK(GnuTLS, [ - AC_CHECK_HEADER([gnutls.h], [ - AC_CHECK_HEADER([gcrypt.h], [ - AC_DEFINE([PHP_HTTP_HAVE_GNUTLS], [1], [ ]) - LIBS="$LIBS -lgnutls -lgcrypt" - ]) - ]) - ]) - HTTP_CURL_SSL_LIB_CHECK(NSS, [ - AC_DEFINE([PHP_HTTP_HAVE_NSS], [1], [ ]) - ]) - HTTP_CURL_SSL_LIB_CHECK(SecureTransport, [ - AC_DEFINE([PHP_HTTP_HAVE_DARWINSSL], [1], [ ]) - ]) - HTTP_CURL_SSL_LIB_CHECK(GSKit, [ - AC_DEFINE([PHP_HTTP_HAVE_GSKIT], [1], [ ]) + PECL_CHECK_CONFIG(libicu, [$ICU_CONFIG], [--version], [--cppflags], [--ldflags-searchpath], [--ldflags-libsonly]) + AC_CACHE_CHECK([for uidna_IDNToASCII], PECL_CACHE_VAR([HAVE_UIDNA_IDNToASCII]), [ + AC_TRY_LINK([ + #include + ], [ + uidna_IDNToASCII(0, 0, 0, 0, 0, 0, 0); + ], [ + PECL_CACHE_VAR([HAVE_UIDNA_IDNToASCII])=yes + ], [ + PECL_CACHE_VAR([HAVE_UIDNA_IDNToASCII])=no ]) - else - dnl no CURL_SSL - AC_MSG_RESULT([no]) - fi - - AC_MSG_CHECKING([for ares support in libcurl]) - AC_TRY_RUN([ - #include - int main(int argc, char *argv[]) { - curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); - if (data && data->ares && data->ares_num0) { - return 0; - } - return 1; - } - ], [ - AC_MSG_RESULT([yes]) - AC_DEFINE([PHP_HTTP_HAVE_ARES], [1], [ ]) - ], [ - AC_MSG_RESULT([no]) - ], [ - AC_MSG_RESULT([no]) ]) + if $PECL_CACHE_VAR([HAVE_UIDNA_IDNTOASCII]); then + PECL_DEFINE([HAVE_IDNA2003]) + PECL_DEFINE_FN([UIDNA_IDNTOASCII]) + fi - AC_MSG_CHECKING([whether CURLOPT_TLSAUTH_TYPE expects CURL_TLSAUTH_SRP or literal "SRP"]) - AC_TRY_RUN([ - #include - int main(int argc, char *argv[]) { - CURL *ch = curl_easy_init(); - return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, CURL_TLSAUTH_SRP); - } - ], [ - AC_MSG_RESULT([CURL_TLSAUTH_SRP]) - AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_SRP], [CURL_TLSAUTH_SRP], [ ]) - AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_DEF], [CURL_TLSAUTH_NONE], [ ]) - ], [ - AC_TRY_RUN([ - #include - int main(int argc, char *argv[]) { - CURL *ch = curl_easy_init(); - return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, "SRP"); - } + AC_CACHE_CHECK([for uidna_nameToASCII_UTF8], PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8]), [ + AC_TRY_LINK([ + #include ], [ - AC_MSG_RESULT(["SRP"]) - AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_SRP], ["SRP"], [ ]) - AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_DEF], [""], [ ]) + uidna_nameToASCII_UTF8(0, 0, 0, 0, 0, 0, 0); ], [ - AC_MSG_RESULT([neither]) + PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8])=yes ], [ - AC_MSG_RESULT([neither]) + PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8])=no ]) - ], [ - AC_MSG_RESULT([neither]) ]) + if $PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8]); then + PECL_DEFINE([HAVE_IDNA2008]) + PECL_DEFINE_FN([uidna_nameToASCII_UTF8]) + fi + PECL_CHECK_DONE(libicu, [$PECL_VAR([HAVE_LIBICU])]) + fi - AC_MSG_CHECKING([for default SSL CA info/path]) - CURL_CA_PATH= - CURL_CA_INFO= - CURL_CONFIG_CA=$($CURL_CONFIG --ca) - if test -z "$CURL_CONFIG_CA"; then - CURL_CONFIG_CA=$($CURL_CONFIG --configure | $EGREP -o -- "--with-ca@<:@^'@:>@*" | $SED 's/.*=//') + dnl IDNKIT2 + PHP_ARG_WITH([http-libidnkit2-dir], [whether/where to check for libidnkit2], + [ --with-http-libidnkit2-dir[=DIR] HTTP: where to find libidnkit2], $PHP_HTTP_LIBCURL_DIR, no) + if test "$PHP_HTTP_LIBIDNKIT2_DIR" != "no"; then + PECL_CHECK_CUSTOM(libidnkit2, "$PHP_HTTP_LIBIDNKIT2_DIR", idn/api.h, idnkit, + [$($EGREP "define IDNKIT_VERSION_LIBIDN\b" "$path/include/idn/version.h" | $SED -e's/^.*VERSION_LIBIDN//g' -e 's/@<:@^0-9\.@:>@//g')]) + if $PECL_VAR([HAVE_LIBIDNKIT2]); then + PECL_DEFINE([HAVE_IDNA2008]) fi - for i in \ - "$CURL_CONFIG_CA" \ - /etc/ssl/certs \ - /etc/ssl/certs/ca-bundle.crt \ - /etc/ssl/certs/ca-certificates.crt \ - /etc/pki/tls/certs/ca-bundle.crt \ - /etc/pki/tls/certs/ca-bundle.trust.crt \ - /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ - /System/Library/OpenSSL - do - if test -z "$CURL_CA_PATH" && test -d "$i"; then - # check if it's actually a hashed directory - if ls "$i"/@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@@<:@0-9a-f@:>@.0 >/dev/null 2>&1; then - CURL_CA_PATH="$i" - fi - elif test -z "$CURL_CA_INFO" && test -f "$i"; then - CURL_CA_INFO="$i" - fi - done - if test -n "$CURL_CA_PATH" && test -n "$CURL_CA_INFO"; then - AC_MSG_RESULT([path:$CURL_CA_PATH, info:$CURL_CA_INFO]) - AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAPATH], ["$CURL_CA_PATH"], [path to default SSL CA path]) - AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CA_INFO"], [path to default SSL CA info]) - elif test -n "$CURL_CA_INFO"; then - AC_MSG_RESULT([info:$CURL_CA_INFO]) - AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CA_INFO"], [path to default SSL CA info]) - elif test -n "$CURL_CA_PATH"; then - AC_MSG_RESULT([path:$CURL_CA_PATH]) - AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAPATH], ["$CURL_CA_PATH"], [path to default SSL CA path]) + PECL_CHECK_DONE(libidnkit2, [$PECL_VAR([HAVE_LIBIDNKIT2])]) + fi + dnl IDNKIT1 + PHP_ARG_WITH([http-libidnkit-dir], [whether/where to check for libidnkit], + [ --with-http-libidnkit-dir[=DIR] HTTP: where to find libidnkit], $PHP_HTTP_LIBCURL_DIR, no) + if test "$PHP_HTTP_LIBIDNKIT_DIR" != "no"; then + # libidnkit1 and libidnkit2 have the same API + if test "$PHP_HTTP_LIBIDNKIT2_DIR" != no && $PECL_VAR([HAVE_LIBIDNKIT2]); then + AC_MSG_WARN([libidnkit-$PECL_VAR([LIBIDNKIT2_VERSION]) already enabled, skipping libidnkit1]) else - AC_MSG_RESULT([none]) + PECL_CHECK_CUSTOM(libidnkit, "$PHP_HTTP_LIBIDNKIT_DIR", idn/api.h, idnkit, + [$($EGREP "define IDNKIT_VERSION\b" "$path/include/idn/version.h" | $SED -e's/^.*VERSION//g' -e 's/@<:@^0-9\.@:>@//g')]) + if $PECL_VAR([HAVE_LIBIDNKIT]); then + PECL_DEFINE([HAVE_IDNA2003]) + fi + PECL_CHECK_DONE(libidnkit, [$PECL_VAR([HAVE_LIBIDNKIT])]) fi - - HTTP_HAVE_A_REQUEST_LIB=true fi - HTTP_CHECK_DONE(libcurl, test -n "$PHP_HTTP_LIBCURL_VERSION") - -dnl ---- -dnl EVENT -dnl ---- - HTTP_CHECK_PKGCONFIG(libevent, [$PHP_HTTP_LIBEVENT_DIR]) - HTTP_HAVE_VERSION(libevent, 2.0, [ - AC_DEFINE([PHP_HTTP_HAVE_LIBEVENT2], [1], [ ]) - ]) - HTTP_CHECK_DONE(libevent, [$PHP_HTTP_HAVE_LIBEVENT]) - -dnl ---- -dnl RAPHF -dnl ---- - HTTP_HAVE_PHP_EXT([raphf], [ - AC_MSG_CHECKING([for php_raphf.h]) - HTTP_EXT_RAPHF_INCDIR= - for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do - if test -d $i; then - if test -f $i/php_raphf.h; then - HTTP_EXT_RAPHF_INCDIR=$i - break - elif test -f $i/ext/raphf/php_raphf.h; then - HTTP_EXT_RAPHF_INCDIR=$i/ext/raphf - break - fi - fi - done - if test "x$HTTP_EXT_RAPHF_INCDIR" = "x"; then - AC_MSG_ERROR([not found]) - else - AC_MSG_RESULT([$HTTP_EXT_RAPHF_INCDIR]) - AC_DEFINE([PHP_HTTP_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support]) - PHP_ADD_INCLUDE([$HTTP_EXT_RAPHF_INCDIR]) - fi + dnl EXTENSIONS + PECL_HAVE_PHP_EXT([raphf], [ + PECL_HAVE_PHP_EXT_HEADER([raphf]) ], [ - AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini]) + AC_MSG_ERROR([please install and enable pecl/raphf]) ]) - -dnl ---- -dnl PROPRO -dnl ---- - HTTP_HAVE_PHP_EXT([propro], [ - AC_MSG_CHECKING([for php_propro.h]) - HTTP_EXT_PROPRO_INCDIR= - for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../propro; do - if test -d $i; then - if test -f $i/php_propro.h; then - HTTP_EXT_PROPRO_INCDIR=$i - break - elif test -f $i/ext/propro/php_propro.h; then - HTTP_EXT_PROPRO_INCDIR=$i/ext/propro - break - fi - fi - done - if test "x$HTTP_EXT_PROPRO_INCDIR" = "x"; then - AC_MSG_ERROR([not found]) - else - AC_MSG_RESULT([$HTTP_EXT_PROPRO_INCDIR]) - AC_DEFINE([PHP_HTTP_HAVE_PHP_PROPRO_H], [1], [Have ext/propro support]) - PHP_ADD_INCLUDE([$HTTP_EXT_PROPRO_INCDIR]) - fi + PECL_HAVE_PHP_EXT([propro], [ + PECL_HAVE_PHP_EXT_HEADER([propro]) ], [ - AC_MSG_ERROR([Please install pecl/propro and activate extension=propro.$SHLIB_DL_SUFFIX_NAME in your php.ini]) - ]) - -PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared], -[ --without-http-shared-deps HTTP: do not depend on extensions like hash - and iconv (when they are built shared)], $PHP_HTTP, $PHP_HTTP) -dnl ---- -dnl HASH -dnl ---- - HTTP_HAVE_PHP_EXT([hash], [ - AC_MSG_CHECKING([for php_hash.h]) - HTTP_EXT_HASH_INCDIR= - for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do - if test -d $i; then - if test -f $i/php_hash.h; then - HTTP_EXT_HASH_INCDIR=$i - break - elif test -f $i/ext/hash/php_hash.h; then - HTTP_EXT_HASH_INCDIR=$i/ext/hash - break - fi - fi - done - if test "x$HTTP_EXT_HASH_INCDIR" = "x"; then - AC_MSG_RESULT([not found]) - else - AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR]) - AC_DEFINE([PHP_HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support]) - PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR]) - fi + AC_MSG_ERROR([please install and enable pecl/propro]) ]) + PECL_HAVE_PHP_EXT([hash]) + PECL_HAVE_PHP_EXT([iconv]) -dnl ---- -dnl ICONV -dnl ---- - HTTP_HAVE_PHP_EXT([iconv]) - -dnl ---- -dnl DONE -dnl ---- - + dnl DONE PHP_SUBST([HTTP_SHARED_LIBADD]) - PHP_HTTP_SRCDIR=PHP_EXT_SRCDIR(http) - PHP_HTTP_BUILDDIR=PHP_EXT_BUILDDIR(http) + PECL_VAR([SRCDIR])=PHP_EXT_SRCDIR(http) + PECL_VAR([BUILDDIR])=PHP_EXT_BUILDDIR(http) - PHP_ADD_INCLUDE($PHP_HTTP_SRCDIR/src) - PHP_ADD_BUILD_DIR($PHP_HTTP_BUILDDIR/src) + PHP_ADD_INCLUDE([$PECL_VAR([SRCDIR])/src]) + PHP_ADD_BUILD_DIR([$PECL_VAR([BUILDDIR])/src]) - PHP_HTTP_HEADERS=`(cd $PHP_HTTP_SRCDIR/src && echo *.h)` - PHP_HTTP_SOURCES=`(cd $PHP_HTTP_SRCDIR && echo src/*.c)` + PECL_VAR([HEADERS])=$(cd $PECL_VAR([SRCDIR])/src && echo *.h) + PECL_VAR([SOURCES])=$(cd $PECL_VAR([SRCDIR]) && echo src/*.c) - PHP_NEW_EXTENSION(http, $PHP_HTTP_SOURCES, $ext_shared) - PHP_INSTALL_HEADERS(ext/http, php_http.h $PHP_HTTP_HEADERS) + PHP_NEW_EXTENSION(http, [$PECL_VAR([SOURCES])], [$ext_shared]) + PHP_INSTALL_HEADERS(ext/http, [php_http.h $PECL_VAR([HEADERS])]) - HTTP_SHARED_DEP([hash]) - HTTP_SHARED_DEP([iconv]) + PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared], + [ --without-http-shared-deps HTTP: do not depend on extensions like hash + and iconv (when they are built shared)], yes, no) + if test "$PHP_HTTP_SHARED_DEPS" != "no"; then + if $PECL_VAR([HAVE_EXT_HASH]); then + PHP_ADD_EXTENSION_DEP([http], [hash], true) + fi + if $PECL_VAR([HAVE_EXT_ICONV]); then + PHP_ADD_EXTENSION_DEP([http], [iconv], true) + fi + fi PHP_ADD_EXTENSION_DEP([http], [raphf], true) PHP_ADD_EXTENSION_DEP([http], [propro], true) - PHP_SUBST(PHP_HTTP_HEADERS) - PHP_SUBST(PHP_HTTP_SOURCES) + PHP_SUBST(PECL_VAR([HEADERS])) + PHP_SUBST(PECL_VAR([SOURCES])) - PHP_SUBST(PHP_HTTP_SRCDIR) - PHP_SUBST(PHP_HTTP_BUILDDIR) + PHP_SUBST(PECL_VAR([SRCDIR])) + PHP_SUBST(PECL_VAR([BUILDDIR])) PHP_ADD_MAKEFILE_FRAGMENT AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support]) - if $HTTP_HAVE_A_REQUEST_LIB; then - AC_DEFINE([PHP_HTTP_HAVE_CLIENT], [1], [Have HTTP client support]) - fi fi diff --git a/scripts/gen_travis_yml.php b/scripts/gen_travis_yml.php index cd74848..ff43cf0 100755 --- a/scripts/gen_travis_yml.php +++ b/scripts/gen_travis_yml.php @@ -26,6 +26,7 @@ $env = $gen([ "enable_json", "enable_hash" => ["yes"], "enable_iconv" => ["yes"], + "with_http_libicu_dir", ]); foreach ($env as $e) { printf(" - %s\n", $e); diff --git a/src/php_http.c b/src/php_http.c index 4130bce..207c248 100644 --- a/src/php_http.c +++ b/src/php_http.c @@ -37,10 +37,13 @@ #if PHP_HTTP_HAVE_LIBIDN # include #endif +#if PHP_HTTP_HAVE_LIBIDNKIT2 || PHP_HTTP_HAVE_LIBIDNKIT +#include "idn/version.h" +#endif ZEND_DECLARE_MODULE_GLOBALS(php_http); -#ifdef COMPILE_DL_HTTP +#if COMPILE_DL_HTTP ZEND_GET_MODULE(http) #endif @@ -57,10 +60,10 @@ static zend_module_dep http_module_deps[] = { ZEND_MOD_REQUIRED("raphf") ZEND_MOD_REQUIRED("propro") ZEND_MOD_REQUIRED("spl") -#ifdef PHP_HTTP_HAVE_HASH +#if PHP_HTTP_HAVE_HASH ZEND_MOD_REQUIRED("hash") #endif -#ifdef PHP_HTTP_HAVE_ICONV +#if PHP_HTTP_HAVE_ICONV ZEND_MOD_REQUIRED("iconv") #endif {NULL, NULL, NULL, 0} @@ -257,7 +260,16 @@ PHP_MINFO_FUNCTION(http) #else php_info_print_table_row(3, "libidn (IDNA2003)", "disabled", "disabled"); #endif - +#if PHP_HTTP_HAVE_LIBIDNKIT2 + php_info_print_table_row(3, "libidnkit2 (IDNA2008)", IDNKIT_VERSION_LIBIDN, idn_version_libidn()); +#else + php_info_print_table_row(3, "libidnkit2 (IDNA2008)", "disabled", "disabled"); +#endif +#if PHP_HTTP_HAVE_LIBIDNKIT + php_info_print_table_row(3, "libidnkit (IDNA2003)", IDNKIT_VERSION, idn_version_getstring()); +#else + php_info_print_table_row(3, "libidnkit (IDNA2003)", "disabled", "disabled"); +#endif php_info_print_table_end(); DISPLAY_INI_ENTRIES(); diff --git a/src/php_http_api.h b/src/php_http_api.h index 717b64c..4071f0f 100644 --- a/src/php_http_api.h +++ b/src/php_http_api.h @@ -33,37 +33,37 @@ #include "zend_exceptions.h" -#ifdef PHP_WIN32 +#if PHP_WIN32 # define PHP_HTTP_API __declspec(dllexport) -#elif defined(__GNUC__) && __GNUC__ >= 4 +#elif __GNUC__ >= 4 # define PHP_HTTP_API extern __attribute__ ((visibility("default"))) #else # define PHP_HTTP_API extern #endif -#if (defined(HAVE_ICONV) || defined(PHP_HTTP_HAVE_EXT_ICONV)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV)) -# define PHP_HTTP_HAVE_ICONV +#if (HAVE_ICONV || PHP_HTTP_HAVE_EXT_ICONV) && (PHP_HTTP_SHARED_DEPS || !COMPILE_DL_ICONV) +# define PHP_HTTP_HAVE_ICONV 1 #endif -#if (defined(HAVE_HASH_EXT) || defined(PHP_HTTP_HAVE_EXT_HASH)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_HASH)) && defined(PHP_HTTP_HAVE_PHP_HASH_H) -# define PHP_HTTP_HAVE_HASH +#if (HAVE_HASH_EXT || PHP_HTTP_HAVE_EXT_HASH) && (PHP_HTTP_SHARED_DEPS || !COMPILE_DL_HASH) +# define PHP_HTTP_HAVE_HASH 1 #endif #include -#ifdef PHP_WIN32 +#if PHP_WIN32 # define CURL_STATICLIB # include #else -# ifdef HAVE_NETDB_H +# if HAVE_NETDB_H # include # endif -# ifdef HAVE_UNISTD_H +# if HAVE_UNISTD_H # include # endif #endif -#if defined(HAVE_WCHAR_H) && defined(HAVE_WCTYPE_H) && defined(HAVE_ISWALNUM) && (defined(HAVE_MBRTOWC) || defined(HAVE_MBTOWC)) +#if HAVE_WCHAR_H && HAVE_WCTYPE_H && HAVE_ISWALNUM && (HAVE_MBRTOWC || HAVE_MBTOWC) # define PHP_HTTP_HAVE_WCHAR 1 #endif @@ -108,18 +108,18 @@ ZEND_BEGIN_MODULE_GLOBALS(php_http) struct php_http_env_globals env; -#ifdef PHP_HTTP_HAVE_CLIENT +#if PHP_HTTP_HAVE_CLIENT struct { -#ifdef PHP_HTTP_HAVE_LIBCURL +# if PHP_HTTP_HAVE_LIBCURL struct php_http_client_curl_globals curl; -#endif +# endif } client; #endif ZEND_END_MODULE_GLOBALS(php_http) ZEND_EXTERN_MODULE_GLOBALS(php_http); -#ifdef ZTS +#if ZTS # include "TSRM/TSRM.h" # define PHP_HTTP_G ((zend_php_http_globals *) (*((void ***) tsrm_get_ls_cache()))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)]) # undef TSRMLS_FETCH_FROM_CTX diff --git a/src/php_http_client_curl.c b/src/php_http_client_curl.c index 641a9d8..ca39e93 100644 --- a/src/php_http_client_curl.c +++ b/src/php_http_client_curl.c @@ -17,10 +17,10 @@ #if PHP_HTTP_HAVE_LIBCURL -#ifdef PHP_HTTP_HAVE_OPENSSL +#if PHP_HTTP_HAVE_LIBCURL_OPENSSL # include #endif -#ifdef PHP_HTTP_HAVE_GNUTLS +#if PHP_HTTP_HAVE_LIBCURL_GNUTLS # include #endif @@ -500,7 +500,7 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) break; case CURLSSLBACKEND_OPENSSL: backend = "openssl"; -#ifdef PHP_HTTP_HAVE_OPENSSL +#if PHP_HTTP_HAVE_LIBCURL_OPENSSL { SSL_CTX *ctx = ti->internals; @@ -516,7 +516,7 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) break; case CURLSSLBACKEND_GNUTLS: backend = "gnutls"; -#ifdef PHP_HTTP_HAVE_GNUTLS +#if PHP_HTTP_HAVE_LIBCURL_GNUTLS { gnutls_session_t sess = ti->internals; char *desc; @@ -564,7 +564,10 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) } #endif -#if (PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL)) || (PHP_HTTP_CURL_VERSION(7,34,0) && defined(PHP_HTTP_HAVE_NSS)) || (PHP_HTTP_CURL_VERSION(7,42,0) && defined(PHP_HTTP_HAVE_GNUTLS)) || (PHP_HTTP_CURL_VERSION(7,39,0) && defined(PHP_HTTP_HAVE_GSKIT)) +#if (PHP_HTTP_CURL_VERSION(7,19,1) && PHP_HTTP_HAVE_LIBCURL_OPENSSL) || \ + (PHP_HTTP_CURL_VERSION(7,34,0) && PHP_HTTP_HAVE_LIBCURL_NSS) || \ + (PHP_HTTP_CURL_VERSION(7,42,0) && PHP_HTTP_HAVE_LIBCURL_GNUTLS) || \ + (PHP_HTTP_CURL_VERSION(7,39,0) && PHP_HTTP_HAVE_LIBCURL_GSKIT) { int i; zval ci_array, subarray; @@ -1098,7 +1101,7 @@ static ZEND_RESULT_CODE php_http_curle_option_set_resolve(php_http_option_t *opt } #endif -#if PHP_HTTP_CURL_VERSION(7,21,4) && defined(PHP_HTTP_CURL_TLSAUTH_SRP) +#if PHP_HTTP_CURL_VERSION(7,21,4) && PHP_HTTP_HAVE_LIBCURL_TLSAUTH_TYPE static ZEND_RESULT_CODE php_http_curle_option_set_ssl_tlsauthtype(php_http_option_t *opt, zval *val, void *userdata) { php_http_client_curl_handler_t *curl = userdata; @@ -1107,7 +1110,7 @@ static ZEND_RESULT_CODE php_http_curle_option_set_ssl_tlsauthtype(php_http_optio if (val && Z_LVAL_P(val)) { switch (Z_LVAL_P(val)) { case CURL_TLSAUTH_SRP: - if (CURLE_OK == curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, PHP_HTTP_CURL_TLSAUTH_SRP)) { + if (CURLE_OK == curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, PHP_HTTP_LIBCURL_TLSAUTH_SRP)) { return SUCCESS; } /* no break */ @@ -1115,7 +1118,7 @@ static ZEND_RESULT_CODE php_http_curle_option_set_ssl_tlsauthtype(php_http_optio return FAILURE; } } - if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, PHP_HTTP_CURL_TLSAUTH_DEF)) { + if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, PHP_HTTP_LIBCURL_TLSAUTH_DEF)) { return FAILURE; } return SUCCESS; @@ -1178,7 +1181,7 @@ static void php_http_curle_options_init(php_http_options_t *registry) opt->setter = php_http_curle_option_set_resolve; } #endif -#if PHP_HTTP_HAVE_ARES +#if PHP_HTTP_HAVE_LIBCURL_ARES # if PHP_HTTP_CURL_VERSION(7,24,0) if ((opt = php_http_option_register(registry, ZEND_STRL("dns_servers"), CURLOPT_DNS_SERVERS, IS_STRING))) { opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; @@ -1388,22 +1391,22 @@ static void php_http_curle_options_init(php_http_options_t *registry) ZVAL_BOOL(&opt->defval, 1); opt->setter = php_http_curle_option_set_ssl_verifyhost; } -#if PHP_HTTP_CURL_VERSION(7,41,0) && (defined(PHP_HTTP_HAVE_OPENSSL) || defined(PHP_HTTP_HAVE_NSS) || defined(PHP_HTTP_HAVE_GNUTLS)) +#if PHP_HTTP_CURL_VERSION(7,41,0) && (PHP_HTTP_HAVE_LIBCURL_OPENSSL || PHP_HTTP_HAVE_LIBCURL_NSS || PHP_HTTP_HAVE_LIBCURL_GNUTLS) php_http_option_register(registry, ZEND_STRL("verifystatus"), CURLOPT_SSL_VERIFYSTATUS, _IS_BOOL); #endif php_http_option_register(registry, ZEND_STRL("cipher_list"), CURLOPT_SSL_CIPHER_LIST, IS_STRING); if ((opt = php_http_option_register(registry, ZEND_STRL("cainfo"), CURLOPT_CAINFO, IS_STRING))) { opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR; -#ifdef PHP_HTTP_CURL_CAINFO - ZVAL_PSTRING(&opt->defval, PHP_HTTP_CURL_CAINFO); +#ifdef PHP_HTTP_CAINFO + ZVAL_PSTRING(&opt->defval, PHP_HTTP_CAINFO); #endif } if ((opt = php_http_option_register(registry, ZEND_STRL("capath"), CURLOPT_CAPATH, IS_STRING))) { opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR; -#ifdef PHP_HTTP_CURL_CAPATH - ZVAL_PSTRING(&opt->defval, PHP_HTTP_CURL_CAPATH); +#ifdef PHP_HTTP_CAPATH + ZVAL_PSTRING(&opt->defval, PHP_HTTP_CAPATH); #endif } if ((opt = php_http_option_register(registry, ZEND_STRL("random_file"), CURLOPT_RANDOM_FILE, IS_STRING))) { @@ -1419,14 +1422,14 @@ static void php_http_curle_options_init(php_http_options_t *registry) opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR; } -# ifdef PHP_HTTP_HAVE_OPENSSL +# if PHP_HTTP_HAVE_LIBCURL_OPENSSL if ((opt = php_http_option_register(registry, ZEND_STRL("crlfile"), CURLOPT_CRLFILE, IS_STRING))) { opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_STRLEN; opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR; } # endif #endif -#if (PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL)) || (PHP_HTTP_CURL_VERSION(7,34,0) && defined(PHP_HTTP_HAVE_NSS)) || (PHP_HTTP_CURL_VERSION(7,42,0) && defined(PHP_HTTP_HAVE_GNUTLS)) || (PHP_HTTP_CURL_VERSION(7,39,0) && defined(PHP_HTTP_HAVE_GSKIT)) +#if (PHP_HTTP_CURL_VERSION(7,19,1) && PHP_HTTP_HAVE_LIBCURL_OPENSSL) || (PHP_HTTP_CURL_VERSION(7,34,0) && PHP_HTTP_HAVE_LIBCURL_NSS) || (PHP_HTTP_CURL_VERSION(7,42,0) && defined(PHP_HTTP_HAVE_LIBCURL_GNUTLS)) || (PHP_HTTP_CURL_VERSION(7,39,0) && defined(PHP_HTTP_HAVE_LIBCURL_GSKIT)) if ((opt = php_http_option_register(registry, ZEND_STRL("certinfo"), CURLOPT_CERTINFO, _IS_BOOL))) { ZVAL_FALSE(&opt->defval); } @@ -1446,7 +1449,7 @@ static void php_http_curle_options_init(php_http_options_t *registry) opt->flags |= PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR; } #endif -#if PHP_HTTP_CURL_VERSION(7,21,4) && defined(PHP_HTTP_CURL_TLSAUTH_SRP) +#if PHP_HTTP_CURL_VERSION(7,21,4) && PHP_HTTP_HAVE_LIBCURL_TLSAUTH_TYPE if ((opt = php_http_option_register(registry, ZEND_STRL("tlsauthtype"), CURLOPT_TLSAUTH_TYPE, IS_LONG))) { opt->setter = php_http_curle_option_set_ssl_tlsauthtype; } @@ -1457,7 +1460,7 @@ 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,42,0) && (defined(PHP_HTTP_HAVE_NSS) || defined(PHP_HTTP_HAVE_DARWINSSL)) +#if PHP_HTTP_CURL_VERSION(7,42,0) && (PHP_HTTP_HAVE_LIBCURL_NSS || PHP_HTTP_HAVE_LIBCURL_SECURETRANSPORT) php_http_option_register(registry, ZEND_STRL("falsestart"), CURLOPT_SSL_FALSESTART, _IS_BOOL); #endif } @@ -1876,7 +1879,7 @@ static php_http_client_curl_handler_t *php_http_client_curl_handler_init(php_htt php_http_buffer_init(&handler->options.ranges); zend_hash_init(&handler->options.cache, 0, NULL, ZVAL_PTR_DTOR, 0); -#if defined(ZTS) +#if ZTS curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L); #endif curl_easy_setopt(handle, CURLOPT_HEADER, 0L); @@ -2225,7 +2228,7 @@ static void php_http_client_curl_reset(php_http_client_t *h) } } -#ifdef PHP_WIN32 +#if PHP_WIN32 # define SELECT_ERROR SOCKET_ERROR #else # define SELECT_ERROR -1 @@ -2291,7 +2294,7 @@ static ZEND_RESULT_CODE php_http_client_curl_exec(php_http_client_t *h) while (php_http_client_curl_once(h) && !EG(exception)) { if (SUCCESS != php_http_client_curl_wait(h, NULL)) { -#ifdef PHP_WIN32 +#if PHP_WIN32 /* see http://msdn.microsoft.com/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp */ php_error_docref(NULL, E_WARNING, "WinSock error: %d", WSAGetLastError()); #else @@ -2538,7 +2541,7 @@ PHP_MINIT_FUNCTION(http_client_curl) REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_SSLv2", CURL_SSLVERSION_SSLv2, CONST_CS|CONST_PERSISTENT); REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_SSLv3", CURL_SSLVERSION_SSLv3, CONST_CS|CONST_PERSISTENT); REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "SSL_VERSION_ANY", CURL_SSLVERSION_DEFAULT, CONST_CS|CONST_PERSISTENT); -#if PHP_HTTP_CURL_VERSION(7,21,4) && defined(PHP_HTTP_CURL_TLSAUTH_SRP) +#if PHP_HTTP_CURL_VERSION(7,21,4) && PHP_HTTP_HAVE_LIBCURL_TLSAUTH_TYPE REGISTER_NS_LONG_CONSTANT("http\\Client\\Curl", "TLSAUTH_SRP", CURL_TLSAUTH_SRP, CONST_CS|CONST_PERSISTENT); #endif diff --git a/src/php_http_client_curl_event.c b/src/php_http_client_curl_event.c index ea5f6af..38e1a56 100644 --- a/src/php_http_client_curl_event.c +++ b/src/php_http_client_curl_event.c @@ -14,24 +14,11 @@ #if PHP_HTTP_HAVE_LIBCURL #if PHP_HTTP_HAVE_LIBEVENT -# if !PHP_HTTP_HAVE_LIBEVENT2 && /* just be really sure */ !(LIBEVENT_VERSION_NUMBER >= 0x02000000) -# include -# define event_base_new event_init -# define event_assign(e, b, s, a, cb, d) do {\ - event_set(e, s, a, cb, d); \ - event_base_set(b, e); \ - } while(0) -# else -# if PHP_HTTP_HAVE_LIBEVENT2 -# include -# include -# else -# error "libevent presence is unknown" -# endif -# endif -# ifndef DBG_EVENTS -# define DBG_EVENTS 0 -# endif + +#include +#ifndef DBG_EVENTS +# define DBG_EVENTS 0 +#endif typedef struct php_http_client_curl_event_context { php_http_client_t *client; diff --git a/src/php_http_curl.c b/src/php_http_curl.c index 3a67443..5c026a6 100644 --- a/src/php_http_curl.c +++ b/src/php_http_curl.c @@ -14,23 +14,24 @@ #if PHP_HTTP_HAVE_LIBCURL -#if defined(ZTS) && defined(PHP_HTTP_HAVE_SSL) -# ifdef PHP_WIN32 -# define PHP_HTTP_NEED_OPENSSL_TSL +#if ZTS && PHP_HTTP_HAVE_LIBCURL_SSL +# include "TSRM.h" +# if PHP_WIN32 +# define PHP_HTTP_NEED_OPENSSL_TSL 1 # include # else /* !PHP_WIN32 */ -# if defined(PHP_HTTP_HAVE_OPENSSL) -# define PHP_HTTP_NEED_OPENSSL_TSL +# if PHP_HTTP_HAVE_LIBCURL_OPENSSL +# define PHP_HTTP_NEED_OPENSSL_TSL 1 # include -# elif defined(PHP_HTTP_HAVE_GNUTLS) -# define PHP_HTTP_NEED_GNUTLS_TSL +# elif PHP_HTTP_HAVE_LIBCURL_GNUTLS +# define PHP_HTTP_NEED_GNUTLS_TSL 1 # include -# endif /* PHP_HTTP_HAVE_OPENSSL || PHP_HTTP_HAVE_GNUTLS */ +# endif /* PHP_HTTP_HAVE_LIBCURL_OPENSSL || PHP_HTTP_HAVE_LIBCURL_GNUTLS */ # endif /* PHP_WIN32 */ -#endif /* ZTS && PHP_HTTP_HAVE_SSL */ +#endif /* ZTS && PHP_HTTP_HAVE_LIBCURL_SSL */ -#ifdef PHP_HTTP_NEED_OPENSSL_TSL +#if PHP_HTTP_NEED_OPENSSL_TSL static MUTEX_T *php_http_openssl_tsl = NULL; static void php_http_openssl_thread_lock(int mode, int n, const char * file, int line) @@ -47,7 +48,7 @@ static ulong php_http_openssl_thread_id(void) return (ulong) tsrm_thread_id(); } #endif -#ifdef PHP_HTTP_NEED_GNUTLS_TSL +#if PHP_HTTP_NEED_GNUTLS_TSL static int php_http_gnutls_mutex_create(void **m) { if (*((MUTEX_T *) m) = tsrm_mutex_alloc()) { @@ -86,7 +87,7 @@ static struct gcry_thread_cbs php_http_gnutls_tsl = { PHP_MINIT_FUNCTION(http_curl) { -#ifdef PHP_HTTP_NEED_OPENSSL_TSL +#if PHP_HTTP_NEED_OPENSSL_TSL /* mod_ssl, libpq or ext/curl might already have set thread lock callbacks */ if (!CRYPTO_get_id_callback()) { int i, c = CRYPTO_num_locks(); @@ -101,7 +102,7 @@ PHP_MINIT_FUNCTION(http_curl) CRYPTO_set_locking_callback(php_http_openssl_thread_lock); } #endif -#ifdef PHP_HTTP_NEED_GNUTLS_TSL +#if PHP_HTTP_NEED_GNUTLS_TSL gcry_control(GCRYCTL_SET_THREAD_CBS, &php_http_gnutls_tsl); #endif @@ -115,7 +116,7 @@ PHP_MINIT_FUNCTION(http_curl) PHP_MSHUTDOWN_FUNCTION(http_curl) { curl_global_cleanup(); -#ifdef PHP_HTTP_NEED_OPENSSL_TSL +#if PHP_HTTP_NEED_OPENSSL_TSL if (php_http_openssl_tsl) { int i, c = CRYPTO_num_locks(); diff --git a/src/php_http_etag.c b/src/php_http_etag.c index a02548c..c1e29c3 100644 --- a/src/php_http_etag.c +++ b/src/php_http_etag.c @@ -12,8 +12,8 @@ #include "php_http_api.h" -#ifdef PHP_HTTP_HAVE_HASH -# include "php_hash.h" +#if PHP_HTTP_HAVE_HASH +# include "ext/hash/php_hash.h" #endif #include "ext/standard/crc32.h" @@ -33,7 +33,7 @@ php_http_etag_t *php_http_etag_init(const char *mode) } else if (mode && !strcasecmp(mode, "md5")) { PHP_MD5Init(ctx = emalloc(sizeof(PHP_MD5_CTX))); } else { -#ifdef PHP_HTTP_HAVE_HASH +#if PHP_HTTP_HAVE_HASH const php_hash_ops *eho = NULL; if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) { @@ -60,7 +60,7 @@ char *php_http_etag_finish(php_http_etag_t *e) unsigned char buf[4]; *((uint *) e->ctx) = ~*((uint *) e->ctx); -#ifdef WORDS_BIGENDIAN +#if WORDS_BIGENDIAN etag = php_http_etag_digest((unsigned char *) e->ctx, 4); #else buf[0] = ((unsigned char *) e->ctx)[3]; @@ -76,7 +76,7 @@ char *php_http_etag_finish(php_http_etag_t *e) PHP_MD5Final(digest, e->ctx); etag = php_http_etag_digest(digest, 16); } else { -#ifdef PHP_HTTP_HAVE_HASH +#if PHP_HTTP_HAVE_HASH const php_hash_ops *eho = NULL; if ((eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) { @@ -106,7 +106,7 @@ size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t dat } else if ((!strcasecmp(e->mode, "md5"))) { PHP_MD5Update(e->ctx, (const unsigned char *) data_ptr, data_len); } else { -#ifdef PHP_HTTP_HAVE_HASH +#if PHP_HTTP_HAVE_HASH const php_hash_ops *eho = NULL; if ((eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) { diff --git a/src/php_http_misc.c b/src/php_http_misc.c index 23fb4b5..36e3490 100644 --- a/src/php_http_misc.c +++ b/src/php_http_misc.c @@ -19,11 +19,11 @@ void php_http_sleep(double s) { -#if defined(PHP_WIN32) +#if PHP_WIN32 Sleep((DWORD) PHP_HTTP_MSEC(s)); -#elif defined(HAVE_USLEEP) +#elif HAVE_USLEEP usleep(PHP_HTTP_USEC(s)); -#elif defined(HAVE_NANOSLEEP) +#elif HAVE_NANOSLEEP struct timespec req, rem; req.tv_sec = (time_t) s; diff --git a/src/php_http_misc.h b/src/php_http_misc.h index e8d900b..ae3359c 100644 --- a/src/php_http_misc.h +++ b/src/php_http_misc.h @@ -139,7 +139,7 @@ static inline const char *php_http_locate_bin_eol(const char *bin, size_t len, i /* ZEND */ -#ifdef PHP_DEBUG +#if PHP_DEBUG # undef HASH_OF # define HASH_OF(p) ((HashTable*)(Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p)) : NULL)))) #endif diff --git a/src/php_http_querystring.c b/src/php_http_querystring.c index 01d95f9..681d009 100644 --- a/src/php_http_querystring.c +++ b/src/php_http_querystring.c @@ -15,7 +15,7 @@ #include "php_variables.h" #include "ext/spl/spl_array.h" -#ifdef PHP_HTTP_HAVE_ICONV +#if PHP_HTTP_HAVE_ICONV # ifndef HAVE_ICONV # define HAVE_ICONV 1 # endif @@ -92,7 +92,7 @@ static inline void php_http_querystring_get(zval *instance, int type, char *name } } -#ifdef PHP_HTTP_HAVE_ICONV +#if PHP_HTTP_HAVE_ICONV ZEND_RESULT_CODE php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe) { zval *entry; @@ -534,7 +534,7 @@ PHP_HTTP_QUERYSTRING_GETTER(getString, IS_STRING); PHP_HTTP_QUERYSTRING_GETTER(getArray, IS_ARRAY); PHP_HTTP_QUERYSTRING_GETTER(getObject, IS_OBJECT); -#ifdef PHP_HTTP_HAVE_ICONV +#if PHP_HTTP_HAVE_ICONV ZEND_BEGIN_ARG_INFO_EX(ai_HttpQueryString_xlate, 0, 0, 2) ZEND_ARG_INFO(0, from_encoding) ZEND_ARG_INFO(0, to_encoding) @@ -702,7 +702,7 @@ static zend_function_entry php_http_querystring_methods[] = { PHP_ME(HttpQueryString, getIterator, ai_HttpQueryString_getIterator, ZEND_ACC_PUBLIC) PHP_ME(HttpQueryString, getGlobalInstance, ai_HttpQueryString_getGlobalInstance, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) -#ifdef PHP_HTTP_HAVE_ICONV +#if PHP_HTTP_HAVE_ICONV PHP_ME(HttpQueryString, xlate, ai_HttpQueryString_xlate, ZEND_ACC_PUBLIC) #endif diff --git a/src/php_http_querystring.h b/src/php_http_querystring.h index dc45f31..c9f284d 100644 --- a/src/php_http_querystring.h +++ b/src/php_http_querystring.h @@ -13,7 +13,7 @@ #ifndef PHP_HTTP_QUERYSTRING_H #define PHP_HTTP_QUERYSTRING_H -#ifdef PHP_HTTP_HAVE_ICONV +#if PHP_HTTP_HAVE_ICONV PHP_HTTP_API ZEND_RESULT_CODE php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe); #endif /* PHP_HTTP_HAVE_ICONV */ PHP_HTTP_API ZEND_RESULT_CODE php_http_querystring_update(zval *qarray, zval *params, zval *qstring); diff --git a/src/php_http_url.c b/src/php_http_url.c index 738cfb0..3c68996 100644 --- a/src/php_http_url.c +++ b/src/php_http_url.c @@ -21,13 +21,17 @@ #if PHP_HTTP_HAVE_LIBICU # include #endif +#if PHP_HTTP_HAVE_LIBIDNKIT || PHP_HTTP_HAVE_LIBIDNKIT2 +# include +# include +#endif -#ifdef PHP_HTTP_HAVE_WCHAR +#if PHP_HTTP_HAVE_WCHAR # include # include #endif -#ifdef HAVE_ARPA_INET_H +#if HAVE_ARPA_INET_H # include #endif @@ -37,13 +41,13 @@ static inline char *localhostname(void) { char hostname[1024] = {0}; -#ifdef PHP_WIN32 +#if PHP_WIN32 if (SUCCESS == gethostname(hostname, lenof(hostname))) { return estrdup(hostname); } -#elif defined(HAVE_GETHOSTNAME) +#elif HAVE_GETHOSTNAME if (SUCCESS == gethostname(hostname, lenof(hostname))) { -# if defined(HAVE_GETDOMAINNAME) +# if HAVE_GETDOMAINNAME size_t hlen = strlen(hostname); if (hlen <= lenof(hostname) - lenof("(none)")) { hostname[hlen++] = '.'; @@ -674,17 +678,17 @@ static size_t parse_mb_utf8(unsigned *wc, const char *ptr, const char *end) return consumed; } -#ifdef PHP_HTTP_HAVE_WCHAR +#if PHP_HTTP_HAVE_WCHAR static size_t parse_mb_loc(unsigned *wc, const char *ptr, const char *end) { wchar_t wchar; size_t consumed = 0; -#if defined(HAVE_MBRTOWC) +#if HAVE_MBRTOWC mbstate_t ps; memset(&ps, 0, sizeof(ps)); consumed = mbrtowc(&wchar, ptr, end - ptr, &ps); -#elif defined(HAVE_MBTOWC) +#elif HAVE_MBTOWC consumed = mbtowc(&wchar, ptr, end - ptr); #endif @@ -727,7 +731,7 @@ static size_t parse_mb(struct parse_state *state, parse_mb_what_t what, const ch if (state->flags & PHP_HTTP_URL_PARSE_MBUTF8) { consumed = parse_mb_utf8(&wchar, ptr, end); } -#ifdef PHP_HTTP_HAVE_WCHAR +#if PHP_HTTP_HAVE_WCHAR else if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) { consumed = parse_mb_loc(&wchar, ptr, end); } @@ -741,7 +745,7 @@ static size_t parse_mb(struct parse_state *state, parse_mb_what_t what, const ch if (!isualnum(wchar)) { break; } -#ifdef PHP_HTTP_HAVE_WCHAR +#if PHP_HTTP_HAVE_WCHAR } else if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) { if (!iswalnum(wchar)) { break; @@ -858,7 +862,7 @@ static ZEND_RESULT_CODE parse_userinfo(struct parse_state *state, const char *pt return SUCCESS; } -#if defined(PHP_WIN32) || defined(HAVE_UIDNA_IDNTOASCII) +#if PHP_WIN32 || HAVE_UIDNA_IDNTOASCII typedef size_t (*parse_mb_func)(unsigned *wc, const char *ptr, const char *end); static ZEND_RESULT_CODE to_utf16(parse_mb_func fn, const char *u8, uint16_t **u16, size_t *len) { @@ -899,11 +903,10 @@ static ZEND_RESULT_CODE to_utf16(parse_mb_func fn, const char *u8, uint16_t **u1 } #endif -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 256 -#endif - #if PHP_HTTP_HAVE_LIBIDN2 +# if __GNUC__ +__attribute__ ((unused)) +# endif static ZEND_RESULT_CODE parse_gidn_2008(struct parse_state *state, size_t prev_len) { char *idn = NULL; @@ -912,7 +915,7 @@ static ZEND_RESULT_CODE parse_gidn_2008(struct parse_state *state, size_t prev_l if (state->flags & PHP_HTTP_URL_PARSE_MBUTF8) { rv = idn2_lookup_u8((const unsigned char *) state->url.host, (unsigned char **) &idn, IDN2_NFC_INPUT); } -# ifdef PHP_HTTP_HAVE_WCHAR +# if PHP_HTTP_HAVE_WCHAR else if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) { rv = idn2_lookup_ul(state->url.host, &idn, 0); } @@ -935,6 +938,9 @@ static ZEND_RESULT_CODE parse_gidn_2008(struct parse_state *state, size_t prev_l #endif #if PHP_HTTP_HAVE_LIBIDN +# if __GNUC__ +__attribute__ ((unused)) +# endif static ZEND_RESULT_CODE parse_gidn_2003(struct parse_state *state, size_t prev_len) { char *idn = NULL; @@ -943,7 +949,7 @@ static ZEND_RESULT_CODE parse_gidn_2003(struct parse_state *state, size_t prev_l if (state->flags & PHP_HTTP_URL_PARSE_MBUTF8) { rv = idna_to_ascii_8z(state->url.host, &idn, IDNA_ALLOW_UNASSIGNED|IDNA_USE_STD3_ASCII_RULES); } -# ifdef PHP_HTTP_HAVE_WCHAR +# if PHP_HTTP_HAVE_WCHAR else if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) { rv = idna_to_ascii_lz(state->url.host, &idn, IDNA_ALLOW_UNASSIGNED|IDNA_USE_STD3_ASCII_RULES); } @@ -965,7 +971,7 @@ static ZEND_RESULT_CODE parse_gidn_2003(struct parse_state *state, size_t prev_l } #endif -#ifdef HAVE_UIDNA_IDNTOASCII +#if HAVE_UIDNA_IDNTOASCII # if PHP_HTTP_HAVE_LIBICU # include # else @@ -976,7 +982,7 @@ int32_t uidna_IDNToASCII(const UChar *src, int32_t srcLength, UChar *dest, int32 static ZEND_RESULT_CODE parse_uidn_2003(struct parse_state *state) { char *host_ptr = state->url.host, ebuf[64] = {0}, *error = NULL; - uint16_t *uhost_str, ahost_str[MAXHOSTNAMELEN], *ahost_ptr; + uint16_t *uhost_str, ahost_str[256], *ahost_ptr; size_t uhost_len, ahost_len; UErrorCode rc = U_ZERO_ERROR; @@ -985,7 +991,7 @@ static ZEND_RESULT_CODE parse_uidn_2003(struct parse_state *state) error = "failed to convert to UTF-16"; goto error; } -#ifdef PHP_HTTP_HAVE_WCHAR +#if PHP_HTTP_HAVE_WCHAR } else if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) { if (SUCCESS != to_utf16(parse_mb_loc, state->url.host, &uhost_str, &uhost_len)) { error = "failed to convert to UTF-16"; @@ -997,9 +1003,15 @@ static ZEND_RESULT_CODE parse_uidn_2003(struct parse_state *state) goto error; } - ahost_len = uidna_IDNToASCII(uhost_str, uhost_len, ahost_str, MAXHOSTNAMELEN, 3, NULL, &rc); - efree(uhost_str); +# if __GNUC__ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# endif + ahost_len = uidna_IDNToASCII(uhost_str, uhost_len, ahost_str, 256, 3, NULL, &rc); +# if __GNUC__ +# pragma GCC diagnostic pop +# endif + efree(uhost_str); if (error > U_ZERO_ERROR) { goto error; } @@ -1022,7 +1034,7 @@ static ZEND_RESULT_CODE parse_uidn_2003(struct parse_state *state) } #endif -#ifdef HAVE_UIDNA_IDNTOASCII +#if HAVE_UIDNA_IDNTOASCII # if PHP_HTTP_HAVE_LIBICU # include # endif @@ -1040,16 +1052,16 @@ static ZEND_RESULT_CODE parse_uidn_2008(struct parse_state *state) host_ptr = state->url.host; if (state->flags & PHP_HTTP_URL_PARSE_MBUTF8) { - char ahost_str[MAXHOSTNAMELEN], *ahost_ptr = &ahost_str[0]; + char ahost_str[256], *ahost_ptr = &ahost_str[0]; size_t ahost_len = uidna_nameToASCII_UTF8(uidna, host_ptr, -1, ahost_str, sizeof(ahost_str)-1, &info, &rc); if (U_FAILURE(rc) || info.errors) { goto error; } PHP_HTTP_DUFF(ahost_len, *host_ptr++ = *ahost_ptr++); -#ifdef PHP_HTTP_HAVE_WCHAR +#if PHP_HTTP_HAVE_WCHAR } else if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) { - uint16_t *uhost_str, whost_str[MAXHOSTNAMELEN], *whost_ptr = &whost_str[0]; + uint16_t *uhost_str, whost_str[256], *whost_ptr = &whost_str[0]; size_t uhost_len, whost_len; if (SUCCESS != to_utf16(parse_mb_loc, host_ptr, &uhost_str, &uhost_len)) { @@ -1059,6 +1071,7 @@ static ZEND_RESULT_CODE parse_uidn_2008(struct parse_state *state) whost_len = uidna_nameToASCII(uidna, uhost_str, uhost_len, whost_str, sizeof(whost_str)-1, &info, &rc); whost_ptr = whost_str; + efree(uhost_str); if (U_FAILURE(rc) || info.errors) { goto error; } @@ -1094,11 +1107,48 @@ static ZEND_RESULT_CODE parse_uidn_2008(struct parse_state *state) } #endif -#if 0 && defined(PHP_WIN32) +#if PHP_HTTP_HAVE_LIBIDNKIT || PHP_HTTP_HAVE_LIBIDNKIT2 +# if __GNUC__ +__attribute__ ((unused)) +# endif +static ZEND_RESULT_CODE parse_kidn(struct parse_state *state) +{ + idn_result_t rc; +#if PHP_HTTP_HAVE_LIBIDNKIT + int actions = IDN_DELIMMAP|IDN_LOCALMAP|IDN_NAMEPREP|IDN_IDNCONV|IDN_LENCHECK; +#elif PHP_HTTP_HAVE_LIBIDNKIT2 + int actions = IDN_MAP|IDN_ASCLOWER|IDN_RTCONV|IDN_PROHCHECK|IDN_NFCCHECK|IDN_PREFCHECK|IDN_COMBCHECK|IDN_CTXOLITECHECK|IDN_BIDICHECK|IDN_LOCALCHECK|IDN_IDNCONV|IDN_LENCHECK|IDN_RTCHECK; +#endif + char ahost_str[256] = {0}, *ahost_ptr = &ahost_str[0], *host_ptr = state->url.host; + + if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) { +#if PHP_HTTP_HAVE_LIBIDNKIT + actions |= IDN_LOCALCONV; +#elif PHP_HTTP_HAVE_LIBIDNKIT2 + actions |= IDN_UNICODECONV; +#endif + } + + rc = idn_encodename(actions, state->url.host, ahost_str, 256); + if (rc == idn_success) { + PHP_HTTP_DUFF(strlen(ahost_str), *host_ptr++ = *ahost_ptr++); + + *host_ptr = '\0'; + state->offset += host_ptr - state->url.host; + + return SUCCESS; + } else { + php_error_docref(NULL, E_WARNING, "Failed to parse IDN; %s", idn_result_tostring(rc)); + return FAILURE; + } +} +#endif + +#if 0 && PHP_WIN32 static ZEND_RESULT_CODE parse_widn_2003(struct parse_state *state) { char *host_ptr; - uint16_t *uhost_str, ahost_str[MAXHOSTNAMELEN], *ahost_ptr; + uint16_t *uhost_str, ahost_str[256], *ahost_ptr; size_t uhost_len; if (state->flags & PHP_HTTP_URL_PARSE_MBUTF8) { @@ -1106,7 +1156,7 @@ static ZEND_RESULT_CODE parse_widn_2003(struct parse_state *state) php_error_docref(NULL, E_WARNING, "Failed to parse IDN"); return FAILURE; } -#ifdef PHP_HTTP_HAVE_WCHAR +#if PHP_HTTP_HAVE_WCHAR } else if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) { if (SUCCESS != to_utf16(parse_mb_loc, state->url.host, &uhost_str, &uhost_len)) { php_error_docref(NULL, E_WARNING, "Failed to parse IDN"); @@ -1118,7 +1168,7 @@ static ZEND_RESULT_CODE parse_widn_2003(struct parse_state *state) return FAILURE; } - if (!IdnToAscii(IDN_ALLOW_UNASSIGNED|IDN_USE_STD3_ASCII_RULES, uhost_str, uhost_len, ahost_str, MAXHOSTNAMELEN)) { + if (!IdnToAscii(IDN_ALLOW_UNASSIGNED, uhost_str, uhost_len, ahost_str, 256)) { efree(uhost_str); php_error_docref(NULL, E_WARNING, "Failed to parse IDN"); return FAILURE; @@ -1128,7 +1178,6 @@ static ZEND_RESULT_CODE parse_widn_2003(struct parse_state *state) host_ptr = state->url.host; ahost_ptr = ahost_str; PHP_HTTP_DUFF(wcslen(ahost_str), *host_ptr++ = *ahost_ptr++); - efree(ahost_str); *host_ptr = '\0'; state->offset += host_ptr - state->url.host; @@ -1139,27 +1188,39 @@ static ZEND_RESULT_CODE parse_widn_2003(struct parse_state *state) static ZEND_RESULT_CODE parse_idna(struct parse_state *state, size_t len) { +#if PHP_HTTP_HAVE_IDNA2008 if ((state->flags & PHP_HTTP_URL_PARSE_TOIDN_2008) +# if PHP_HTTP_HAVE_IDNA2003 || !(state->flags & PHP_HTTP_URL_PARSE_TOIDN_2003) +# endif ) { #if HAVE_UIDNA_NAMETOASCII_UTF8 return parse_uidn_2008(state); #elif PHP_HTTP_HAVE_LIBIDN2 return parse_gidn_2008(state, len); +#elif PHP_HTTP_HAVE_LIBIDNKIT2 + return parse_kidn(state); #endif } +#endif +#if PHP_HTTP_HAVE_IDNA2003 if ((state->flags & PHP_HTTP_URL_PARSE_TOIDN_2003) +# if PHP_HTTP_HAVE_IDNA2008 || !(state->flags & PHP_HTTP_URL_PARSE_TOIDN_2008) +#endif ) { #if HAVE_UIDNA_IDNTOASCII return parse_uidn_2003(state); #elif PHP_HTTP_HAVE_LIBIDN return parse_gidn_2003(state, len); +#elif PHP_HTTP_HAVE_LIBIDNKIT + return parse_kidn(state); #endif } +#endif -#if 0 && defined(PHP_WIN32) +#if 0 && PHP_WIN32 return parse_widn_2003(state); #endif @@ -1167,16 +1228,20 @@ static ZEND_RESULT_CODE parse_idna(struct parse_state *state, size_t len) return parse_uidn_2008(state); #elif PHP_HTTP_HAVE_LIBIDN2 return parse_gidn_2008(state, len); +#elif PHP_HTTP_HAVE_LIBIDNKIT2 + return parse_kidn(state); #elif HAVE_UIDNA_IDNTOASCII return parse_uidn_2003(state); #elif PHP_HTTP_HAVE_LIBIDN return parse_gidn_2003(state, len); +#elif PHP_HTTP_HAVE_LIBIDNKIT + return parse_kidn(state); #endif return SUCCESS; } -#ifdef HAVE_INET_PTON +#if HAVE_INET_PTON static const char *parse_ip6(struct parse_state *state, const char *ptr) { unsigned pos = 0; @@ -1223,7 +1288,7 @@ static ZEND_RESULT_CODE parse_hostinfo(struct parse_state *state, const char *pt size_t mb, len = state->offset; const char *end = state->ptr, *tmp = ptr, *port = NULL, *label = NULL; -#ifdef HAVE_INET_PTON +#if HAVE_INET_PTON if (*ptr == '[' && !(ptr = parse_ip6(state, ptr))) { if (!(state->flags & PHP_HTTP_URL_IGNORE_ERRORS)) { return FAILURE; @@ -1995,11 +2060,11 @@ PHP_MINIT_FUNCTION(http_url) zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("FROM_ENV"), PHP_HTTP_URL_FROM_ENV); zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("SANITIZE_PATH"), PHP_HTTP_URL_SANITIZE_PATH); -#ifdef PHP_HTTP_HAVE_WCHAR +#if PHP_HTTP_HAVE_WCHAR zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_MBLOC"), PHP_HTTP_URL_PARSE_MBLOC); #endif zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_MBUTF8"), PHP_HTTP_URL_PARSE_MBUTF8); -#if PHP_HTTP_HAVE_LIBIDN2 || PHP_HTTP_HAVE_LIBIDN || HAVE_UIDNA_IDNTOASCII || HAVE_UIDNA_NAMETOASCII_UTF8 +#if PHP_HTTP_HAVE_LIBIDN2 || PHP_HTTP_HAVE_LIBIDN || PHP_HTTP_HAVE_LIBIDNKIT || PHP_HTTP_HAVE_LIBIDNKIT2 || HAVE_UIDNA_IDNTOASCII || HAVE_UIDNA_NAMETOASCII_UTF8 zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_TOIDN"), PHP_HTTP_URL_PARSE_TOIDN); # if PHP_HTTP_HAVE_IDNA2003 zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_TOIDN_2003"), PHP_HTTP_URL_PARSE_TOIDN_2003); diff --git a/tests/bug66388.phpt b/tests/bug66388.phpt index 77d50c7..97f8419 100644 --- a/tests/bug66388.phpt +++ b/tests/bug66388.phpt @@ -3,6 +3,7 @@ Bug #66388 (Crash on POST with Content-Length:0 and untouched body) --SKIPIF-- --FILE-- diff --git a/tests/client025.phpt b/tests/client025.phpt index 62f0342..4cb63af 100644 --- a/tests/client025.phpt +++ b/tests/client025.phpt @@ -3,6 +3,7 @@ client seek --SKIPIF-- --FILE-- --FILE-- + --FILE-- --FILE-- @@ -22,7 +21,7 @@ $urls = array( foreach ($urls as $url) { printf("\n%s\n", $url); - var_dump(new http\Url($url, null, http\Url::PARSE_MBLOC|http\Url::PARSE_TOIDN|http\Url::PARSE_TOIDN_2003)); + var_dump(new http\Url($url, null, http\Url::PARSE_MBLOC|http\Url::PARSE_TOIDN_2003)); } ?> DONE diff --git a/tests/urlparser007.phpt b/tests/urlparser007.phpt index c175545..e2cb309 100644 --- a/tests/urlparser007.phpt +++ b/tests/urlparser007.phpt @@ -3,8 +3,8 @@ url parser multibyte/utf-8/idna --SKIPIF-- --FILE-- @@ -19,7 +19,7 @@ $urls = array( foreach ($urls as $url) { printf("\n%s\n", $url); - var_dump(new http\Url($url, null, http\Url::PARSE_MBUTF8|http\Url::PARSE_TOIDN|http\Url::PARSE_TOIDN_2003)); + var_dump(new http\Url($url, null, http\Url::PARSE_MBUTF8|http\Url::PARSE_TOIDN_2003)); } ?> DONE diff --git a/tests/urlparser012.phpt b/tests/urlparser012.phpt new file mode 100644 index 0000000..2187222 --- /dev/null +++ b/tests/urlparser012.phpt @@ -0,0 +1,46 @@ +--TEST-- +url parser multibyte/locale/topct +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +Test +object(http\Url)#%d (8) { + ["scheme"]=> + string(4) "http" + ["user"]=> + string(4) "mike" + ["pass"]=> + string(12) "pa%C3%9Fwort" + ["host"]=> + string(13) "xn--097ccd.it" + ["port"]=> + NULL + ["path"]=> + string(15) "/for/%E2%82%AC/" + ["query"]=> + string(9) "by=%C2%A2" + ["fragment"]=> + string(6) "%C3%B8" +} +DONE diff --git a/tests/urlparser013.phpt b/tests/urlparser013.phpt new file mode 100644 index 0000000..53889dd --- /dev/null +++ b/tests/urlparser013.phpt @@ -0,0 +1,43 @@ +--TEST-- +url parser multibyte/utf-8/topct +--SKIPIF-- + +--FILE-- + +DONE +--EXPECTF-- +Test +object(http\Url)#%d (8) { + ["scheme"]=> + string(4) "http" + ["user"]=> + string(4) "mike" + ["pass"]=> + string(12) "pa%C3%9Fwort" + ["host"]=> + string(13) "xn--097ccd.it" + ["port"]=> + NULL + ["path"]=> + string(15) "/for/%E2%82%AC/" + ["query"]=> + string(9) "by=%C2%A2" + ["fragment"]=> + string(6) "%C3%B8" +} +DONE -- 2.30.2