- From: Stephane Nicoll <stephane.nicoll@skynet.be>
- Date: Tue, 15 Jan 2002 22:36:40 +0100
- To: <www-jigsaw@w3.org>
- Message-ID: <000601c19e0c$b8b413d0$3f9988d9@bettyboop>
Got the same problem as you. Can anyone help? In proxy configuration, How can we add a filter for *ALL* incoming requests. Here is the code: // JigSaw filter // (c) COPYRIGHT 2002 Stéphane NICOLL, Infonet - FUNDP // Please first read the full copyright statement in file COPYRIGHT.txt package be.ac.fundp.infonet.webconf.filters; import java.io.*; import org.w3c.tools.resources.*; import org.w3c.jigsaw.http.*; import org.w3c.jigsaw.resources.*; /** * A Test filter used to discover JigSaw capabilities */ public class TestFilter extends ResourceFilter { /** * Attribute index - The on/off toggle. */ protected static int ATTR_ONOFF = -1 ; private static PrintStream out = System.out; static { Attribute a = null ; Class cls = null ; try { cls = Class.forName("be.ac.fundp.infonet.webconf.filters.TestFilter"); } catch (Exception ex) { ex.printStackTrace() ; System.exit(1) ; } // The onoff toggle a = new BooleanAttribute("onoff" , Boolean.TRUE , Attribute.EDITABLE) ; ATTR_ONOFF = AttributeRegistry.registerAttribute(cls, a) ; } /** * Get the onoff toggle value. */ public boolean getOnOffFlag() { return getBoolean(ATTR_ONOFF, true) ; } /** * The ingoing filter - Used to check incoming request * @param request The incomming request. * @return Always <strong>null</strong>. */ public ReplyInterface ingoingFilter(RequestInterface req) { Request request = (Request) req; if ( getOnOffFlag() ) { if (!request.isInternal()) { out.println("Incoming request for: "+request.getQueryString()); out.println("From client: "+request.getClient().getInetAddress().toString()); out.println("Local path: "+request.getURLPath()); } else { out.println("Dependencies for: "+request.getOriginal().getQueryString()); } } return null; } /** * The outgoing filter - Used to check server's response * @param request The original request. * @param reply The target's reply. * @exception HTTPException If processing failed. */ public ReplyInterface outgoingFilter(RequestInterface req, ReplyInterface rep) { Reply reply = (Reply) rep; Request request = (Request) req; if ( getOnOffFlag() ) { out.println("Response for: "+request.getQueryString()+" - "+reply.getStatus()+" - "+reply.getReason()); } return null; } }
Received on Tuesday, 15 January 2002 16:37:09 UTC