Commit 0e2b3fbe authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Merge r1790852, r1790853, r1790860 from trunk:

Merge r1761714, r1762512, r1762515, r1771791, r1779077, r1779091, r1779699, r1790852, r1790853, r1790860 from trunk:

mod_brotli: Add initial implementation.

This new module supports dynamic Brotli (RFC 7932) compression.  Existing
mod_deflate installations can benefit from better compression ratio by
sending Brotli-compressed data to the clients that support it:

    SetOutputFilter BROTLI_COMPRESS;DEFLATE

The module features zero-copy processing, which is only possible with the
new API from the upcoming 1.0.x series of brotli [1].  The Linux makefile
works against libbrotli [2], as currently the core brotli repository doesn't
offer a way to build a library [3].  Apart from that, only the CMake build
is now supported.

[1] https://github.com/google/brotli
[2] https://github.com/bagder/libbrotli
[3] https://github.com/google/brotli/pull/332


mod_brotli: Allow compression ratio logging with new BrotliFilterNote
directive.


mod_brotli: Handle new 'no-brotli' internal environment variable that
disables Brotli compression for a particular request.

This mimicks how mod_deflate handles the 'no-gzip' env variable, and
should allow seamless migration for configurations that use it.


mod_brotli: Explicitly cast 'const uint8_t *' to 'const char *' when using
the data received from Brotli to create a bucket.

This fixes a /W4 warning in my environment, and should also allow building
mod_brotli on NetWare.

Submitted by: NormW <normw gknw.net>


unused variable error could mistakenly note that brotli isn't available.


1st draft


Be more consitent in the layout, and fix the display of a multi lines <highlight> section

mod_brotli: Update makefile to allow using Brotli library >= 0.6.0.

The 0.6.0 version has just been released [1], and it contains the
necessary API required for mod_brotli.

[1] https://github.com/google/brotli/releases/tag/v0.6.0

mod_brotli: Fix a minor typo in the description of BrotliAlterETag
that has been referring to httpd 2.2.x.

There's no mod_brotli in 2.2.x.

mod_brotli: Comment on the default choice (0) for BROTLI_PARAM_LGBLOCK.

Submitted by: kotkov, jim, jim, jailletc36, kotkov, kotkov, kotkov
Reviewed by: jim, jorton, icing

mod_brotli: Update makefile to allow using Brotli library >= 0.6.0.

The 0.6.0 version has just been released [1], and it contains the
necessary API required for mod_brotli.

[1] https://github.com/google/brotli/releases/tag/v0.6.0

mod_brotli: Fix a minor typo in the description of BrotliAlterETag
that has been referring to httpd 2.2.x.

There's no mod_brotli in 2.2.x.

mod_brotli: Comment on the default choice (0) for BROTLI_PARAM_LGBLOCK.

Submitted by: kotkov
Reviewed by: jim, jorton, icing


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1791231 13f79535-47bb-0310-9956-ffa450edef68
parent b9e76872
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@

Changes with Apache 2.4.26

  *) mod_brotli: Add a new module for dynamic Brotli (RFC 7932) compression.
     [Evgeny Kotkov]

  *) mod_proxy_http2: Fixed bug in re-attempting proxy requests after 
     connection error. Reliability of reconnect handling improved. 
     [Stefan Eissing]
+29 −0
Original line number Diff line number Diff line
@@ -58,6 +58,12 @@ ELSE()
  SET(default_nghttp2_libraries "${CMAKE_INSTALL_PREFIX}/lib/nghttp2.lib")
ENDIF()

IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/brotli_enc.lib")
  SET(default_brotli_libraries "${CMAKE_INSTALL_PREFIX}/lib/brotli_enc.lib" "${CMAKE_INSTALL_PREFIX}/lib/brotli_common.lib")
ELSE()
  SET(default_brotli_libraries)
ENDIF()

