tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r951093 - in /tomcat/trunk/java/org/apache: catalina/connector/ coyote/ coyote/ajp/ coyote/http11/
Date Thu, 03 Jun 2010 18:13:48 GMT
Author: markt
Date: Thu Jun  3 18:13:47 2010
New Revision: 951093

URL: http://svn.apache.org/viewvc?rev=951093&view=rev
Log:
Extend access logging to requests rejected in the Processors

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/trunk/java/org/apache/coyote/Adapter.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java

Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=951093&r1=951092&r2=951093&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Thu Jun  3 18:13:47
2010
@@ -457,6 +457,41 @@ public class CoyoteAdapter implements Ad
     }
 
 
+    public void log(org.apache.coyote.Request req,
+            org.apache.coyote.Response res, long time) {
+
+        Request request = (Request) req.getNote(ADAPTER_NOTES);
+        Response response = (Response) res.getNote(ADAPTER_NOTES);
+
+        if (request == null) {
+
+            // Create objects
+            request = connector.createRequest();
+            request.setCoyoteRequest(req);
+            response = connector.createResponse();
+            response.setCoyoteResponse(res);
+
+            // Link objects
+            request.setResponse(response);
+            response.setRequest(request);
+
+            // Set as notes
+            req.setNote(ADAPTER_NOTES, request);
+            res.setNote(ADAPTER_NOTES, response);
+
+            // Set query string encoding
+            req.getParameters().setQueryStringEncoding
+                (connector.getURIEncoding());
+        }
+        
+        connector.getService().getContainer().logAccess(
+                request, response, 0, true);
+        
+        request.recycle();
+        response.recycle();
+    }
+    
+    
     // ------------------------------------------------------ Protected Methods
 
 

Modified: tomcat/trunk/java/org/apache/coyote/Adapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/Adapter.java?rev=951093&r1=951092&r2=951093&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/Adapter.java (original)
+++ tomcat/trunk/java/org/apache/coyote/Adapter.java Thu Jun  3 18:13:47 2010
@@ -45,11 +45,13 @@ public interface Adapter {
      *  runtime exceptions )
      */
     public void service(Request req, Response res)
-	throws Exception;
+            throws Exception;
 
     public boolean event(Request req, Response res, SocketStatus status)
-    throws Exception;
+            throws Exception;
     
-    public boolean asyncDispatch(Request req,Response res, SocketStatus status) throws Exception;
+    public boolean asyncDispatch(Request req,Response res, SocketStatus status)
+            throws Exception;
 
+    public void log(Request req, Response res, long time);
 }

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=951093&r1=951092&r2=951093&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Thu Jun  3 18:13:47 2010
@@ -416,6 +416,7 @@ public class AjpAprProcessor implements 
                 log.debug(sm.getString("ajpprocessor.header.error"), t);
                 // 400 - Bad Request
                 response.setStatus(400);
+                adapter.log(request, response, 0);
                 error = true;
             }
 
@@ -427,6 +428,7 @@ public class AjpAprProcessor implements 
                 log.debug(sm.getString("ajpprocessor.request.prepare"), t);
                 // 400 - Internal Server Error
                 response.setStatus(400);
+                adapter.log(request, response, 0);
                 error = true;
             }
 
@@ -441,6 +443,7 @@ public class AjpAprProcessor implements 
                     log.error(sm.getString("ajpprocessor.request.process"), t);
                     // 500 - Internal Server Error
                     response.setStatus(500);
+                    adapter.log(request, response, 0);
                     error = true;
                 }
             }
@@ -501,6 +504,7 @@ public class AjpAprProcessor implements 
             log.error(sm.getString("http11processor.request.process"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
 
@@ -892,6 +896,7 @@ public class AjpAprProcessor implements 
                     secret = true;
                     if (!tmpMB.equals(requiredSecret)) {
                         response.setStatus(403);
+                        adapter.log(request, response, 0);
                         error = true;
                     }
                 }
@@ -908,6 +913,7 @@ public class AjpAprProcessor implements 
         // Check if secret was submitted if required
         if ((requiredSecret != null) && !secret) {
             response.setStatus(403);
+            adapter.log(request, response, 0);
             error = true;
         }
 
@@ -956,6 +962,7 @@ public class AjpAprProcessor implements 
                 request.serverName().duplicate(request.localName());
             } catch (IOException e) {
                 response.setStatus(400);
+                adapter.log(request, response, 0);
                 error = true;
             }
             return;
@@ -1007,6 +1014,7 @@ public class AjpAprProcessor implements 
                     error = true;
                     // 400 - Bad request
                     response.setStatus(400);
+                    adapter.log(request, response, 0);
                     break;
                 }
                 port = port + (charValue * mult);

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?rev=951093&r1=951092&r2=951093&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Thu Jun  3 18:13:47 2010
@@ -427,6 +427,7 @@ public class AjpProcessor implements Act
                 log.debug(sm.getString("ajpprocessor.header.error"), t);
                 // 400 - Bad Request
                 response.setStatus(400);
