lowresimagefilter.java

来自「一款Java实现的HTTP代理服务器」· Java 代码 · 共 43 行

JAVA
43
字号
package rabbit.filter;import rabbit.html.HtmlBlock;import rabbit.html.Tag;import rabbit.html.TagType;import rabbit.http.HttpHeader;import rabbit.proxy.Connection;/** This filter removes the &quot;<tt>lowsrc=some_image.gif</tt>&quot; attributes *  from the &lt;img&gt; tags. * * @author <a href="mailto:robo@khelekore.org">Robert Olofsson</a> */public class LowresImageFilter extends SimpleTagFilter {    // For the factory.    public LowresImageFilter () {    }    /** Create a new LowresImageFilter for the given request, response pair.     * @param con the Connection handling the request.     * @param request the actual request made.     * @param response the actual response being sent.     */    public LowresImageFilter (Connection con, HttpHeader request, HttpHeader response) {		super (con, request, response);    }    @Override public HtmlFilter newFilter (Connection con, 					   HttpHeader request, 					   HttpHeader response) {	return new LowresImageFilter (con, request, response);    }    /** remove the lowres tags.     * @param block the part of the html page we are filtering.     */    public void handleTag (Tag tag, HtmlBlock block, int tokenIndex) {	if (tag.getTagType () == TagType.IMG)	    tag.removeAttribute ("lowsrc");    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?