SET(APR_INCLUDE_DIR       "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with APR[-Util] include files")
SET(APR_LIBRARIES         ${default_apr_libraries}       CACHE STRING "APR libraries to link with")
SET(NGHTTP2_INCLUDE_DIR   "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with NGHTTP2 include files within nghttp2 subdirectory")
@@ -66,6 +72,8 @@ SET(PCRE_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Direct
SET(PCRE_LIBRARIES        ${default_pcre_libraries}      CACHE STRING "PCRE libraries to link with")
SET(LIBXML2_ICONV_INCLUDE_DIR     ""                     CACHE STRING "Directory with iconv include files for libxml2")
SET(LIBXML2_ICONV_LIBRARIES       ""                     CACHE STRING "iconv libraries to link with for libxml2")
SET(BROTLI_INCLUDE_DIR    "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Directory with include files for Brotli")
SET(BROTLI_LIBRARIES      ${default_brotli_libraries}    CACHE STRING "Brotli libraries to link with")
# end support library configuration

# Misc. options
@@ -179,6 +187,18 @@ ELSE()
  SET(NGHTTP2_FOUND FALSE)
ENDIF()

# See if we have Brotli
SET(BROTLI_FOUND TRUE)
IF(EXISTS "${BROTLI_INCLUDE_DIR}/brotli/encode.h")
  FOREACH(onelib ${BROTLI_LIBRARIES})
    IF(NOT EXISTS ${onelib})
      SET(BROTLI_FOUND FALSE)
    ENDIF()
  ENDFOREACH()
ELSE()
  SET(BROTLI_FOUND FALSE)
ENDIF()

MESSAGE(STATUS "")
MESSAGE(STATUS "Summary of feature detection:")
MESSAGE(STATUS "")
@@ -187,6 +207,7 @@ MESSAGE(STATUS "LUA51_FOUND .............. : ${LUA51_FOUND}")
MESSAGE(STATUS "NGHTTP2_FOUND ............ : ${NGHTTP2_FOUND}")
MESSAGE(STATUS "OPENSSL_FOUND ............ : ${OPENSSL_FOUND}")
MESSAGE(STATUS "ZLIB_FOUND ............... : ${ZLIB_FOUND}")
MESSAGE(STATUS "BROTLI_FOUND ............. : ${BROTLI_FOUND}")
MESSAGE(STATUS "APR_HAS_LDAP ............. : ${APR_HAS_LDAP}")
MESSAGE(STATUS "APR_HAS_XLATE ............ : ${APR_HAS_XLATE}")
MESSAGE(STATUS "APU_HAVE_CRYPTO .......... : ${APU_HAVE_CRYPTO}")
@@ -258,6 +279,7 @@ SET(MODULE_LIST
  "modules/examples/mod_case_filter_in+O+Example uppercase conversion input filter"
  "modules/examples/mod_example_hooks+O+Example hook callback handler module"
  "modules/examples/mod_example_ipc+O+Example of shared memory and mutex usage"
  "modules/filters/mod_brotli+i+Brotli compression support"
  "modules/filters/mod_buffer+I+Filter Buffering"
  "modules/filters/mod_charset_lite+i+character set translation"
  "modules/filters/mod_data+O+RFC2397 data encoder"
@@ -376,6 +398,11 @@ IF(ZLIB_FOUND)
  SET(mod_deflate_extra_includes       ${ZLIB_INCLUDE_DIR})
  SET(mod_deflate_extra_libs           ${ZLIB_LIBRARIES})
ENDIF()
SET(mod_brotli_requires              BROTLI_FOUND)
IF(BROTLI_FOUND)
  SET(mod_brotli_extra_includes        ${BROTLI_INCLUDE_DIR})
  SET(mod_brotli_extra_libs            ${BROTLI_LIBRARIES})
ENDIF()
SET(mod_firehose_requires            SOMEONE_TO_MAKE_IT_COMPILE_ON_WINDOWS)
SET(mod_heartbeat_extra_libs         mod_watchdog)
SET(mod_http2_requires               NGHTTP2_FOUND)
@@ -922,6 +949,8 @@ MESSAGE(STATUS " PCRE include directory .......... : ${PCRE_INCLUDE_DIR}")
MESSAGE(STATUS "  PCRE libraries .................. : ${PCRE_LIBRARIES}")
MESSAGE(STATUS "  libxml2 iconv prereq include dir. : ${LIBXML2_ICONV_INCLUDE_DIR}")
MESSAGE(STATUS "  libxml2 iconv prereq libraries .. : ${LIBXML2_ICONV_LIBRARIES}")
MESSAGE(STATUS "  Brotli include directory......... : ${BROTLI_INCLUDE_DIR}")
MESSAGE(STATUS "  Brotli libraries ................ : ${BROTLI_LIBRARIES}")
MESSAGE(STATUS "  Extra include directories ....... : ${EXTRA_INCLUDES}")
MESSAGE(STATUS "  Extra compile flags ............. : ${EXTRA_COMPILE_FLAGS}")
MESSAGE(STATUS "  Extra libraries ................. : ${EXTRA_LIBS}")
+0 −16
Original line number Diff line number Diff line
@@ -138,22 +138,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
  [ start all new proposals below, under PATCHES PROPOSED. ]

  *) mod_brotli: Backport of mod_brotli filter
     trunk patch: http://svn.apache.org/r1761714
                  http://svn.apache.org/r1762512
                  http://svn.apache.org/r1762515
                  http://svn.apache.org/r1771791
                  http://svn.apache.org/r1779077
                  http://svn.apache.org/r1779091
                  http://svn.apache.org/r1779699
                  http://svn.apache.org/r1790852
                  http://svn.apache.org/r1790853
                  http://svn.apache.org/r1790860
     2.4.x patch: http://home.apache.org/~jim/patches/brotli-2.4.patch
                  http://svn.apache.org/r1790852
                  http://svn.apache.org/r1790853
                  http://svn.apache.org/r1790860
     +1: jim, jorton, icing

PATCHES PROPOSED TO BACKPORT FROM TRUNK:
  [ New proposals should be added at the end of the list ]
+122 −0
Original line number Diff line number Diff line
@@ -140,6 +140,128 @@ APACHE_MODULE(proxy_html, Fix HTML Links in a Reverse Proxy, , , , [
]
)

dnl
dnl APACHE_CHECK_BROTLI
dnl
dnl Configure for Brotli, giving preference to
dnl "--with-brotli=<path>" if it was specified.
dnl
AC_DEFUN([APACHE_CHECK_BROTLI],[
  AC_CACHE_CHECK([for Brotli], [ac_cv_brotli], [
    dnl initialise the variables we use
    ac_cv_brotli=no
    ac_brotli_found=""
    ac_brotli_base=""
    ac_brotli_libs=""
    ac_brotli_mod_cflags=""
    ac_brotli_mod_ldflags=""

    dnl Determine the Brotli base directory, if any
    AC_MSG_CHECKING([for user-provided Brotli base directory])
    AC_ARG_WITH(brotli, APACHE_HELP_STRING(--with-brotli=PATH,Brotli installation directory), [
      dnl If --with-brotli specifies a directory, we use that directory
      if test "x$withval" != "xyes" -a "x$withval" != "x"; then
        dnl This ensures $withval is actually a directory and that it is absolute
        ac_brotli_base="`cd $withval ; pwd`"
      fi
    ])
    if test "x$ac_brotli_base" = "x"; then
      AC_MSG_RESULT(none)
    else
      AC_MSG_RESULT($ac_brotli_base)
    fi

    dnl Run header and version checks
    saved_CPPFLAGS="$CPPFLAGS"
    saved_LIBS="$LIBS"
    saved_LDFLAGS="$LDFLAGS"

    dnl Before doing anything else, load in pkg-config variables
    if test -n "$PKGCONFIG"; then
      saved_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
      if test "x$ac_brotli_base" != "x" -a \
              -f "${ac_brotli_base}/lib/pkgconfig/libbrotlienc.pc"; then
        dnl Ensure that the given path is used by pkg-config too, otherwise
        dnl the system libbrotlienc.pc might be picked up instead.
        PKG_CONFIG_PATH="${ac_brotli_base}/lib/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
        export PKG_CONFIG_PATH
      fi
      ac_brotli_libs="`$PKGCONFIG --libs-only-l --silence-errors libbrotlienc`"
      if test $? -eq 0; then
        ac_brotli_found="yes"
        pkglookup="`$PKGCONFIG --cflags-only-I libbrotlienc`"
        APR_ADDTO(CPPFLAGS, [$pkglookup])
        APR_ADDTO(MOD_CFLAGS, [$pkglookup])
        pkglookup="`$PKGCONFIG --libs-only-L libbrotlienc`"
        APR_ADDTO(LDFLAGS, [$pkglookup])
        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
        pkglookup="`$PKGCONFIG --libs-only-other libbrotlienc`"
        APR_ADDTO(LDFLAGS, [$pkglookup])
        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
      fi
      PKG_CONFIG_PATH="$saved_PKG_CONFIG_PATH"
    fi

    dnl fall back to the user-supplied directory if not found via pkg-config
    if test "x$ac_brotli_base" != "x" -a "x$ac_brotli_found" = "x"; then
      APR_ADDTO(CPPFLAGS, [-I$ac_brotli_base/include])
      APR_ADDTO(MOD_CFLAGS, [-I$ac_brotli_base/include])
      APR_ADDTO(LDFLAGS, [-L$ac_brotli_base/lib])
      APR_ADDTO(MOD_LDFLAGS, [-L$ac_brotli_base/lib])
      if test "x$ap_platform_runtime_link_flag" != "x"; then
        APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ac_brotli_base/lib])
        APR_ADDTO(MOD_LDFLAGS, [$ap_platform_runtime_link_flag$ac_brotli_base/lib])
      fi
    fi

    ac_brotli_libs="${ac_brotli_libs:--lbrotlienc `$apr_config --libs`} "
    APR_ADDTO(MOD_LDFLAGS, [$ac_brotli_libs])
    APR_ADDTO(LIBS, [$ac_brotli_libs])

    dnl Run library and function checks
    liberrors=""
    AC_CHECK_HEADERS([brotli/encode.h])
    AC_MSG_CHECKING([for Brotli version >= 0.6.0])
    AC_TRY_COMPILE([#include <brotli/encode.h>],[
const uint8_t *o = BrotliEncoderTakeOutput((BrotliEncoderState*)0, (size_t*)0);
if (o) return *o;],
      [AC_MSG_RESULT(OK)
       ac_cv_brotli="yes"],
      [AC_MSG_RESULT(FAILED)])

    dnl restore
    CPPFLAGS="$saved_CPPFLAGS"
    LIBS="$saved_LIBS"
    LDFLAGS="$saved_LDFLAGS"

    dnl cache MOD_LDFLAGS, MOD_CFLAGS
    ac_brotli_mod_cflags=$MOD_CFLAGS
    ac_brotli_mod_ldflags=$MOD_LDFLAGS
  ])
  if test "x$ac_cv_brotli" = "xyes"; then
    APR_ADDTO(MOD_LDFLAGS, [$ac_brotli_mod_ldflags])

    dnl Ouch!  libbrotlienc.1.so doesn't link against libm.so (-lm),
    dnl although it should.  Workaround that in our LDFLAGS:

    APR_ADDTO(MOD_LDFLAGS, ["-lm"])
    APR_ADDTO(MOD_CFLAGS, [$ac_brotli_mod_cflags])
  fi
])

APACHE_MODULE(brotli, Brotli compression support, , , most, [
  APACHE_CHECK_BROTLI
  if test "$ac_cv_brotli" = "yes" ; then
      if test "x$enable_brotli" = "xshared"; then
         # The only symbol which needs to be exported is the module
         # structure, so ask libtool to hide everything else:
         APR_ADDTO(MOD_BROTLI_LDADD, [-export-symbols-regex brotli_module])
      fi
  else
      enable_brotli=no
  fi
])

APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current])

APACHE_MODPATH_FINISH
+592 −0

File added.

Preview size limit exceeded, changes collapsed.