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:54:54 UTC
[cxf] branch 3.1.x-fixes 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 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.1.x-fixes by this push:
new 455bf6e Optionally disabling gzip for the out payloads of non-matching CTs
455bf6e is described below
commit 455bf6e97d9af28c29e06962957a059519ab1769
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
---
.../transport/common/gzip/GZIPOutInterceptor.java | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 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 7693308..46fb982 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);
@@ -336,6 +342,12 @@ 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>'].