m6w6 / ext-http

Extended HTTP Support
BSD 2-Clause "Simplified" License
79 stars 22 forks source link

BROTLI lib version not displayed #112

Closed llaville closed 3 years ago

llaville commented 3 years ago

Hello,

I've rebuild version 3.2.4 (under PHP 7.3 and 7.4) and 4.1.0 (under PHP 8.0) and got the same results.

I expect to see libbrotli version available on http\Client\Curl\Versions\BROTLI but see nothing while I've lib available and used during pecl installation.

root@php-8.0.5 in ~ $ pecl install --force --alldeps pecl_http
downloading pecl_http-4.1.0.tgz ...
Starting to download pecl_http-4.1.0.tgz (220,349 bytes)
..............................................done: 220,349 bytes
84 source files, building
running: phpize
Configuring for:
PHP Api Version:         20200930
Zend Module Api No:      20200930
Zend Extension Api No:   420200930
where to find zlib [/usr] :
where to find libcurl [/usr] :
where to find libevent [/usr] :
where to find libicu [/usr] :
where to find libidn2 [/usr] :
where to find libidn [/usr] :
where to find libidnkit2 [/usr] :
where to find libidnkit [/usr] :
building in /tmp/pear/temp/pear-build-rootJ2kDlE/pecl_http-4.1.0
running: /tmp/pear/temp/pecl_http/configure --with-php-config=/usr/local/bin/php-config --with-http-zlib-dir=/usr --with-http-libcurl-dir=/usr --with-http-libevent-dir=/usr --with-http-libicu-dir=/usr --with-http-libidn2-dir=/usr --with-http-libidn-dir=/usr --with-http-libidnkit2-dir=/usr --with-http-libidnkit-dir=/usr
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20200930
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... gawk
checking whether to enable extended HTTP support... yes, shared
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for off_t... yes
checking for mbstate_t... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking for unistd.h... (cached) yes
checking wchar.h usability... yes
checking wchar.h presence... yes
checking for wchar.h... yes
checking wctype.h usability... yes
checking wctype.h presence... yes
checking for wctype.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking for gethostname... yes
checking for getdomainname... yes
checking for mbrtowc... yes
checking for mbtowc... yes
checking for iswalnum... yes
checking for inet_pton... yes
checking whether/where to check for zlib... yes, shared
checking for gawk... (cached) gawk
checking for zlib... 1.2.11
checking whether zlib version 1.2.11 >= 1.2.0.4... ok
checking whether/where to check for libbrotli... yes, shared
checking for libbrotlicommon... 1.0.7
checking whether libbrotlicommon version 1.0.7 >= 1.0... ok
checking for libbrotlidec... 1.0.7
checking whether libbrotlidec version 1.0.7 >= 1.0... ok
checking for libbrotlienc... 1.0.7
checking whether libbrotlienc version 1.0.7 >= 1.0... ok
checking whether/where to check for libcurl... yes, shared
checking for a sed that does not truncate output... (cached) /bin/sed
checking for egrep... (cached) /bin/grep -E
checking for curl-config... /usr/bin/curl-config
checking for libcurl... 7.64.0
checking whether libcurl version 7.64.0 >= 7.18.2... ok
checking for default CA path... /etc/ssl/certs
checking for default CA info...
checking for HTTP protocol in libcurl... yes
checking for HTTP2 feature in libcurl... yes
checking for ALT-SVC feature in libcurl... no
checking for HSTS feature in libcurl... no
checking for c-ares providing AsynchDNS in libcurl... no
checking for SSL feature in libcurl... yes
checking for OpenSSL providing SSL in libcurl... yes
checking openssl/ssl.h usability... yes
checking openssl/ssl.h presence... yes
checking for openssl/ssl.h... yes
checking openssl/crypto.h usability... yes
checking openssl/crypto.h presence... yes
checking for openssl/crypto.h... yes
checking for CURLOPT_TLSAUTH_TYPE in curl/curl.h... yes
checking whether CURLOPT_TLSAUTH_TYPE expects CURL_TLSAUTH_SRP... no
checking for default CA path... (cached) /etc/ssl/certs
checking for default CA info...
checking whether/where to check for libevent... /usr
checking for libevent... 2.1.8-stable
checking whether libevent version 2.1.8-stable >= 2.0... ok
checking for event_base_new... yes
checking for event_assign... yes
checking whether/where to check for libidn2... /usr
checking for libidn2... 2.0.5
checking whether/where to check for libidn... /usr
checking for libidn... 1.33
checking whether/where to check for libicu... /usr
checking for icu-config... false
checking for icu-i18n... 63.1
checking for uidna_IDNToASCII... yes
checking for uidna_nameToASCII_UTF8... yes
checking whether/where to check for libidnkit2... /usr
checking for libidnkit2... no
checking whether/where to check for libidnkit... /usr
checking for libidnkit... no
checking whether ext/raphf is enabled... yes
checking for php_raphf.h of ext/raphf... /usr/local/include/php/ext/raphf
checking whether ext/iconv is enabled... yes
checking whether to depend on extensions which have been built shared... yes
checking for a sed that does not truncate output... /bin/sed
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
running: make

