tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/valves AccessLogValve.java
Date Tue, 11 Apr 2000 00:27:54 GMT
craigmcc    00/04/10 17:27:53

  Modified:    proposals/catalina/src/share/org/apache/tomcat Request.java
                        Response.java
               proposals/catalina/src/share/org/apache/tomcat/connector
                        RequestBase.java ResponseBase.java
               proposals/catalina/src/share/org/apache/tomcat/core
                        StandardContextValve.java StandardEngineValve.java
                        StandardHostValve.java
               proposals/catalina/src/share/org/apache/tomcat/security
                        HttpBasicAuth.java
               proposals/catalina/src/share/org/apache/tomcat/valves
                        AccessLogValve.java
  Log:
  Eliminate the syntactic dependencies on Request and Response really being
  facades for HttpServletRequest and HttpServletResponse.  They are now
  facades for ServletRequest and ServletResponse instead.
  
  This makes Catalina more friendly to implementing non-HTTP servlets,
  although there are lots of semantic issues to consider -- for example, how
  do you map from a request to a particular servlet, in the absence of a
  request URI.  There is probably not a generic answer to this for all
  protocols.
  
  Revision  Changes    Path
  1.3       +9 -9      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Request.java	2000/02/20 02:55:05	1.2
  +++ Request.java	2000/04/11 00:27:51	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java,v
