This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new c6d9566  SOLR-11752: Support Accept-Encoding header to enable response 
gzip compression (#281)
c6d9566 is described below

commit c6d95666b788033678c6ec5d20d51d979339fa41
Author: Houston Putman <[email protected]>
AuthorDate: Thu Sep 2 11:58:30 2021 -0400

    SOLR-11752: Support Accept-Encoding header to enable response gzip 
compression (#281)
    
    Co-authored-by: Matthew Sporleder <[email protected]>
---
 solr/CHANGES.txt               |  3 +++
 solr/bin/solr                  |  5 +++++
 solr/bin/solr.cmd              |  8 ++++++++
 solr/bin/solr.in.cmd           |  3 +++
 solr/bin/solr.in.sh            |  2 ++
 solr/server/etc/jetty-gzip.xml | 32 ++++++++++++++++++++++++++++++++
 solr/server/modules/gzip.mod   | 12 ++++++++++++
 7 files changed, 65 insertions(+)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index da26111..c8a08bb 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -402,6 +402,9 @@ Improvements
 
 * SOLR-15609: Upgrade log4j to 2.14.1 (hossman)
 
+* SOLR-11752: Support "Accept-Encoding" header to enable response gzip 
compression
+  (Matthew Sporleder, Houston Putman, Shawn Heisey, Jan Høydahl)
+
 Optimizations
 ---------------------
 * SOLR-15433: Replace transient core cache LRU by Caffeine cache. (Bruno 
Roustant)
diff --git a/solr/bin/solr b/solr/bin/solr
index be84209..d861d4c 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -280,6 +280,11 @@ if [ "$SOLR_REQUESTLOG_ENABLED" == "true" ]; then
   SOLR_JETTY_CONFIG+=("--module=requestlog")
 fi
 
+# Jetty gzip module enabled by default
+if [ "${SOLR_GZIP_ENABLED:-true}" == "true" ]; then
+  SOLR_JETTY_CONFIG+=("--module=gzip")
+fi
+
 # Authentication options
 if [ -z "$SOLR_AUTH_TYPE" ] && [ -n "$SOLR_AUTHENTICATION_OPTS" ]; then
   echo "WARNING: SOLR_AUTHENTICATION_OPTS environment variable configured 
without associated SOLR_AUTH_TYPE variable"
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index 5dd67db..b035402 100755
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -159,6 +159,14 @@ IF "%SOLR_REQUESTLOG_ENABLED%"=="true" (
   set "SOLR_JETTY_CONFIG=!SOLR_JETTY_CONFIG! --module=requestlog"
 )
 
+REM Jetty gzip module enabled by default
+IF NOT DEFINED SOLR_GZIP_ENABLED (
+  set "SOLR_GZIP_ENABLED=true"
+)
+IF "%SOLR_GZIP_ENABLED%"=="true" (
+  set "SOLR_JETTY_CONFIG=!SOLR_JETTY_CONFIG! --module=gzip"
+)
+
 REM Authentication options
 
 IF NOT DEFINED SOLR_AUTH_TYPE (
diff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmd
index 5ce8b33..914880b 100755
--- a/solr/bin/solr.in.cmd
+++ b/solr/bin/solr.in.cmd
@@ -183,6 +183,9 @@ REM  -DzkDigestUsername=admin-user 
-DzkDigestPassword=CHANGEME-ADMIN-PASSWORD ^
 REM  -DzkDigestReadonlyUsername=readonly-user 
-DzkDigestReadonlyPassword=CHANGEME-READONLY-PASSWORD
 REM set SOLR_OPTS=%SOLR_OPTS% %SOLR_ZK_CREDS_AND_ACLS%
 
+REM Jetty GZIP module enabled by default
+REM set SOLR_GZIP_ENABLED=true
+
 REM When running Solr in non-cloud mode and if planning to do distributed 
search (using the "shards" parameter), the
 REM list of hosts needs to be defined in an allow-list or Solr will forbid the 
request. The allow-list can be configured
 REM in solr.xml, or if you are using the OOTB solr.xml, can be specified using 
the system property "solr.allowUrls".
diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.sh
index 17b9dc1..2976042 100644
--- a/solr/bin/solr.in.sh
+++ b/solr/bin/solr.in.sh
@@ -207,6 +207,8 @@
 #  -DzkDigestReadonlyUsername=readonly-user 
-DzkDigestReadonlyPassword=CHANGEME-READONLY-PASSWORD"
 #SOLR_OPTS="$SOLR_OPTS $SOLR_ZK_CREDS_AND_ACLS"
 
+# Jetty GZIP module enabled by default
+#SOLR_GZIP_ENABLED=true
 
 # Settings for common system values that may cause operational imparement when 
system defaults are used.
 # Solr can use many processes and many file handles. On modern operating 
systems the savings by leaving
diff --git a/solr/server/etc/jetty-gzip.xml b/solr/server/etc/jetty-gzip.xml
new file mode 100644
index 0000000..cb69edd
--- /dev/null
+++ b/solr/server/etc/jetty-gzip.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" 
"http://www.eclipse.org/jetty/configure_9_3.dtd";>
+
+<!-- =============================================================== -->
+<!-- Mixin the GZIP Handler                                          -->
+<!-- This applies the GZIP Handler to the entire server              -->
+<!-- If a GZIP handler is required for an individual context, then   -->
+<!-- use a context XML (see test.xml example in distribution)        -->
+<!-- =============================================================== -->
+
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+ <Call name="insertHandler">
+   <Arg>
+     <New id="GzipHandler" 
class="org.eclipse.jetty.server.handler.gzip.GzipHandler">
+       <Set name="minGzipSize"><Property name="jetty.gzip.minGzipSize" 
deprecated="gzip.minGzipSize" default="2048"/></Set>
+       <Set name="checkGzExists"><Property name="jetty.gzip.checkGzExists" 
deprecated="gzip.checkGzExists" default="false"/></Set>
+       <Set name="compressionLevel"><Property 
name="jetty.gzip.compressionLevel" deprecated="gzip.compressionLevel" 
default="-1"/></Set>
+       <Set name="inflateBufferSize"><Property 
name="jetty.gzip.inflateBufferSize" default="0"/></Set>
+       <Set name="deflaterPoolCapacity"><Property 
name="jetty.gzip.deflaterPoolCapacity" default="-1"/></Set>
+       <Set name="syncFlush"><Property name="jetty.gzip.syncFlush" 
default="false" /></Set>
+
+       <Set name="excludedAgentPatterns">
+         <Array type="String">
+           <Item><Property name="jetty.gzip.excludedUserAgent" 
deprecated="gzip.excludedUserAgent" default=".*MSIE.6\.0.*"/></Item>
+         </Array>
+       </Set>
+
+       <Set name="includedMethodList"><Property 
name="jetty.gzip.includedMethodList" default="GET,POST" /></Set>
+       <Set name="excludedMethodList"><Property 
name="jetty.gzip.excludedMethodList" default="" /></Set>
+     </New>
+   </Arg>
+ </Call>
+</Configure>
diff --git a/solr/server/modules/gzip.mod b/solr/server/modules/gzip.mod
new file mode 100644
index 0000000..3542a45
--- /dev/null
+++ b/solr/server/modules/gzip.mod
@@ -0,0 +1,12 @@
+[description]
+Enable GzipHandler for dynamic gzip compression
+for the entire server.
+
+[tags]
+handler
+
+[depend]
+server
+
+[xml]
+etc/jetty-gzip.xml

Reply via email to