+                adapter.log(request, response, 0);
                 error = true;
             }
 
@@ -438,6 +439,7 @@ public class AjpProcessor implements Act
                 log.debug(sm.getString("ajpprocessor.request.prepare"), t);
                 // 400 - Internal Server Error
                 response.setStatus(400);
+                adapter.log(request, response, 0);
                 error = true;
             }
 
@@ -452,6 +454,7 @@ public class AjpProcessor implements Act
                     log.error(sm.getString("ajpprocessor.request.process"), t);
                     // 500 - Internal Server Error
                     response.setStatus(500);
+                    adapter.log(request, response, 0);
                     error = true;
                 }
             }
@@ -505,6 +508,7 @@ public class AjpProcessor implements Act
             log.error(sm.getString("http11processor.request.process"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
 
@@ -900,6 +904,7 @@ public class AjpProcessor implements Act
                     secret = true;
                     if (!tmpMB.equals(requiredSecret)) {
                         response.setStatus(403);
+                        adapter.log(request, response, 0);
                         error = true;
                     }
                 }
@@ -916,6 +921,7 @@ public class AjpProcessor implements Act
         // Check if secret was submitted if required
         if ((requiredSecret != null) && !secret) {
             response.setStatus(403);
+            adapter.log(request, response, 0);
             error = true;
         }
 
@@ -964,6 +970,7 @@ public class AjpProcessor implements Act
                 request.serverName().duplicate(request.localName());
             } catch (IOException e) {
                 response.setStatus(400);
+                adapter.log(request, response, 0);
                 error = true;
             }
             return;
@@ -1015,6 +1022,7 @@ public class AjpProcessor implements Act
                     error = true;
                     // 400 - Bad request
                     response.setStatus(400);
+                    adapter.log(request, response, 0);
                     break;
                 }
                 port = port + (charValue * mult);

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=951093&r1=951092&r2=951093&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Thu Jun  3 18:13:47
2010
@@ -734,6 +734,7 @@ public class Http11AprProcessor implemen
             log.error(sm.getString("http11processor.request.process"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
         
@@ -821,6 +822,7 @@ public class Http11AprProcessor implemen
                 }
                 // 400 - Bad Request
                 response.setStatus(400);
+                adapter.log(request, response, 0);
                 error = true;
             }
 
@@ -835,6 +837,7 @@ public class Http11AprProcessor implemen
                     }
                     // 400 - Internal Server Error
                     response.setStatus(400);
+                    adapter.log(request, response, 0);
                     error = true;
                 }
             }
@@ -862,6 +865,7 @@ public class Http11AprProcessor implemen
                     log.error(sm.getString("http11processor.request.process"), t);
                     // 500 - Internal Server Error
                     response.setStatus(500);
+                    adapter.log(request, response, 0);
                     error = true;
                 }
             }
@@ -939,6 +943,7 @@ public class Http11AprProcessor implemen
             log.error(sm.getString("http11processor.request.process"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
 
@@ -976,6 +981,7 @@ public class Http11AprProcessor implemen
             log.error(sm.getString("http11processor.request.finish"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
         try {
@@ -1351,6 +1357,7 @@ public class Http11AprProcessor implemen
             error = true;
             // Send 505; Unsupported HTTP version
             response.setStatus(505);
+            adapter.log(request, response, 0);
         }
 
         MessageBytes methodMB = request.method();
@@ -1448,6 +1455,7 @@ public class Http11AprProcessor implemen
                     error = true;
                     // 501 - Unimplemented
                     response.setStatus(501);
+                    adapter.log(request, response, 0);
                 }
                 startPos = commaPos + 1;
                 commaPos = transferEncodingValue.indexOf(',', startPos);
@@ -1459,6 +1467,7 @@ public class Http11AprProcessor implemen
                 error = true;
                 // 501 - Unimplemented
                 response.setStatus(501);
+                adapter.log(request, response, 0);
             }
         }
 
@@ -1477,6 +1486,7 @@ public class Http11AprProcessor implemen
             error = true;
             // 400 - Bad request
             response.setStatus(400);
+            adapter.log(request, response, 0);
         }
 
         parseHost(valueMB);
@@ -1559,6 +1569,7 @@ public class Http11AprProcessor implemen
                     error = true;
                     // 400 - Bad request
                     response.setStatus(400);
+                    adapter.log(request, response, 0);
                     break;
                 }
                 port = port + (charValue * mult);

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=951093&r1=951092&r2=951093&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Thu Jun  3 18:13:47
2010
@@ -222,6 +222,7 @@ public class Http11NioProcessor extends 
             log.error(sm.getString("http11processor.request.process"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
 
@@ -279,6 +280,7 @@ public class Http11NioProcessor extends 
             log.error(sm.getString("http11processor.request.process"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
 
@@ -370,6 +372,7 @@ public class Http11NioProcessor extends 
                 }
                 // 400 - Bad Request
                 response.setStatus(400);
+                adapter.log(request, response, 0);
                 error = true;
             }
 
@@ -384,6 +387,7 @@ public class Http11NioProcessor extends 
                     }
                     // 400 - Internal Server Error
                     response.setStatus(400);
+                    adapter.log(request, response, 0);
                     error = true;
                 }
             }
