📄 includablegzipfilter.java
字号:
//========================================================================//Copyright 2004-2008 Mort Bay Consulting Pty. Ltd.//------------------------------------------------------------------------//Licensed under the Apache License, Version 2.0 (the "License");//you may not use this file except in compliance with the License.//You may obtain a copy of the License at //http://www.apache.org/licenses/LICENSE-2.0//Unless required by applicable law or agreed to in writing, software//distributed under the License is distributed on an "AS IS" BASIS,//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.//See the License for the specific language governing permissions and//limitations under the License.//========================================================================package org.mortbay.servlet.jetty;import java.io.IOException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.mortbay.jetty.HttpConnection;import org.mortbay.servlet.GzipFilter;/* ------------------------------------------------------------ *//** Includable GZip Filter. * This extension to the {@link GzipFilter} that uses Jetty APIs to allow * headers to be set during calls to * {@link javax.servlet.RequestDispatcher#include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)}. * This allows the gzip filter to function correct during includes and to make a decision to gzip or not * at the time the buffer fills and on the basis of all response headers. * * @author gregw * */public class IncludableGzipFilter extends GzipFilter{ protected GZIPResponseWrapper newGZIPResponseWrapper(HttpServletRequest request, HttpServletResponse response) { return new IncludableResponseWrapper(request,response); } public class IncludableResponseWrapper extends GzipFilter.GZIPResponseWrapper { public IncludableResponseWrapper(HttpServletRequest request, HttpServletResponse response) { super(request,response); } protected GzipStream newGzipStream(HttpServletRequest request,HttpServletResponse response,long contentLength,int bufferSize, int minGzipSize) throws IOException { return new IncludableGzipStream(request,response,contentLength,bufferSize,minGzipSize); } } public class IncludableGzipStream extends GzipFilter.GzipStream { public IncludableGzipStream(HttpServletRequest request, HttpServletResponse response, long contentLength, int bufferSize, int minGzipSize) throws IOException { super(request,response,contentLength,bufferSize,minGzipSize); } protected boolean setContentEncodingGzip() { HttpConnection connection = HttpConnection.getCurrentConnection(); connection.getResponseFields().put("Content-Encoding", "gzip"); return true; } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -