aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-07-01 15:57:22 (EDT)
committerThomas Becker2013-07-01 15:57:22 (EDT)
commit8b31188ca7b0856584b75569347011df385fbe94 (patch)
treec59a1cd0b9c3cddf8732eecc0f788cf02662551c
parent260b21f7df79f6b5c4d3b8705998398d1c98ea80 (diff)
downloadorg.eclipse.jetty.project-8b31188ca7b0856584b75569347011df385fbe94.zip
org.eclipse.jetty.project-8b31188ca7b0856584b75569347011df385fbe94.tar.gz
org.eclipse.jetty.project-8b31188ca7b0856584b75569347011df385fbe94.tar.bz2
405424 add X-Powered-By and Server header to SPDY
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java23
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Server.java4
-rw-r--r--jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java4
4 files changed, 19 insertions, 16 deletions
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java
index 69313ca..af09866 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java
@@ -55,18 +55,19 @@ public class HttpGenerator
private long _contentPrepared = 0;
private boolean _noContent = false;
private Boolean _persistent = null;
-
- public final int _send;
- public final static int SEND_SERVER=0x01;
- public final static int SEND_XPOWEREDBY=0x02;
+
+ private final int _send;
+ private final static int SEND_SERVER = 0x01;
+ private final static int SEND_XPOWEREDBY = 0x02;
/* ------------------------------------------------------------------------------- */
- public static void setServerVersion(String version)
+ public static void setJettyVersion(String serverVersion)
{
- SEND[SEND_SERVER]=StringUtil.getBytes("Server: Jetty("+version+")\015\012");
- SEND[SEND_XPOWEREDBY]=StringUtil.getBytes("X-Powered-By: Jetty("+version+")\015\012");
- SEND[SEND_SERVER|SEND_XPOWEREDBY]=StringUtil.getBytes("Server: Jetty("+version+")\015\012X-Powered-By: Jetty("+version+")\015\012");
+ SEND[SEND_SERVER] = StringUtil.getBytes("Server: " + serverVersion + "\015\012");
+ SEND[SEND_XPOWEREDBY] = StringUtil.getBytes("X-Powered-By: " + serverVersion + "\015\012");
+ SEND[SEND_SERVER | SEND_XPOWEREDBY] = StringUtil.getBytes("Server: " + serverVersion + "\015\012X-Powered-By: " +
+ serverVersion + "\015\012");
}
/* ------------------------------------------------------------------------------- */
@@ -862,9 +863,9 @@ public class HttpGenerator
private static final byte[] HTTP_1_1_SPACE = StringUtil.getBytes(HttpVersion.HTTP_1_1+" ");
private static final byte[] CRLF = StringUtil.getBytes("\015\012");
private static final byte[] TRANSFER_ENCODING_CHUNKED = StringUtil.getBytes("Transfer-Encoding: chunked\015\012");
- public static final byte[][] SEND = new byte[][]{
- new byte[0],
- StringUtil.getBytes("Server: Jetty(9.x.x)\015\012"),
+ private static final byte[][] SEND = new byte[][]{
+ new byte[0],
+ StringUtil.getBytes("Server: Jetty(9.x.x)\015\012"),
StringUtil.getBytes("X-Powered-By: Jetty(9.x.x)\015\012"),
StringUtil.getBytes("Server: Jetty(9.x.x)\015\012X-Powered-By: Jetty(9.x.x)\015\012")
};
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java
index 85f3b90..2feb032 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.jetty.http.HttpScheme;
+import org.eclipse.jetty.util.Jetty;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
@@ -40,6 +41,8 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
@ManagedObject("HTTP Configuration")
public class HttpConfiguration
{
+ public static final String SERVER_VERSION = "Jetty(" + Jetty.VERSION + ")";
+
private List<Customizer> _customizers=new CopyOnWriteArrayList<>();
private int _outputBufferSize=32*1024;
private int _requestHeaderSize=8*1024;
@@ -50,7 +53,6 @@ public class HttpConfiguration
private boolean _sendServerVersion = true; //send Server: header
private boolean _sendXPoweredBy = false; //send X-Powered-By: header
private boolean _sendDateHeader = false; //send Date: header
-
public interface Customizer
{
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
index cc377f0..31a67de 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
@@ -281,8 +281,8 @@ public class Server extends HandlerWrapper implements Attributes
ShutdownMonitor.getInstance().start(); // initialize
- LOG.info("jetty-"+getVersion());
- HttpGenerator.setServerVersion(getVersion());
+ LOG.info("jetty-" + getVersion());
+ HttpGenerator.setJettyVersion(HttpConfiguration.SERVER_VERSION);
MultiException mex=new MultiException();
try
diff --git a/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java b/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java
index 530058c..4a830bc 100644
--- a/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java
+++ b/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java
@@ -159,9 +159,9 @@ public class HttpTransportOverSPDY implements HttpTransport
}
if (configuration.getSendServerVersion())
- headers.add(HttpHeader.SERVER.asString(), new String(HttpGenerator.SEND[HttpGenerator.SEND_SERVER]));
+ headers.add(HttpHeader.SERVER.asString(), HttpConfiguration.SERVER_VERSION);
if(configuration.getSendXPoweredBy())
- headers.add(HttpHeader.X_POWERED_BY.asString(), new String(HttpGenerator.SEND[HttpGenerator.SEND_XPOWEREDBY]));
+ headers.add(HttpHeader.X_POWERED_BY.asString(), HttpConfiguration.SERVER_VERSION);
boolean close = !hasContent && lastContent;
ReplyInfo reply = new ReplyInfo(headers, close);
reply(stream, reply);