Build process completed successfully
Installing '/usr/local/include/php/ext/http/php_http_url.h'
Installing '/usr/local/include/php/ext/http/php_http_misc.h'
Installing '/usr/local/include/php/ext/http/php_http_message.h'
Installing '/usr/local/include/php/ext/http/php_http_options.h'
Installing '/usr/local/include/php/ext/http/php_http_filter.h'
Installing '/usr/local/include/php/ext/http/php_http_cookie.h'
Installing '/usr/local/include/php/ext/http/php_http_api.h'
Installing '/usr/local/include/php/ext/http/php_http_negotiate.h'
Installing '/usr/local/include/php/ext/http/php_http_client.h'
Installing '/usr/local/include/php/ext/http/php_http.h'
Installing '/usr/local/include/php/ext/http/php_http_buffer.h'
Installing '/usr/local/include/php/ext/http/php_http_client_curl_event.h'
Installing '/usr/local/include/php/ext/http/php_http_encoding.h'
Installing '/usr/local/include/php/ext/http/php_http_client_curl_user.h'
Installing '/usr/local/include/php/ext/http/php_http_env_request.h'
Installing '/usr/local/include/php/ext/http/php_http_header.h'
Installing '/usr/local/include/php/ext/http/php_http_info.h'
Installing '/usr/local/include/php/ext/http/php_http_env.h'
Installing '/usr/local/include/php/ext/http/php_http_client_curl.h'
Installing '/usr/local/include/php/ext/http/php_http_querystring.h'
Installing '/usr/local/include/php/ext/http/php_http_encoding_zlib.h'
Installing '/usr/local/include/php/ext/http/php_http_header_parser.h'
Installing '/usr/local/include/php/ext/http/php_http_message_body.h'
Installing '/usr/local/include/php/ext/http/php_http_encoding_brotli.h'
Installing '/usr/local/include/php/ext/http/php_http_response_codes.h'
Installing '/usr/local/include/php/ext/http/php_http_params.h'
Installing '/usr/local/include/php/ext/http/php_http_message_parser.h'
Installing '/usr/local/include/php/ext/http/php_http_object.h'
Installing '/usr/local/include/php/ext/http/php_http_env_response.h'
Installing '/usr/local/include/php/ext/http/php_http_exception.h'
Installing '/usr/local/include/php/ext/http/php_http_curl.h'
Installing '/usr/local/include/php/ext/http/php_http_etag.h'
Installing '/usr/local/include/php/ext/http/php_http_client_response.h'
Installing '/usr/local/include/php/ext/http/php_http_client_request.h'
Installing '/usr/local/include/php/ext/http/php_http_version.h'
Installing '/usr/local/include/php/ext/http/php_http_utf8.h'
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20200930/http.so'
install ok: channel://pecl.php.net/pecl_http-4.1.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=http.so" to php.ini

And got with following CLI command php --re http this output (partial here) :

