Class GZIPOutInterceptor
- java.lang.Object
- 
- org.apache.cxf.phase.AbstractPhaseInterceptor<Message>
- 
- org.apache.cxf.transport.common.gzip.GZIPOutInterceptor
 
 
- 
- All Implemented Interfaces:
- Interceptor<Message>,- PhaseInterceptor<Message>
 
 public class GZIPOutInterceptor extends AbstractPhaseInterceptor<Message> CXF interceptor that compresses outgoing messages using gzip and sets the HTTP Content-Encoding header appropriately. An instance of this class should be added as an out interceptor on clients that need to talk to a service that accepts gzip-encoded requests or on a service that wants to be able to return compressed responses. In server mode, the interceptor only compresses responses if the client indicated (via an Accept-Encoding header on the request) that it can understand them. To handle gzip-encoded input messages, seeGZIPInInterceptor. This interceptor supports a compressionthreshold(default 1kB) - messages smaller than this threshold will not be compressed. To force compression of all messages, set the threshold to 0. This class was originally based on one of the CXF samples (configuration_interceptor).
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classGZIPOutInterceptor.UseGzipEnum giving the possible values for whether we should gzip a particular message.
 - 
Field SummaryFields Modifier and Type Field Description static PatternENCODINGSregular expression which can split encodingsstatic StringGZIP_ENCODING_KEYKey under which we store the name which should be used for the content-encoding of the outgoing message.static StringORIGINAL_OUTPUT_STREAM_KEYKey under which we store the original output stream on the message, for use by the ending interceptor.static StringSOAP_JMS_CONTENTENCODINGstatic StringUSE_GZIP_KEYKey under which we store an indication of whether compression is permitted or required, for use by the ending interceptor.static PatternZERO_Qregular expression that matches any encoding with a q-value of 0 (or 0.0, 0.00, etc.).
 - 
Constructor SummaryConstructors Constructor Description GZIPOutInterceptor()GZIPOutInterceptor(int threshold)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>getSupportedPayloadContentTypes()intgetThreshold()GZIPOutInterceptor.UseGzipgzipPermitted(Message message)Checks whether we can, cannot or must use gzip compression on this output message.voidhandleMessage(Message message)Intercepts a message.voidsetForce(boolean force)voidsetSupportedPayloadContentTypes(Set<String> supportedPayloadContentTypes)voidsetThreshold(int threshold)- 
Methods inherited from class org.apache.cxf.phase.AbstractPhaseInterceptoraddAfter, addAfter, addBefore, addBefore, getAdditionalInterceptors, getAfter, getBefore, getId, getPhase, handleFault, isGET, isRequestor, setAfter, setBefore
 
- 
 
- 
- 
- 
Field Detail- 
ZERO_Qpublic static final Pattern ZERO_Q regular expression that matches any encoding with a q-value of 0 (or 0.0, 0.00, etc.).
 - 
ENCODINGSpublic static final Pattern ENCODINGS regular expression which can split encodings
 - 
ORIGINAL_OUTPUT_STREAM_KEYpublic static final String ORIGINAL_OUTPUT_STREAM_KEY Key under which we store the original output stream on the message, for use by the ending interceptor.
 - 
USE_GZIP_KEYpublic static final String USE_GZIP_KEY Key under which we store an indication of whether compression is permitted or required, for use by the ending interceptor.
 - 
GZIP_ENCODING_KEYpublic static final String GZIP_ENCODING_KEY Key under which we store the name which should be used for the content-encoding of the outgoing message. Typically "gzip" but may be "x-gzip" if we are processing a response message and this is the name given by the client in Accept-Encoding.
 - 
SOAP_JMS_CONTENTENCODINGpublic static final String SOAP_JMS_CONTENTENCODING - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
setThresholdpublic void setThreshold(int threshold) 
 - 
getThresholdpublic int getThreshold() 
 - 
handleMessagepublic void handleMessage(Message message) Description copied from interface:InterceptorIntercepts a message. Interceptors should NOT invoke handleMessage or handleFault on the next interceptor - the interceptor chain will take care of this.
 - 
gzipPermittedpublic GZIPOutInterceptor.UseGzip gzipPermitted(Message message) Checks whether we can, cannot or must use gzip compression on this output message. Gzip is always permitted if the message is a client request. If the message is a server response we check the Accept-Encoding header of the corresponding request message - with no Accept-Encoding we assume that gzip is not permitted. For the full gory details, see section 14.3 of RFC 2616 (HTTP 1.1).- Parameters:
- message- the outgoing message.
- Returns:
- whether to attempt gzip compression for this message.
- Throws:
- Fault- if the Accept-Encoding header does not allow any encoding that we can support (identity, gzip or x-gzip).
 
 - 
setForcepublic void setForce(boolean force) 
 
- 
 
-