--- jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Constants.java (original)
+++ jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Constants.java Wed Jul 30 02:26:27 2008
@@ -53,4 +53,12 @@
     public static final int STAGE_ENDED = 7;
 
 
+    /**
+     * If true, custom HTTP status messages will be used in headers.
+     */
+    public static final boolean USE_CUSTOM_STATUS_MSG_IN_HEADER =
+        Boolean.valueOf(System.getProperty(
+                "org.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER",
+                "false")).booleanValue();
+
 }

--- jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalOutputBuffer.java (original)
+++ jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalOutputBuffer.java Wed Jul 30 02:26:27 2008
@@ -448,11 +448,14 @@
         buf[pos++] = Constants.SP;
 
         // Write message
-        String message = response.getMessage();
+        String message = null;
+        if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER) {
+            message = response.getMessage();
+        } 
         if (message == null) {
             write(getMessage(status));
         } else {
-            write(message);
+            write(message.replace('\n', ' ').replace('\r', ' '));
         }
 
         // End the response status line

--- jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkCoyoteHandler.java.org	2005-03-26 20:24:11.000000000 +0100
+++ jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkCoyoteHandler.java	2008-08-18 11:37:00.000000000 +0200
@@ -363,7 +363,10 @@
             mb=MessageBytes.newInstance();
             ep.setNote( tmpMessageBytesNote, mb );
         }
-        String message=res.getMessage();
+        String message=null;
+        if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER) {
+            message = res.getMessage();
+        }
         if( message==null ){
 	    if( System.getSecurityManager() != null ) {
 		message = (String)AccessController.doPrivileged(

--- jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContextValve.java (original)
+++ jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContextValve.java Wed Jul 30 02:26:27 2008
@@ -119,8 +119,7 @@
             || (requestPathMB.equalsIgnoreCase("/META-INF"))
             || (requestPathMB.startsWithIgnoreCase("/WEB-INF/", 0))
             || (requestPathMB.equalsIgnoreCase("/WEB-INF"))) {
-            String requestURI = request.getDecodedRequestURI();
-            notFound(requestURI, response);
+            notFound(response);
             return;
         }
 
@@ -136,8 +135,7 @@
         // Select the Wrapper to be used for this Request
         Wrapper wrapper = request.getWrapper();
         if (wrapper == null) {
-            String requestURI = request.getDecodedRequestURI();
-            notFound(requestURI, response);
+            notFound(response);
             return;
         }
 
@@ -206,13 +204,12 @@
      * application, but currently that code runs at the wrapper level rather
      * than the context level.
      *
-     * @param requestURI The request URI for the requested resource
      * @param response The response we are creating
      */
-    private void notFound(String requestURI, HttpServletResponse response) {
+    private void notFound(HttpServletResponse response) {
 
         try {
-            response.sendError(HttpServletResponse.SC_NOT_FOUND, requestURI);
+            response.sendError(HttpServletResponse.SC_NOT_FOUND);
         } catch (IllegalStateException e) {
             ;
         } catch (IOException e) {

