From: markt Date: Tue, 12 Jan 2010 21:36:49 +0000 (+0000) Subject: Fix bug 48004. Allow applications to set the server header. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=73d3af627f68f3eacc154b142c52859fc6bf3779;p=tomcat7.0 Fix bug 48004. Allow applications to set the server header. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@898527 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/coyote/http11/Http11AprProcessor.java b/java/org/apache/coyote/http11/Http11AprProcessor.java index dc80c5803..a53076b99 100644 --- a/java/org/apache/coyote/http11/Http11AprProcessor.java +++ b/java/org/apache/coyote/http11/Http11AprProcessor.java @@ -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); } diff --git a/java/org/apache/coyote/http11/Http11NioProcessor.java b/java/org/apache/coyote/http11/Http11NioProcessor.java index ede09ee2d..9d9a44262 100644 --- a/java/org/apache/coyote/http11/Http11NioProcessor.java +++ b/java/org/apache/coyote/http11/Http11NioProcessor.java @@ -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); } diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index c4354b451..37c0df808 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -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); } diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml index e56433063..b4ec6d4ae 100644 --- a/webapps/docs/config/http.xml +++ b/webapps/docs/config/http.xml @@ -364,8 +364,12 @@ -

The Server header for the http response. - Unless you are paranoid, you won't need this feature. +

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 + Apache-Coyote/1.1 is used. Unless you are paranoid, you won't + need this feature.