01: // DebugFilter.java
02: // $Id: DebugFilter.java,v 1.8 2000/08/16 21:38:02 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.www.protocol.http;
07:
08: import java.io.OutputStream;
09: import java.io.PrintStream;
10:
11: /**
12: * A simple debug filter, that will dump traffic
13: * This filter will dump the outgoing request, and the incomming reply to
14: * the java process standard output.
15: * <p>Usefull for debugging !
16: */
17:
18: public class DebugFilter implements PropRequestFilter {
19:
20: /**
21: * This filter doesn't handle exceptions.
22: * @param request The request that triggered the exception.
23: * @param ex The triggered exception.
24: * @return Always <strong>false</strong>.
25: */
26:
27: public boolean exceptionFilter(Request request, HttpException ex) {
28: return false;
29: }
30:
31: /**
32: * PropRequestFilter implementation - Initialize the filter.
33: * Time to register ourself to the HttpManager.
34: * @param manager The HTTP manager that is initializing ourself.
35: */
36:
37: public void initialize(HttpManager manager) {
38: // We install ourself as a global filter, we are cool !
39: manager.setFilter(this );
40: }
41:
42: /**
43: * The ingoing filter just dumps the request.
44: * @param request The request to be filtered.
45: * @exception HttpException is never thrown.
46: */
47:
48: public Reply ingoingFilter(Request request) throws HttpException {
49: // On the way in, emit the request to stdout:
50: System.out.println("\nREQUEST : \n");
51: request.dump(System.out);
52: return null;
53: }
54:
55: /**
56: * The outgoing filter just dumps the reply.
57: * @param request The request that is filtered.
58: * @param reply The corresponding reply.
59: * @exception HttpException is never thrown.
60: */
61:
62: public Reply outgoingFilter(Request Request, Reply reply)
63: throws HttpException {
64: // On the way out, emit the reply to stdou:
65: System.out.println("\nREPLY : \n");
66: reply.dump(System.out);
67: return null;
68: }
69:
70: /**
71: * We do not maintain any in-memory cached state.
72: */
73:
74: public void sync() {
75: return;
76: }
77:
78: }
|