1.2 2000/02/20 02:55:05 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/02/20 02:55:05 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Request.java,v
1.3 2000/04/11 00:27:51 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/11 00:27:51 $
    *
    * ====================================================================
    *
  @@ -71,17 +71,17 @@
   import java.util.Locale;
   import javax.servlet.ServletException;
   import javax.servlet.ServletInputStream;
  +import javax.servlet.ServletRequest;
   import javax.servlet.http.Cookie;
  -import javax.servlet.http.HttpServletRequest;
   
   
   /**
    * A <b>Request</b> is the Tomcat-internal facade for an
  - * <code>HttpServletRequest</code> that is to be processed, in order to
  - * produce a corresponding Response.  
  + * <code>ServletRequest</code> or <code>HttpServletRequest</code>
  + * that is to be processed, in order to produce a corresponding Response.  
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/02/20 02:55:05 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/11 00:27:51 $
    */
   
   public interface Request {
  @@ -130,10 +130,10 @@
   
   
       /**
  -     * Return the <code>HttpServletRequest</code> for which this object
  +     * Return the <code>ServletRequest</code> for which this object
        * is the facade.
        */
  -    public HttpServletRequest getRequest();
  +    public ServletRequest getRequest();
   
   
       /**
  
  
  
  1.3       +9 -9      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Response.java	2000/02/20 02:55:05	1.2
  +++ Response.java	2000/04/11 00:27:51	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java,v
1.2 2000/02/20 02:55:05 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/02/20 02:55:05 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Response.java,v
1.3 2000/04/11 00:27:51 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/11 00:27:51 $
    *
    * ====================================================================
    *
  @@ -70,16 +70,16 @@
   import java.util.Enumeration;
   import javax.servlet.ServletException;
   import javax.servlet.ServletOutputStream;
  -import javax.servlet.http.HttpServletResponse;
  +import javax.servlet.ServletResponse;
   
   
   /**
    * A <b>Response</b> is the Tomcat-internal facade for an
  - * <code>HttpServletResponse</code> that is to be produced, based on the
  - * processing of a corresponding Request.
  + * <code>ServletResponse</code> or <code>HttpServletResponse</code>
  + * that is to be produced, based on the processing of a corresponding Request.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/02/20 02:55:05 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/11 00:27:51 $
    */
   
   public interface Response {
  @@ -140,10 +140,10 @@
   
   
       /**
  -     * Return the <code>HttpServletResponse</code> for which this object
  +     * Return the <code>ServletResponse</code> for which this object
        * is the facade.
        */
  -    public HttpServletResponse getResponse();
  +    public ServletResponse getResponse();
   
   
       /**
  
  
  
  1.2       +7 -6      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java
  
  Index: RequestBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RequestBase.java	2000/02/20 02:55:06	1.1
  +++ RequestBase.java	2000/04/11 00:27:52	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
1.1 2000/02/20 02:55:06 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/02/20 02:55:06 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
1.2 2000/04/11 00:27:52 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/04/11 00:27:52 $
    *
    * ====================================================================
    *
  @@ -76,6 +76,7 @@
   import javax.servlet.RequestDispatcher;
   import javax.servlet.ServletException;
   import javax.servlet.ServletInputStream;
  +import javax.servlet.ServletRequest;
   import javax.servlet.http.Cookie;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpSession;
  @@ -91,7 +92,7 @@
    * the connector-specific methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/02/20 02:55:06 $
  + * @version $Revision: 1.2 $ $Date: 2000/04/11 00:27:52 $
    */
   
   public class RequestBase
  @@ -291,12 +292,12 @@
   
   
       /**
  -     * Return the <code>HttpServletRequest</code> for which this object
  +     * Return the <code>ServletRequest</code> for which this object
        * is the facade.  This method must be implemented by a subclass.
        */
  -    public HttpServletRequest getRequest() {
  +    public ServletRequest getRequest() {
   
  -	return ((HttpServletRequest) this);
  +	return ((ServletRequest) this);
   
       }
   
  
  
  
  1.2       +7 -6      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java
  
  Index: ResponseBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResponseBase.java	2000/02/20 02:55:06	1.1
  +++ ResponseBase.java	2000/04/11 00:27:52	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v
1.1 2000/02/20 02:55:06 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/02/20 02:55:06 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v
1.2 2000/04/11 00:27:52 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/04/11 00:27:52 $
    *
    * ====================================================================
    *
  @@ -74,6 +74,7 @@
   import java.util.Vector;
   import javax.servlet.ServletException;
   import javax.servlet.ServletOutputStream;
  +import javax.servlet.ServletResponse;
   import javax.servlet.http.Cookie;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.tomcat.Connector;
  @@ -88,7 +89,7 @@
    * the connector-specific methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/02/20 02:55:06 $
  + * @version $Revision: 1.2 $ $Date: 2000/04/11 00:27:52 $
    */
   
   public class ResponseBase
  @@ -239,12 +240,12 @@
   
   
       /**
  -     * Return the <code>HttpServletResponse</code> for which this object
  +     * Return the <code>ServletResponse</code> for which this object
        * is the facade.
        */
  -    public HttpServletResponse getResponse() {
  +    public ServletResponse getResponse() {
   
  -	return ((HttpServletResponse) this);
  +	return ((ServletResponse) this);
   
       }
   
  
  
  
  1.3       +16 -6     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContextValve.java
  
  Index: StandardContextValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContextValve.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardContextValve.java	2000/01/31 04:38:44	1.2
  +++ StandardContextValve.java	2000/04/11 00:27:52	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContextValve.java,v
1.2 2000/01/31 04:38:44 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/01/31 04:38:44 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContextValve.java,v
1.3 2000/04/11 00:27:52 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/11 00:27:52 $
    *
    * ====================================================================
    *
  @@ -67,6 +67,7 @@
   
   import java.io.IOException;
   import javax.servlet.ServletException;
  +import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.tomcat.Container;
   import org.apache.tomcat.Request;
  @@ -79,9 +80,12 @@
   /**
    * Valve that implements the default basic behavior for the
    * <code>StandardContext</code> container implementation.
  + * <p>
  + * <b>USAGE CONSTRAINT</b>:  This implementation is likely to be useful only
  + * when processing HTTP requests.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/01/31 04:38:44 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/11 00:27:52 $
    */
   
   final class StandardContextValve
  @@ -117,11 +121,17 @@
   
   	StandardContext context = (StandardContext) getContainer();
   
  +	if (!(request.getRequest() instanceof HttpServletRequest) ||
  +	    !(response.getResponse() instanceof HttpServletResponse)) {
  +	    return;	// FIXME - Not much else we can do generically
  +	}
  +
   	// Select the Wrapper to be used for this Request
  -	String path = request.getRequest().getRequestURI();
  +	String path =
  +	    ((HttpServletRequest) request.getRequest()).getRequestURI();
   	Wrapper wrapper = context.map(path);
   	if (wrapper == null) {
  -	    response.getResponse().sendError
  +	    ((HttpServletResponse) response.getResponse()).sendError
   		(HttpServletResponse.SC_NOT_FOUND,
   		 sm.getString("standardContext.notFound"));
   	    return;
  
  
  
  1.3       +14 -5     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardEngineValve.java
  
  Index: StandardEngineValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardEngineValve.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardEngineValve.java	2000/01/31 04:38:44	1.2
  +++ StandardEngineValve.java	2000/04/11 00:27:52	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardEngineValve.java,v
1.2 2000/01/31 04:38:44 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/01/31 04:38:44 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardEngineValve.java,v
1.3 2000/04/11 00:27:52 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/11 00:27:52 $
    *
    * ====================================================================
    *
  @@ -67,6 +67,7 @@
   
   import java.io.IOException;
   import javax.servlet.ServletException;
  +import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.tomcat.Container;
   import org.apache.tomcat.Host;
  @@ -79,9 +80,12 @@
   /**
    * Valve that implements the default basic behavior for the
    * <code>StandardEngine</code> container implementation.
  + * <p>
  + * <b>USAGE CONSTRAINT</b>:  This implementation is likely to be useful only
  + * when processing HTTP requests.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/01/31 04:38:44 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/11 00:27:52 $
    */
   
   final class StandardEngineValve
  @@ -117,10 +121,15 @@
   
   	StandardEngine engine = (StandardEngine) getContainer();
   
  +	if (!(request.getRequest() instanceof HttpServletRequest) ||
  +	    !(response.getResponse() instanceof HttpServletResponse)) {
  +	    return;	// FIXME - Not much else we can do generically
  +	}
  +
   	// Select the host to be used for this request
   	Host host = engine.map(request);
   	if (host == null) {
  -	    response.getResponse().sendError
  +	    ((HttpServletResponse) response.getResponse()).sendError
   		(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
   		 sm.getString("standardEngine.noHost"));
   	    return;
  
  
  
  1.3       +16 -6     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHostValve.java
  
  Index: StandardHostValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHostValve.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardHostValve.java	2000/01/31 04:38:44	1.2
  +++ StandardHostValve.java	2000/04/11 00:27:52	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHostValve.java,v
1.2 2000/01/31 04:38:44 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/01/31 04:38:44 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHostValve.java,v
1.3 2000/04/11 00:27:52 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/11 00:27:52 $
    *
    * ====================================================================
    *
  @@ -67,6 +67,7 @@
   
   import java.io.IOException;
   import javax.servlet.ServletException;
  +import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.tomcat.Container;
   import org.apache.tomcat.Context;
  @@ -79,9 +80,12 @@
   /**
    * Valve that implements the default basic behavior for the
    * <code>StandardHost</code> container implementation.
  + * <p>
  + * <b>USAGE CONSTRAINT</b>:  This implementation is likely to be useful only
  + * when processing HTTP requests.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/01/31 04:38:44 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/11 00:27:52 $
    */
   
   final class StandardHostValve
  @@ -117,11 +121,17 @@
   
   	StandardHost host = (StandardHost) getContainer();
   
  +	if (!(request.getRequest() instanceof HttpServletRequest) ||
  +	    !(response.getResponse() instanceof HttpServletResponse)) {
  +	    return;	// FIXME - Not much else we can do generically
  +	}
  +
   	// Select the Context to be used for this request
  -	String path = request.getRequest().getRequestURI();
  +	String path =
  +	    ((HttpServletRequest) request.getRequest()).getRequestURI();
   	Context context = host.map(path);
   	if (context == null) {
  -	    response.getResponse().sendError
  +	    ((HttpServletResponse) response.getResponse()).sendError
   		(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
   		 sm.getString("standardHost.noContext"));
   	    return;
  
  
  
  1.3       +16 -9     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/security/HttpBasicAuth.java
  
  Index: HttpBasicAuth.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/security/HttpBasicAuth.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HttpBasicAuth.java	2000/02/13 01:43:47	1.2
  +++ HttpBasicAuth.java	2000/04/11 00:27:53	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/security/HttpBasicAuth.java,v
1.2 2000/02/13 01:43:47 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/02/13 01:43:47 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/security/HttpBasicAuth.java,v
1.3 2000/04/11 00:27:53 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/11 00:27:53 $
    *
    * ====================================================================
    *
  @@ -67,6 +67,7 @@
   
   import java.io.IOException;
   import java.security.Principal;
  +import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.tomcat.Realm;
   import org.apache.tomcat.Request;
  @@ -77,9 +78,13 @@
   /**
    * Utility methods that support HTTP Basic Authentication for the
    * <code>SecurityInterceptor</code> implementation.
  + * <p>
  + * <b>USAGE CONSTRAINT</b>:  These methods assume that you are processing
  + * HTTP request and response objects, and will throw class cast exceptions
  + * if this is not the case.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/02/13 01:43:47 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/11 00:27:53 $
    */
   
   final class HttpBasicAuth {
  @@ -107,7 +112,10 @@
   	throws IOException {
   
   	// Validate any credentials already included with this request
  -	String authorization = request.getRequest().getHeader("Authorization");
  +	HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
  +	HttpServletResponse hres =
  +	    (HttpServletResponse) response.getResponse();
  +	String authorization = hreq.getHeader("Authorization");
   	if (authorization != null) {
   	    Principal principal = findPrincipal(authorization, realm);
   	    if (principal != null) {
  @@ -121,9 +129,8 @@
   	if (realmName == null)
   	    realmName = request.getRequest().getServerName() + ":" +
   		request.getRequest().getServerPort();
  -	response.getResponse().setHeader
  -	    ("WWW-Authenticate", "Basic \"" + realmName + "\"");
  -	response.getResponse().setStatus(HttpServletResponse.SC_UNAUTHORIZED);
  +	hres.setHeader("WWW-Authenticate", "Basic \"" + realmName + "\"");
  +	hres.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
   	response.flush();
   	return (false);
   
  @@ -149,7 +156,7 @@
   	authorization = authorization.substring(6).trim();
   
   	// Decode and parse the authorization credentials
  -	String unencoded = authorization;	// XXX - Base64 Decoder needed!
  +	String unencoded = authorization;	// FIXME - Base64 Decoder needed!
   	int colon = unencoded.indexOf(':');
   	if (colon < 0)
   	    return (null);
  
  
  
  1.4       +43 -14    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/valves/AccessLogValve.java
  
  Index: AccessLogValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/valves/AccessLogValve.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AccessLogValve.java	2000/04/10 20:01:41	1.3
  +++ AccessLogValve.java	2000/04/11 00:27:53	1.4
  @@ -67,6 +67,10 @@
   import java.io.PrintWriter;
   import java.sql.Timestamp;
   import javax.servlet.ServletException;
  +import javax.servlet.ServletRequest;
  +import javax.servlet.ServletResponse;
  +import javax.servlet.http.HttpServletRequest;
  +import javax.servlet.http.HttpServletResponse;
   import org.apache.tomcat.Lifecycle;
   import org.apache.tomcat.LifecycleEvent;
   import org.apache.tomcat.LifecycleException;
  @@ -117,7 +121,7 @@
    * can be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/04/10 20:01:41 $
  + * @version $Revision: 1.4 $ $Date: 2000/04/11 00:27:53 $
    */
   
   public final class AccessLogValve
  @@ -459,8 +463,17 @@
   
   	String value = null;
   
  +	ServletRequest req = request.getRequest();
  +	HttpServletRequest hreq = null;
  +	if (req instanceof HttpServletRequest)
  +	    hreq = (HttpServletRequest) req;
  +	ServletResponse res = response.getResponse();
  +	HttpServletResponse hres = null;
  +	if (res instanceof HttpServletResponse)
  +	    hres = (HttpServletResponse) res;
  +
   	if (pattern == 'a') {
  -	    value = request.getRequest().getRemoteAddr();
  +	    value = req.getRemoteAddr();
   	} else if (pattern == 'A') {
   	    value = "127.0.0.1";	// FIXME
   	} else if (pattern == 'b') {
  @@ -472,27 +485,37 @@
   	} else if (pattern == 'B') {
   	    value = "" + response.getContentLength();
   	} else if (pattern == 'h') {
  -	    value = request.getRequest().getRemoteHost();
  +	    value = req.getRemoteHost();
   	} else if (pattern == 'H') {
  -	    value = request.getRequest().getProtocol();
  +	    value = req.getProtocol();
   	} else if (pattern == 'l') {
   	    value = "-";
   	} else if (pattern == 'm') {
  -	    value = request.getRequest().getMethod();
  +	    if (hreq != null)
  +		value = hreq.getMethod();
  +	    else
  +		value = "";
   	} else if (pattern == 'p') {
  -	    value = "" + request.getRequest().getServerPort();
  +	    value = "" + req.getServerPort();
   	} else if (pattern == 'q') {
  -	    String query = request.getRequest().getQueryString();
  +	    String query = null;
  +	    if (hreq != null)
  +		query = hreq.getQueryString();
   	    if (query != null)
   		value = "?" + query;
   	    else
   		value = "";
   	} else if (pattern == 'r') {
  -	    value = request.getRequest().getMethod() + " " +
  -		request.getRequest().getRequestURI() + " " +
  -		request.getRequest().getProtocol();
  +	    if (hreq != null)
  +		value = hreq.getMethod() + " " + hreq.getRequestURI() + " " +
  +		    hreq.getProtocol();
  +	    else
  +		value = "- - " + req.getProtocol();
   	} else if (pattern == 's') {
  -	    value = "" + response.getStatus();
  +	    if (hres != null)
  +		value = "" + response.getStatus();
  +	    else
  +		value = "-";
   	} else if (pattern == 't') {
   	    String timestamp =
   		new Timestamp(System.currentTimeMillis()).toString();
  @@ -509,11 +532,17 @@
   	    temp.append(']');
   	    value = temp.toString();
   	} else if (pattern == 'u') {
  -	    value = request.getRequest().getRemoteUser();
  +	    if (hreq != null)
  +		value = hreq.getRemoteUser();
  +	    if (value == null)
  +		value = "-";
   	} else if (pattern == 'U') {
  -	    value = request.getRequest().getRequestURI();
  +	    if (hreq != null)
  +		value = hreq.getRequestURI();
  +	    else
  +		value = "-";
   	} else if (pattern == 'v') {
  -	    value = request.getRequest().getServerName();
  +	    value = req.getServerName();
   	} else {
   	    value = "???" + pattern + "???";
   	}
  
  
  

Mime
View raw message