[ --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
])
])
+ if test -z "$PKG_CONFIG"; then
+ AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
+ fi
+
AC_PROG_CPP
if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
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
+ 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
dnl IDN
dnl ----
- AC_MSG_CHECKING([for idna.h])
- IDNA_DIR=
- for i in "$PHP_HTTP_LIBIDN_DIR" "$IDN_DIR" /usr/local /usr /opt; do
- if test -f "$i/include/idna.h"; then
- IDNA_DIR=$i
- break;
- fi
- done
- if test "x$IDNA_DIR" != "x"; then
- AC_MSG_RESULT([found in $IDNA_DIR])
- AC_DEFINE([PHP_HTTP_HAVE_IDN], [1], [Have libidn support])
- PHP_ADD_INCLUDE($IDNA_DIR/include)
- PHP_ADD_LIBRARY_WITH_PATH(idn, $IDNA_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
- AC_MSG_CHECKING([for libidn version])
- IDNA_VER=$(pkg-config --version libidn 2>/dev/null || echo unknown)
- AC_MSG_RESULT([$IDNA_VER])
- AC_DEFINE_UNQUOTED([PHP_HTTP_LIBIDN_VERSION], "$IDNA_VER", [ ])
- else
- AC_MSG_RESULT([not found])
- AC_MSG_CHECKING([for idn2.h])
- IDNA_DIR=
- for i in "$PHP_HTTP_LIBIDN_DIR" "$IDN_DIR" /usr/local /usr /opt; do
- if test -f "$i/include/idn2.h"; then
- IDNA_DIR=$i
- break;
- fi
- done
- if test "x$IDNA_DIR" != "x"; then
- AC_MSG_RESULT([found in $IDNA_DIR])
- AC_DEFINE([PHP_HTTP_HAVE_IDN2], [1], [Have libidn2 support])
- PHP_ADD_INCLUDE($IDNA_DIR/include)
- PHP_ADD_LIBRARY_WITH_PATH(idn2, $IDNA_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
- AC_MSG_CHECKING([for libidn2 version])
- IDNA_VER=`$EGREP "define IDN2_VERSION " $IDNA_DIR/include/idn2.h | $SED -e's/^.*VERSION //g' -e 's/[[^0-9\.]]//g'`
- AC_MSG_RESULT([$IDNA_VER])
- AC_DEFINE_UNQUOTED([PHP_HTTP_LIBIDN2_VERSION], "$IDNA_VER", [ ])
- else
- AC_MSG_RESULT([not found])
- AC_CHECK_HEADERS([unicode/uidna.h])
- case $host_os in
- darwin*)
- PHP_CHECK_FUNC(uidna_IDNToASCII, icucore);;
- *)
- AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
- if test ! -x "$ICU_CONFIG"; then
- ICU_CONFIG="icu-config"
- fi
- AC_MSG_CHECKING([for uidna_IDNToASCII])
- if ! test -x "$ICU_CONFIG"; then
- ICU_CONFIG=icu-config
- fi
- if $ICU_CONFIG --exists 2>/dev/null >&2; then
- save_LIBS=$LIBS
- LIBS=$($ICU_CONFIG --ldflags)
- AC_TRY_RUN([
- #include <unicode/uidna.h>
- int main(int argc, char *argv[]) {
- return uidna_IDNToASCII(0, 0, 0, 0, 0, 0, 0);
- }
- ], [
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_UIDNA_IDNTOASCII], [1], [ ])
- LIBS=$save_LIBS
- PHP_EVAL_LIBLINE(`$ICU_CONFIG --ldflags`, HTTP_SHARED_LIBADD)
- ], [
- LIBS=$save_LIBS
- AC_MSG_RESULT([no])
- ])
- fi
- ;;
- esac
- fi
+ HTTP_CHECK_PKGCONFIG(libidn, [$PHP_HTTP_LIBIDN_DIR])
+ if $PHP_HTTP_HAVE_LIBIDN; then
+ AC_DEFINE([PHP_HTTP_HAVE_IDNA2003], [1], [ ])
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], [ ])
+ fi
+ HTTP_CHECK_DONE(libidn2, test -n "$PHP_HTTP_LIBIDN2_VERSION")
+
+ case $host_os in
+ darwin*)
+ PHP_CHECK_FUNC(uidna_IDNToASCII, icucore)
+ ;;
+ *)
+ 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 <unicode/uidna.h>
+ ], [
+ 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 <unicode/uidna.h>
+ ], [
+ 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 ----
- AC_MSG_CHECKING([for zlib.h])
- ZLIB_DIR=
- for i in "$PHP_HTTP_ZLIB_DIR" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
- if test -f "$i/include/zlib.h"; then
- ZLIB_DIR=$i
- break;
- fi
- done
- if test "x$ZLIB_DIR" = "x"; then
- AC_MSG_RESULT([not found])
- AC_MSG_ERROR([could not find zlib.h])
- else
- AC_MSG_RESULT([found in $ZLIB_DIR])
- AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
- ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
- AC_MSG_RESULT([$ZLIB_VERSION])
- if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
- AC_MSG_ERROR([zlib version greater or equal to 1.2.0.4 required])
- else
- PHP_ADD_INCLUDE($ZLIB_DIR/include)
- PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
- fi
- fi
+ 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 ----
- if test "$PHP_HTTP_LIBCURL_DIR" = "no"; then
- AC_DEFINE([PHP_HTTP_HAVE_CURL], [0], [ ])
- else
- AC_MSG_CHECKING([for curl/curl.h])
- CURL_DIR=
- for i in "$PHP_HTTP_LIBCURL_DIR" /usr/local /usr /opt; do
- if test -f "$i/include/curl/curl.h"; then
- CURL_DIR=$i
- break
- fi
- done
- if test "x$CURL_DIR" = "x"; then
- AC_MSG_RESULT([not found])
- else
- AC_MSG_RESULT([found in $CURL_DIR])
+ AC_PATH_PROG([CURL_CONFIG], [curl-config], false, [$PHP_HTTP_LIBCURL_DIR/bin:$PATH:/usr/local/bin])
- AC_MSG_CHECKING([for curl-config])
- CURL_CONFIG=
- for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
- if test -x "$i"; then
- CURL_CONFIG=$i
- break
- fi
- done
- if test "x$CURL_CONFIG" = "x"; then
- AC_MSG_RESULT([not found])
- AC_MSG_ERROR([could not find curl-config])
- else
- AC_MSG_RESULT([found: $CURL_CONFIG])
- fi
+ 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)
- dnl RHEL6: 7.19.7
- dnl SUSE11: 7.19.7
- dnl Debian wheezy: 7.26.0
- dnl Debian sqeeze: 7.21.0
- dnl Debian ancient 7.18.2
- AC_MSG_CHECKING([for curl version >= 7.18.2])
- CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
- AC_MSG_RESULT([$CURL_VERSION])
- if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71802; then
- AC_MSG_ERROR([libcurl version greater or equal to 7.18.2 required])
- fi
+ 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 HTTP2 support in libcurl])
- if $CURL_CONFIG --features | $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], [ ])
- dnl
- dnl compile tests
- dnl
-
- save_INCLUDES="$INCLUDES"
- INCLUDES=
- save_LIBS="$LIBS"
- LIBS=-lcurl
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS `$CURL_CONFIG --cflags`"
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
-
- AC_MSG_CHECKING([for SSL support in libcurl])
- CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
- CURL_SSL_LIBS=""
- if test "$CURL_SSL" = "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], [ ])
- CURL_SSL_LIBS="ssl crypto"
- ])
+ 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], [ ])
- CURL_SSL_LIBS="gnutls gcrypt"
- ])
+ ])
+ 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], [ ])
- ])
- else
- dnl no CURL_SSL
- AC_MSG_RESULT([no])
- fi
+ ])
+ 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], [ ])
+ ])
+ else
+ dnl no CURL_SSL
+ AC_MSG_RESULT([no])
+ fi
- AC_MSG_CHECKING([for ares support in libcurl])
- AC_TRY_RUN([
- #include <curl/curl.h>
- 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_CHECKING([for ares support in libcurl])
+ AC_TRY_RUN([
+ #include <curl/curl.h>
+ 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;
}
- ], [
- AC_MSG_RESULT([yes])
- AC_DEFINE([PHP_HTTP_HAVE_ARES], [1], [ ])
- ], [
- AC_MSG_RESULT([no])
- ], [
- AC_MSG_RESULT([no])
- ])
+ return 1;
+ }
+ ], [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([PHP_HTTP_HAVE_ARES], [1], [ ])
+ ], [
+ AC_MSG_RESULT([no])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
- AC_MSG_CHECKING([whether CURLOPT_TLSAUTH_TYPE expects CURL_TLSAUTH_SRP or literal "SRP"])
+ AC_MSG_CHECKING([whether CURLOPT_TLSAUTH_TYPE expects CURL_TLSAUTH_SRP or literal "SRP"])
+ AC_TRY_RUN([
+ #include <curl/curl.h>
+ 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 <curl/curl.h>
int main(int argc, char *argv[]) {
CURL *ch = curl_easy_init();
- return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, CURL_TLSAUTH_SRP);
+ return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, "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_MSG_RESULT(["SRP"])
+ AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_SRP], ["SRP"], [ ])
+ AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_DEF], [""], [ ])
], [
- AC_TRY_RUN([
- #include <curl/curl.h>
- int main(int argc, char *argv[]) {
- CURL *ch = curl_easy_init();
- return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, "SRP");
- }
- ], [
- AC_MSG_RESULT(["SRP"])
- AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_SRP], ["SRP"], [ ])
- AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_DEF], [""], [ ])
- ], [
- AC_MSG_RESULT([neither])
- ], [
- AC_MSG_RESULT([neither])
- ])
+ AC_MSG_RESULT([neither])
], [
AC_MSG_RESULT([neither])
])
+ ], [
+ AC_MSG_RESULT([neither])
+ ])
- INCLUDES="$save_INCLUDES"
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
- LDFLAGS="$save_LDFLAGS"
-
- if test -n "$CURL_SSL_LIBS"; then
- for CURL_SSL_LIB in $CURL_SSL_LIBS; do
- PHP_ADD_LIBRARY_WITH_PATH([$CURL_SSL_LIB], $CURL_DIR/$PHP_LIBDIR, PHP_HTTP_SHARED_LIBADD)
- done
- fi
-
- dnl end compile tests
-
- 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/.*=//')
- 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"
+ 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/.*=//')
+ 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
- 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])
- else
- AC_MSG_RESULT([none])
+ elif test -z "$CURL_CA_INFO" && test -f "$i"; then
+ CURL_CA_INFO="$i"
fi
-
- PHP_ADD_INCLUDE($CURL_DIR/include)
- PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
- PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
- AC_DEFINE([PHP_HTTP_HAVE_CURL], [1], [Have libcurl support])
- HTTP_HAVE_A_REQUEST_LIB=true
+ 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])
+ else
+ AC_MSG_RESULT([none])
fi
+
+ HTTP_HAVE_A_REQUEST_LIB=true
fi
+ HTTP_CHECK_DONE(libcurl, test -n "$PHP_HTTP_LIBCURL_VERSION")
dnl ----
dnl EVENT
dnl ----
- if test "$PHP_HTTP_LIBEVENT_DIR" = "no"; then
- AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
- else
- AC_MSG_CHECKING([for event2/event.h])
- EVENT_DIR=
- for i in "$PHP_HTTP_LIBEVENT_DIR" /usr/local /usr /opt; do
- if test -f "$i/include/event.h"; then
- EVENT_DIR=$i
- break
- fi
- done
- if test "x$EVENT_DIR" = "x"; then
- AC_MSG_RESULT([not found])
- AC_MSG_WARN([continuing without libevent support])
- AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
- else
- AC_MSG_RESULT([found in $EVENT_DIR])
-
- AC_MSG_CHECKING([for libevent version, roughly])
-
- if test -f "$EVENT_DIR/include/event2/event.h"; then
- EVENT_VER="`$AWK '/_EVENT_VERSION/ {gsub(/\"/,\"\",$3); print $3}' < $EVENT_DIR/include/event2/event-config.h`"
- AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [1], [ ])
- else
- AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [0], [ ])
- if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
- if test -f "$EVENT_DIR/include/evrpc.h"; then
- EVENT_VER="1.4 or greater"
- else
- EVENT_VER="1.2 or greater"
- fi
- else
- EVENT_VER="1.1b or lower"
- fi
- fi
- AC_DEFINE_UNQUOTED([PHP_HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
- AC_MSG_RESULT([$EVENT_VER])
-
- PHP_ADD_INCLUDE($EVENT_DIR/include)
- PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
- AC_DEFINE([PHP_HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
- fi
- fi
+ 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
#include "php_http_api.h"
-#if PHP_HTTP_HAVE_IDN2
+#if PHP_HTTP_HAVE_LIBIDN2
# include <idn2.h>
-#elif PHP_HTTP_HAVE_IDN
+#endif
+#if PHP_HTTP_HAVE_LIBIDN
# include <idna.h>
#endif
+#if PHP_HTTP_HAVE_LIBICU
+# include <unicode/uidna.h>
+#endif
#ifdef PHP_HTTP_HAVE_WCHAR
# include <wchar.h>
# define MAXHOSTNAMELEN 256
#endif
-#if PHP_HTTP_HAVE_IDN2
-static ZEND_RESULT_CODE parse_idn2(struct parse_state *state, size_t prev_len)
+#if PHP_HTTP_HAVE_LIBIDN2
+static ZEND_RESULT_CODE parse_gidn_2008(struct parse_state *state, size_t prev_len)
{
char *idn = NULL;
int rv = -1;
# endif
if (rv != IDN2_OK) {
if (!(state->flags & PHP_HTTP_URL_SILENT_ERRORS)) {
- php_error_docref(NULL, E_WARNING, "Failed to parse IDN; %s", idn2_strerror(rv));
+ php_error_docref(NULL, E_WARNING, "Failed to parse IDN (IDNA2008); %s", idn2_strerror(rv));
}
if (!(state->flags & PHP_HTTP_URL_IGNORE_ERRORS)) {
return FAILURE;
}
return SUCCESS;
}
-#elif PHP_HTTP_HAVE_IDN
-static ZEND_RESULT_CODE parse_idn(struct parse_state *state, size_t prev_len)
+#endif
+
+#if PHP_HTTP_HAVE_LIBIDN
+static ZEND_RESULT_CODE parse_gidn_2003(struct parse_state *state, size_t prev_len)
{
char *idn = NULL;
int rv = -1;
# endif
if (rv != IDNA_SUCCESS) {
if (!(state->flags & PHP_HTTP_URL_SILENT_ERRORS)) {
- php_error_docref(NULL, E_WARNING, "Failed to parse IDN; %s", idna_strerror(rv));
+ php_error_docref(NULL, E_WARNING, "Failed to parse IDN (IDNA2003); %s", idna_strerror(rv));
}
if (!(state->flags & PHP_HTTP_URL_IGNORE_ERRORS)) {
return FAILURE;
#endif
#ifdef HAVE_UIDNA_IDNTOASCII
-# if HAVE_UNICODE_UIDNA_H
+# if PHP_HTTP_HAVE_LIBICU
# include <unicode/uidna.h>
# else
typedef uint16_t UChar;
typedef enum { U_ZERO_ERROR = 0 } UErrorCode;
int32_t uidna_IDNToASCII(const UChar *src, int32_t srcLength, UChar *dest, int32_t destCapacity, int32_t options, void *parseError, UErrorCode *status);
# endif
-static ZEND_RESULT_CODE parse_uidn(struct parse_state *state)
+static ZEND_RESULT_CODE parse_uidn_2003(struct parse_state *state)
{
- char *host_ptr;
+ char *host_ptr = state->url.host, ebuf[64] = {0}, *error = NULL;
uint16_t *uhost_str, ahost_str[MAXHOSTNAMELEN], *ahost_ptr;
size_t uhost_len, ahost_len;
- UErrorCode error = U_ZERO_ERROR;
+ UErrorCode rc = U_ZERO_ERROR;
if (state->flags & PHP_HTTP_URL_PARSE_MBUTF8) {
if (SUCCESS != to_utf16(parse_mb_utf8, state->url.host, &uhost_str, &uhost_len)) {
- return FAILURE;
+ error = "failed to convert to UTF-16";
+ goto error;
}
#ifdef 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)) {
- return FAILURE;
+ error = "failed to convert to UTF-16";
+ goto error;
}
#endif
} else {
- php_error_docref(NULL, E_WARNING, "Failed to parse IDN; codepage not specified");
- return FAILURE;
+ error = "codepage not specified";
+ goto error;
}
- ahost_len = uidna_IDNToASCII(uhost_str, uhost_len, ahost_str, MAXHOSTNAMELEN, 3, NULL, &error);
+ ahost_len = uidna_IDNToASCII(uhost_str, uhost_len, ahost_str, MAXHOSTNAMELEN, 3, NULL, &rc);
efree(uhost_str);
- if (error != U_ZERO_ERROR) {
- php_error_docref(NULL, E_WARNING, "Failed to parse IDN; ICU error %d", error);
- return FAILURE;
+ if (error > U_ZERO_ERROR) {
+ goto error;
}
- host_ptr = state->url.host;
ahost_ptr = ahost_str;
PHP_HTTP_DUFF(ahost_len, *host_ptr++ = *ahost_ptr++);
+ *host_ptr = '\0';
+ state->offset += host_ptr - state->url.host;
+
+ return SUCCESS;
+
+ error:
+ if (!error) {
+ slprintf(ebuf, sizeof(ebuf)-1, "errorcode: %d", rc);
+ error = ebuf;
+ }
+ php_error_docref(NULL, E_WARNING, "Failed to parse IDN (ICU IDNA2003); %s", error);
+
+ return FAILURE;
+}
+#endif
+
+#ifdef HAVE_UIDNA_IDNTOASCII
+# if PHP_HTTP_HAVE_LIBICU
+# include <unicode/uidna.h>
+# endif
+static ZEND_RESULT_CODE parse_uidn_2008(struct parse_state *state)
+{
+ char *host_ptr, *error = NULL, ebuf[64] = {0};
+ UErrorCode rc = U_ZERO_ERROR;
+ UIDNAInfo info = UIDNA_INFO_INITIALIZER;
+ UIDNA *uidna = uidna_openUTS46(UIDNA_ALLOW_UNASSIGNED|UIDNA_USE_STD3_RULES, &rc);
+
+ if (!uidna || U_FAILURE(rc)) {
+ return FAILURE;
+ }
+
+ host_ptr = state->url.host;
+
+ if (state->flags & PHP_HTTP_URL_PARSE_MBUTF8) {
+ char ahost_str[MAXHOSTNAMELEN], *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
+ } else if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) {
+ uint16_t *uhost_str, whost_str[MAXHOSTNAMELEN], *whost_ptr = &whost_str[0];
+ size_t uhost_len, whost_len;
+
+ if (SUCCESS != to_utf16(parse_mb_loc, host_ptr, &uhost_str, &uhost_len)) {
+ error = "could not convert to UTF-16";
+ goto error;
+ }
+
+ whost_len = uidna_nameToASCII(uidna, uhost_str, uhost_len, whost_str, sizeof(whost_str)-1, &info, &rc);
+ whost_ptr = whost_str;
+ if (U_FAILURE(rc) || info.errors) {
+ goto error;
+ }
+ PHP_HTTP_DUFF(whost_len, *host_ptr++ = *whost_ptr++);
+#endif
+ } else {
+ error = "codepage not specified";
+ goto error;
+ }
*host_ptr = '\0';
state->offset += host_ptr - state->url.host;
+ uidna_close(uidna);
return SUCCESS;
+
+ error:
+ if (!error) {
+ if (U_FAILURE(rc)) {
+ slprintf(ebuf, sizeof(ebuf)-1, "%s", u_errorName(rc));
+ error = ebuf;
+ } else if (info.errors) {
+ slprintf(ebuf, sizeof(ebuf)-1, "ICU IDNA error codes: 0x%x", info.errors);
+ error = ebuf;
+ } else {
+ error = "unknown error";
+ }
+ }
+ php_error_docref(NULL, E_WARNING, "Failed to parse IDN (ICU IDNA2008); %s", error);
+
+ uidna_close(uidna);
+ return FAILURE;
}
#endif
#if 0 && defined(PHP_WIN32)
-static ZEND_RESULT_CODE parse_widn(struct parse_state *state)
+static ZEND_RESULT_CODE parse_widn_2003(struct parse_state *state)
{
char *host_ptr;
uint16_t *uhost_str, ahost_str[MAXHOSTNAMELEN], *ahost_ptr;
}
#endif
+static ZEND_RESULT_CODE parse_idna(struct parse_state *state, size_t len)
+{
+ if ((state->flags & PHP_HTTP_URL_PARSE_TOIDN_2008)
+ || !(state->flags & PHP_HTTP_URL_PARSE_TOIDN_2003)
+ ) {
+#if HAVE_UIDNA_NAMETOASCII_UTF8
+ return parse_uidn_2008(state);
+#elif PHP_HTTP_HAVE_LIBIDN2
+ return parse_gidn_2008(state, len);
+#endif
+ }
+
+ if ((state->flags & PHP_HTTP_URL_PARSE_TOIDN_2003)
+ || !(state->flags & PHP_HTTP_URL_PARSE_TOIDN_2008)
+ ) {
+#if HAVE_UIDNA_IDNTOASCII
+ return parse_uidn_2003(state);
+#elif PHP_HTTP_HAVE_LIBIDN
+ return parse_gidn_2003(state, len);
+#endif
+ }
+
+#if 0 && defined(PHP_WIN32)
+ return parse_widn_2003(state);
+#endif
+
+#if HAVE_UIDNA_NAMETOASCII_UTF8
+ return parse_uidn_2008(state);
+#elif PHP_HTTP_HAVE_LIBIDN2
+ return parse_gidn_2008(state, len);
+#elif HAVE_UIDNA_IDNTOASCII
+ return parse_uidn_2003(state);
+#elif PHP_HTTP_HAVE_LIBIDN
+ return parse_gidn_2003(state, len);
+#endif
+
+ return SUCCESS;
+}
+
#ifdef HAVE_INET_PTON
static const char *parse_ip6(struct parse_state *state, const char *ptr)
{
}
if (state->flags & PHP_HTTP_URL_PARSE_TOIDN) {
-#if PHP_HTTP_HAVE_IDN2
- return parse_idn2(state, len);
-#elif PHP_HTTP_HAVE_IDN
- return parse_idn(state, len);
-#endif
-#ifdef HAVE_UIDNA_IDNTOASCII
- return parse_uidn(state);
-#endif
-#if 0 && defined(PHP_WIN32)
- return parse_widn(state);
-#endif
+ return parse_idna(state, len);
}
return SUCCESS;
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 defined(PHP_HTTP_HAVE_IDN2) || defined(PHP_HTTP_HAVE_IDN) || defined(HAVE_UIDNA_IDNTOASCII)
+#if PHP_HTTP_HAVE_LIBIDN2 || PHP_HTTP_HAVE_LIBIDN || 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);
+# endif
+# if PHP_HTTP_HAVE_IDNA2008
+ zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_TOIDN_2008"), PHP_HTTP_URL_PARSE_TOIDN_2008);
+# endif
#endif
zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_TOPCT"), PHP_HTTP_URL_PARSE_TOPCT);