Extension [ <persistent> extension #43 http version 4.1.0 ] {

  - Dependencies {
    Dependency [ raphf (Required) ]
    Dependency [ spl (Required) ]
    Dependency [ iconv (Required) ]
  }

  - INI {
    Entry [ http.etag.mode <ALL> ]
      Current = 'crc32b'
    }
  }

  - Constants [72] {
    Constant [ int http\Client\Curl\FEATURES ] { 4179869 }
    Constant [ int http\Client\Curl\Features\IPV6 ] { 1 }
    Constant [ int http\Client\Curl\Features\KERBEROS4 ] { 2 }
    Constant [ int http\Client\Curl\Features\SSL ] { 4 }
    Constant [ int http\Client\Curl\Features\LIBZ ] { 8 }
    Constant [ int http\Client\Curl\Features\NTLM ] { 16 }
    Constant [ int http\Client\Curl\Features\GSSNEGOTIATE ] { 32 }
    Constant [ int http\Client\Curl\Features\ASYNCHDNS ] { 128 }
    Constant [ int http\Client\Curl\Features\SPNEGO ] { 256 }
    Constant [ int http\Client\Curl\Features\LARGEFILE ] { 512 }
    Constant [ int http\Client\Curl\Features\IDN ] { 1024 }
    Constant [ int http\Client\Curl\Features\SSPI ] { 2048 }
    Constant [ int http\Client\Curl\Features\TLSAUTH_SRP ] { 16384 }
    Constant [ int http\Client\Curl\Features\NTLM_WB ] { 32768 }
    Constant [ int http\Client\Curl\Features\HTTP2 ] { 65536 }
    Constant [ int http\Client\Curl\Features\GSSAPI ] { 131072 }
    Constant [ int http\Client\Curl\Features\KERBEROS5 ] { 262144 }
    Constant [ int http\Client\Curl\Features\UNIX_SOCKETS ] { 524288 }
    Constant [ int http\Client\Curl\Features\PSL ] { 1048576 }
    Constant [ int http\Client\Curl\Features\HTTPS_PROXY ] { 2097152 }
    Constant [ int http\Client\Curl\Features\MULTI_SSL ] { 4194304 }
    Constant [ int http\Client\Curl\Features\BROTLI ] { 8388608 }
    Constant [ string http\Client\Curl\VERSIONS ] { libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3 }
    Constant [ string http\Client\Curl\Versions\CURL ] { 7.64.0 }
    Constant [ string http\Client\Curl\Versions\SSL ] { OpenSSL/1.1.1d }
    Constant [ string http\Client\Curl\Versions\LIBZ ] { 1.2.11 }
    Constant [ null http\Client\Curl\Versions\ARES ] {  }
    Constant [ string http\Client\Curl\Versions\IDN ] { 2.0.5 }
    Constant [ null http\Client\Curl\Versions\ICONV ] {  }
    Constant [ null http\Client\Curl\Versions\BROTLI ] {  }
    Constant [ int http\Client\Curl\HTTP_VERSION_1_0 ] { 1 }
    Constant [ int http\Client\Curl\HTTP_VERSION_1_1 ] { 2 }
    Constant [ int http\Client\Curl\HTTP_VERSION_2_0 ] { 3 }
    Constant [ int http\Client\Curl\HTTP_VERSION_2TLS ] { 4 }
    Constant [ int http\Client\Curl\HTTP_VERSION_2_PRIOR_KNOWLEDGE ] { 5 }
    Constant [ int http\Client\Curl\HTTP_VERSION_ANY ] { 0 }
    Constant [ int http\Client\Curl\SSL_VERSION_TLSv1 ] { 1 }
    Constant [ int http\Client\Curl\SSL_VERSION_TLSv1_0 ] { 4 }
    Constant [ int http\Client\Curl\SSL_VERSION_TLSv1_1 ] { 5 }
    Constant [ int http\Client\Curl\SSL_VERSION_TLSv1_2 ] { 6 }
    Constant [ int http\Client\Curl\SSL_VERSION_TLSv1_3 ] { 7 }
    Constant [ int http\Client\Curl\SSL_VERSION_SSLv2 ] { 2 }
    Constant [ int http\Client\Curl\SSL_VERSION_SSLv3 ] { 3 }
    Constant [ int http\Client\Curl\SSL_VERSION_ANY ] { 0 }
    Constant [ int http\Client\Curl\TLSAUTH_SRP ] { 1 }
    Constant [ int http\Client\Curl\SSL_VERSION_MAX_DEFAULT ] { 65536 }
    Constant [ int http\Client\Curl\SSL_VERSION_MAX_TLSv1_0 ] { 262144 }
    Constant [ int http\Client\Curl\SSL_VERSION_MAX_TLSv1_1 ] { 327680 }
    Constant [ int http\Client\Curl\SSL_VERSION_MAX_TLSv1_2 ] { 393216 }
    Constant [ int http\Client\Curl\SSL_VERSION_MAX_TLSv1_3 ] { 458752 }
    Constant [ int http\Client\Curl\IPRESOLVE_V4 ] { 1 }
    Constant [ int http\Client\Curl\IPRESOLVE_V6 ] { 2 }
    Constant [ int http\Client\Curl\IPRESOLVE_ANY ] { 0 }
    Constant [ int http\Client\Curl\AUTH_NONE ] { 0 }
    Constant [ int http\Client\Curl\AUTH_BASIC ] { 1 }
    Constant [ int http\Client\Curl\AUTH_DIGEST ] { 2 }
    Constant [ int http\Client\Curl\AUTH_DIGEST_IE ] { 16 }
    Constant [ int http\Client\Curl\AUTH_NTLM ] { 8 }
    Constant [ int http\Client\Curl\AUTH_GSSNEG ] { 4 }
    Constant [ int http\Client\Curl\AUTH_SPNEGO ] { 4 }
    Constant [ int http\Client\Curl\AUTH_BEARER ] { 64 }
    Constant [ int http\Client\Curl\AUTH_ANY ] { -17 }
    Constant [ int http\Client\Curl\PROXY_SOCKS4 ] { 4 }
    Constant [ int http\Client\Curl\PROXY_SOCKS4A ] { 6 }
    Constant [ int http\Client\Curl\PROXY_SOCKS5_HOSTNAME ] { 7 }
    Constant [ int http\Client\Curl\PROXY_SOCKS5 ] { 5 }
    Constant [ int http\Client\Curl\PROXY_HTTP ] { 0 }
    Constant [ int http\Client\Curl\PROXY_HTTP_1_0 ] { 1 }
    Constant [ int http\Client\Curl\POSTREDIR_301 ] { 1 }
    Constant [ int http\Client\Curl\POSTREDIR_302 ] { 2 }
    Constant [ int http\Client\Curl\POSTREDIR_303 ] { 4 }
    Constant [ int http\Client\Curl\POSTREDIR_ALL ] { 7 }
  }
