aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-07-01 11:08:35 (EDT)
committerThomas Becker2013-07-01 11:08:35 (EDT)
commit260b21f7df79f6b5c4d3b8705998398d1c98ea80 (patch)
tree843725210a13798016b57b8fb9622e95ce7aacb7
parentd2470f61709dc0a3f9a27eb116c97d55442a14ad (diff)
downloadorg.eclipse.jetty.project-260b21f7df79f6b5c4d3b8705998398d1c98ea80.zip
org.eclipse.jetty.project-260b21f7df79f6b5c4d3b8705998398d1c98ea80.tar.gz
org.eclipse.jetty.project-260b21f7df79f6b5c4d3b8705998398d1c98ea80.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.java8
-rw-r--r--jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java5
-rw-r--r--jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/AbstractHTTPSPDYTest.java5
-rw-r--r--jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/ServerHTTPSPDYTest.java7
4 files changed, 18 insertions, 7 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 e02485b..69313ca 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
@@ -56,9 +56,9 @@ public class HttpGenerator
private boolean _noContent = false;
private Boolean _persistent = null;
- private final int _send;
- private final static int SEND_SERVER=0x01;
- private final static int SEND_XPOWEREDBY=0x02;
+ public final int _send;
+ public final static int SEND_SERVER=0x01;
+ public final static int SEND_XPOWEREDBY=0x02;
/* ------------------------------------------------------------------------------- */
@@ -862,7 +862,7 @@ 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");
- private static final byte[][] SEND = new byte[][]{
+ public 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"),
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 4705525..530058c 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
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpGenerator;
+import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.EndPoint;
@@ -157,6 +158,10 @@ public class HttpTransportOverSPDY implements HttpTransport
}
}
+ if (configuration.getSendServerVersion())
+ headers.add(HttpHeader.SERVER.asString(), new String(HttpGenerator.SEND[HttpGenerator.SEND_SERVER]));
+ if(configuration.getSendXPoweredBy())
+ headers.add(HttpHeader.X_POWERED_BY.asString(), new String(HttpGenerator.SEND[HttpGenerator.SEND_XPOWEREDBY]));
boolean close = !hasContent && lastContent;
ReplyInfo reply = new ReplyInfo(headers, close);
reply(stream, reply);
diff --git a/jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/AbstractHTTPSPDYTest.java b/jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/AbstractHTTPSPDYTest.java
index fec3936..de96a4c 100644
--- a/jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/AbstractHTTPSPDYTest.java
+++ b/jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/AbstractHTTPSPDYTest.java
@@ -99,7 +99,10 @@ public abstract class AbstractHTTPSPDYTest
protected HTTPSPDYServerConnector newHTTPSPDYServerConnector(short version)
{
// For these tests, we need the connector to speak HTTP over SPDY even in non-SSL
- HTTPSPDYServerConnector connector = new HTTPSPDYServerConnector(server,version,new HttpConfiguration(), new PushStrategy.None());
+ HttpConfiguration httpConfiguration = new HttpConfiguration();
+ httpConfiguration.setSendServerVersion(true);
+ httpConfiguration.setSendXPoweredBy(true);
+ HTTPSPDYServerConnector connector = new HTTPSPDYServerConnector(server,version, httpConfiguration, new PushStrategy.None());
return connector;
}
diff --git a/jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/ServerHTTPSPDYTest.java b/jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/ServerHTTPSPDYTest.java
index 1c09046..96acd5b 100644
--- a/jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/ServerHTTPSPDYTest.java
+++ b/jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/ServerHTTPSPDYTest.java
@@ -29,7 +29,6 @@ import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
@@ -38,6 +37,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.continuation.ContinuationSupport;
+import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
@@ -57,6 +57,7 @@ import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -100,7 +101,9 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
assertTrue(replyInfo.isClose());
Fields replyHeaders = replyInfo.getHeaders();
- assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
+ assertThat(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"), is(true));
+ assertThat(replyHeaders.get(HttpHeader.SERVER.asString()), is(notNullValue()));
+ assertThat(replyHeaders.get(HttpHeader.X_POWERED_BY.asString()), is(notNullValue()));
replyLatch.countDown();
}
});