Coverage Report - org.apache.tapestry5.internal.gzip.GZIPEnabledResponse
 
Classes in this File Line Coverage Branch Coverage Complexity
GZIPEnabledResponse
100%
10/10
100%
2/2
0
 
 1  
 // Copyright 2009 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry5.internal.gzip;
 16  
 
 17  
 import org.apache.tapestry5.internal.InternalConstants;
 18  
 import org.apache.tapestry5.services.ResponseCompressionAnalyzer;
 19  
 
 20  
 import javax.servlet.ServletOutputStream;
 21  
 import javax.servlet.http.HttpServletRequest;
 22  
 import javax.servlet.http.HttpServletResponse;
 23  
 import javax.servlet.http.HttpServletResponseWrapper;
 24  
 import java.io.IOException;
 25  
 
 26  
 public class GZIPEnabledResponse extends HttpServletResponseWrapper
 27  
 {
 28  
     private final int cutover;
 29  
 
 30  
     private final HttpServletRequest request;
 31  
 
 32  
     private final HttpServletResponse response;
 33  
 
 34  
     private final ResponseCompressionAnalyzer analyzer;
 35  
 
 36  
     public GZIPEnabledResponse(HttpServletResponse response, HttpServletRequest request, int cutover,
 37  
                                ResponseCompressionAnalyzer analyzer)
 38  
     {
 39  1554
         super(response);
 40  
 
 41  1554
         this.request = request;
 42  1554
         this.response = response;
 43  1554
         this.cutover = cutover;
 44  1554
         this.analyzer = analyzer;
 45  1554
     }
 46  
 
 47  
     @Override
 48  
     public ServletOutputStream getOutputStream() throws IOException
 49  
     {
 50  1202
         if (request.getAttribute(InternalConstants.SUPPRESS_COMPRESSION) != null)
 51  114
             return super.getOutputStream();
 52  
 
 53  1088
         String contentType = getContentType();
 54  
 
 55  1088
         return new BufferedGZipOutputStream(contentType, response, cutover, analyzer);
 56  
     }
 57  
 }