root@php-8.0.5 in ~ $ /usr/bin/pkg-config --list-all
libevent_core     libevent_core - libevent_core
libidn2           libidn2 - Library implementing IDNA2008 and TR46
vips              vips - Image processing library
vips-cpp          vips-cpp - C++ API for vips8 image processing library
libevent          libevent - libevent is an asynchronous notification event loop library
libbrotlienc      libbrotlienc - Brotli encoder library
libevent_pthreads libevent_pthreads - libevent_pthreads adds pthreads-based threading support to libevent
icu-io            icu-io - International Components for Unicode: Stream and I/O Library
ruby-2.5          Ruby - Object Oriented Script Language
icu-i18n          icu-i18n - International Components for Unicode: Internationalization library
libbrotlidec      libbrotlidec - Brotli decoder library
openssl           OpenSSL - Secure Sockets Layer and cryptography libraries and tools
libffi            libffi - Library supporting Foreign Function Interfaces
icu-uc            icu-uc - International Components for Unicode: Common and Data libraries
libcrypto         OpenSSL-libcrypto - OpenSSL cryptography library
zlib              zlib - zlib compression library
poppler-data      poppler-data - Encoding files for use with poppler
libevent_extra    libevent_extra - libevent_extra
python-2.7        Python - Python library
bash-completion   bash-completion - programmable completion for the bash shell
libbrotlicommon   libbrotlicommon - Brotli common dictionary library
libevent_openssl  libevent_openssl - libevent_openssl adds openssl-based TLS support to libevent
libidn            Libidn - IETF stringprep, nameprep, punycode, IDNA text processing.
libcurl           libcurl - Library to transfer files with ftp, http, etc.
expat             expat - expat XML parser
ruby              Ruby - Object Oriented Script Language
yaml-0.1          LibYAML - Library to parse and emit YAML
libssl            OpenSSL-libssl - Secure Sockets Layer and cryptography libraries
shared-mime-info  shared-mime-info - Freedesktop common MIME database

Did I missed something ?

m6w6 commented 3 years ago

http\Client\Curl\Versions\BROTLI lists the version libcurl was built with, if any.

Try checking ldd /usr/lib/libcurl.so if libcurl was linked against libbrotli.

Apparently, I missed to add libbrotli to the phpinfo output, though! (but this only affects http\Encoding\Stream support)

llaville commented 3 years ago

As http\Client\Curl\Versions\BROTLI was introduced since release 4.1.0 only, the only way to get libbrotli version (from PHP script) is to parse http\Client\Curl\VERSIONS But in my case, its impossible because info is missing

Constant [ string http\Client\Curl\VERSIONS ] { libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3 

it will really help if available !

m6w6 commented 3 years ago

Hi! This info is what libcurl literally tells us. If it's not there, then libcurl itself was not built with libbrotli support.

HTH

llaville commented 3 years ago

HTH Not really, even if I understand !

As I've a pecl_http version that support BROTLI compression format (https://github.com/google/brotli) => Constant [ int http\Client\Curl\Features\BROTLI ] { 8388608 } See checks at https://github.com/m6w6/ext-http/blob/master/autoconf/pecl/libbrotli.m4#L10-L16

And version of libbrotli is provided by libbrotlicommon that I have (see pkg-config output)

devilbox@php-8.0.5 in /shared/httpd $ pkg-config --print-provides libbrotlicommon
libbrotlicommon = 1.0.7

Defined in source code; See https://github.com/google/brotli/blob/v1.0.7/c/common/version.h#L17

Is it a reason why we could not see libbrotli displayed both in pecl_http 3.2.x and 4.x versions

m6w6 commented 3 years ago

Sorry for the confusion; http\Client\Curl\FEATURES has to be tested to include http\Client\Curl\Features\BROTLI; see https://mdref.m6w6.name/http/Client/Curl#FEATURES

Example:

if (http\Client\Curl\FEATURES & http\Client\Curl\Features\BROTLI) {
 ...
}