You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2018/01/19 11:52:33 UTC

[cxf] branch master updated: Optionally disabling gzip for the out payloads of non-matching CTs

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

sergeyb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 716fdf4  Optionally disabling gzip for the out payloads of non-matching CTs
716fdf4 is described below

commit 716fdf482383cdc2978d36af4f9b9f973098dce5
Author: Sergey Beryozkin <sb...@gmail.com>
AuthorDate: Fri Jan 19 11:52:16 2018 +0000

    Optionally disabling gzip for the out payloads of non-matching CTs
---
 .../cxf/transport/common/gzip/GZIPOutInterceptor.java  | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java b/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
index 2b7808a..fe4e4dd 100644
--- a/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
+import java.util.Set;
 import java.util.TreeMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -112,7 +113,8 @@ public class GZIPOutInterceptor extends AbstractPhaseInterceptor<Message> {
      */
     private int threshold = 1024;
     private boolean force;
-
+    private Set<String> supportedPayloadContentTypes;
+    
     public GZIPOutInterceptor() {
         super(Phase.PREPARE_SEND);
         addAfter(MessageSenderInterceptor.class.getName());
@@ -132,7 +134,7 @@ public class GZIPOutInterceptor extends AbstractPhaseInterceptor<Message> {
     }
 
     public void handleMessage(Message message) throws Fault {
-        UseGzip use = gzipPermitted(message, force);
+        UseGzip use = gzipPermitted(message);
         if (use != UseGzip.NO) {
             // remember the original output stream, we will write compressed
             // data to this later
@@ -167,8 +169,12 @@ public class GZIPOutInterceptor extends AbstractPhaseInterceptor<Message> {
      * @throws Fault if the Accept-Encoding header does not allow any encoding
      *                 that we can support (identity, gzip or x-gzip).
      */
-    public static UseGzip gzipPermitted(Message message, boolean force) throws Fault {
+    public UseGzip gzipPermitted(Message message) throws Fault {
         UseGzip permitted = UseGzip.NO;
+        if (supportedPayloadContentTypes != null && message.containsKey(Message.CONTENT_TYPE)
+            && !supportedPayloadContentTypes.contains(message.get(Message.CONTENT_TYPE))) {
+            return permitted;
+        }
         if (MessageUtils.isRequestor(message)) {
             LOG.fine("Requestor role, so gzip enabled");
             Object o = message.getContextualProperty(USE_GZIP_KEY);
@@ -337,5 +343,11 @@ public class GZIPOutInterceptor extends AbstractPhaseInterceptor<Message> {
     public void setForce(boolean force) {
         this.force = force;
     }
+    public Set<String> getSupportedPayloadContentTypes() {
+        return supportedPayloadContentTypes;
+    }
+    public void setSupportedPayloadContentTypes(Set<String> supportedPayloadContentTypes) {
+        this.supportedPayloadContentTypes = supportedPayloadContentTypes;
+    }
 
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@cxf.apache.org" <co...@cxf.apache.org>'].