Fix bug 48004. Allow applications to set the server header.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 12 Jan 2010 21:36:49 +0000 (21:36 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 12 Jan 2010 21:36:49 +0000 (21:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@898527 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/Http11AprProcessor.java
java/org/apache/coyote/http11/Http11NioProcessor.java
java/org/apache/coyote/http11/Http11Processor.java
webapps/docs/config/http.xml

index dc80c58..a53076b 100644 (file)
@@ -1688,8 +1688,10 @@ public class Http11AprProcessor implements ActionHook {
 
         // Add server header
         if (server != null) {
+            // Always overrides anything the app might set
             headers.setValue("Server").setString(server);
-        } else {
+        } else if (headers.getValue("Server") == null) {
+            // If app didn't set the header, use the default
             outputBuffer.write(Constants.SERVER_BYTES);
         }
 
index ede09ee..9d9a442 100644 (file)
@@ -1187,8 +1187,10 @@ public class Http11NioProcessor extends AbstractHttp11Processor implements Actio
 
         // Add server header
         if (server != null) {
+            // Always overrides anything the app might set
             headers.setValue("Server").setString(server);
-        } else {
+        } else if (headers.getValue("Server") == null) {
+            // If app didn't set the header, use the default
             outputBuffer.write(Constants.SERVER_BYTES);
         }
 
index c4354b4..37c0df8 100644 (file)
@@ -855,8 +855,10 @@ public class Http11Processor extends AbstractHttp11Processor implements ActionHo
 
         // Add server header
         if (server != null) {
+            // Always overrides anything the app might set
             headers.setValue("Server").setString(server);
-        } else {
+        } else if (headers.getValue("Server") == null) {
+            // If app didn't set the header, use the default
             outputBuffer.write(Constants.SERVER_BYTES);
         }
 
index e564330..b4ec6d4 100644 (file)
     </attribute>
 
     <attribute name="server" required="false">
-      <p>The Server header for the http response.
-         Unless you are paranoid, you won't need this feature.
+      <p>Overrides the Server header for the http response. If set, the value
+      for this attribute overrides the Tomcat default and any Server header set
+      by a web application. If not set, any value specified by the application
+      is used. If the application does not specify a value then
+      <code>Apache-Coyote/1.1</code> is used. Unless you are paranoid, you won't
+      need this feature.
       </p>
     </attribute>