@@ -425,6 +429,7 @@ public class Http11NioProcessor extends 
                     log.error(sm.getString("http11processor.request.process"), t);
                     // 500 - Internal Server Error
                     response.setStatus(500);
+                    adapter.log(request, response, 0);
                     error = true;
                 }
             }
@@ -497,6 +502,7 @@ public class Http11NioProcessor extends 
             log.error(sm.getString("http11processor.request.finish"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
         try {
@@ -839,6 +845,7 @@ public class Http11NioProcessor extends 
             error = true;
             // Send 505; Unsupported HTTP version
             response.setStatus(505);
+            adapter.log(request, response, 0);
         }
 
         MessageBytes methodMB = request.method();
@@ -936,6 +943,7 @@ public class Http11NioProcessor extends 
                     error = true;
                     // 501 - Unimplemented
                     response.setStatus(501);
+                    adapter.log(request, response, 0);
                 }
                 startPos = commaPos + 1;
                 commaPos = transferEncodingValue.indexOf(',', startPos);
@@ -947,6 +955,7 @@ public class Http11NioProcessor extends 
                 error = true;
                 // 501 - Unimplemented
                 response.setStatus(501);
+                adapter.log(request, response, 0);
             }
         }
 
@@ -965,6 +974,7 @@ public class Http11NioProcessor extends 
             error = true;
             // 400 - Bad request
             response.setStatus(400);
+            adapter.log(request, response, 0);
         }
 
         parseHost(valueMB);
@@ -1048,6 +1058,7 @@ public class Http11NioProcessor extends 
                     error = true;
                     // 400 - Bad request
                     response.setStatus(400);
+                    adapter.log(request, response, 0);
                     break;
                 }
                 port = port + (charValue * mult);

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=951093&r1=951092&r2=951093&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Thu Jun  3 18:13:47 2010
@@ -226,6 +226,7 @@ public class Http11Processor extends Abs
                 }
                 // 400 - Bad Request
                 response.setStatus(400);
+                adapter.log(request, response, 0);
                 error = true;
             }
 
@@ -240,6 +241,7 @@ public class Http11Processor extends Abs
                     }
                     // 400 - Internal Server Error
                     response.setStatus(400);
+                    adapter.log(request, response, 0);
                     error = true;
                 }
             }
@@ -268,6 +270,7 @@ public class Http11Processor extends Abs
                     log.error(sm.getString("http11processor.request.process"), t);
                     // 500 - Internal Server Error
                     response.setStatus(500);
+                    adapter.log(request, response, 0);
                     error = true;
                 }
             }
@@ -287,6 +290,7 @@ public class Http11Processor extends Abs
                 log.error(sm.getString("http11processor.request.finish"), t);
                 // 500 - Internal Server Error
                 response.setStatus(500);
+                adapter.log(request, response, 0);
                 error = true;
             }
             try {
@@ -347,6 +351,7 @@ public class Http11Processor extends Abs
             log.error(sm.getString("http11processor.request.process"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
 
@@ -379,6 +384,7 @@ public class Http11Processor extends Abs
             log.error(sm.getString("http11processor.request.finish"), t);
             // 500 - Internal Server Error
             response.setStatus(500);
+            adapter.log(request, response, 0);
             error = true;
         }
         try {
@@ -681,6 +687,7 @@ public class Http11Processor extends Abs
                           " Unsupported HTTP version \""+protocolMB+"\"");
             }
             response.setStatus(505);
+            adapter.log(request, response, 0);
         }
 
         MessageBytes methodMB = request.method();
@@ -778,6 +785,7 @@ public class Http11Processor extends Abs
                     error = true;
                     // 501 - Unimplemented
                     response.setStatus(501);
+                    adapter.log(request, response, 0);
                 }
                 startPos = commaPos + 1;
                 commaPos = transferEncodingValue.indexOf(',', startPos);
@@ -793,6 +801,7 @@ public class Http11Processor extends Abs
                               " Unsupported transfer encoding \""+encodingName+"\"");
                 }
                 response.setStatus(501);
+                adapter.log(request, response, 0);
             }
         }
 
@@ -815,6 +824,7 @@ public class Http11Processor extends Abs
                           " host header missing");
             }
             response.setStatus(400);
+            adapter.log(request, response, 0);
         }
 
         parseHost(valueMB);
@@ -1109,6 +1119,7 @@ public class Http11Processor extends Abs
                     error = true;
                     // 400 - Bad request
                     response.setStatus(400);
+                    adapter.log(request, response, 0);
                     break;
                 }
                 port = port + (charValue * mult);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message