aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-07-16 08:35:45 (EDT)
committerThomas Becker2013-07-16 08:36:02 (EDT)
commitb858f266d68440f201fa170f12a4f6ce4c8491fe (patch)
treedfc305b4c3bb637738c9776fb7cedeeee37f7753
parent7b162460d7246ee1515d1d9a7cc9e842eaa44c0c (diff)
downloadorg.eclipse.jetty.project-b858f266d68440f201fa170f12a4f6ce4c8491fe.zip
org.eclipse.jetty.project-b858f266d68440f201fa170f12a4f6ce4c8491fe.tar.gz
org.eclipse.jetty.project-b858f266d68440f201fa170f12a4f6ce4c8491fe.tar.bz2
413066 SPDY HEAD requests don't send response body anymore
-rw-r--r--jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java7
-rw-r--r--jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/http/ServerHTTPSPDYTest.java8
2 files changed, 13 insertions, 2 deletions
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 08cd325..036df04 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
@@ -29,6 +29,7 @@ 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.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.EndPoint;
@@ -116,7 +117,10 @@ public class HttpTransportOverSPDY implements HttpTransport
// info!=null content!=null lastContent==false reply, commit with content
// info!=null content!=null lastContent==true reply, commit with content and complete
- boolean hasContent = BufferUtil.hasContent(content);
+ short version = stream.getSession().getVersion();
+ boolean hasContent = BufferUtil.hasContent(content) && HttpMethod.HEAD.name().equals(requestHeaders.get
+ (HTTPSPDYHeader
+ .METHOD.name(version)));
if (info != null)
{
@@ -128,7 +132,6 @@ public class HttpTransportOverSPDY implements HttpTransport
LOG.warn("Committed response twice.", exception);
return;
}
- short version = stream.getSession().getVersion();
Fields headers = new Fields();
HttpVersion httpVersion = HttpVersion.HTTP_1_1;
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 96acd5b..22c0f5a 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
@@ -62,6 +62,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
{
@@ -213,6 +214,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
assertEquals("HEAD", httpRequest.getMethod());
assertEquals(path, target);
assertEquals(path, httpRequest.getRequestURI());
+ httpResponse.getWriter().write("body that shouldn't be sent on a HEAD request");
handlerLatch.countDown();
}
}), null);
@@ -229,6 +231,12 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200"));
replyLatch.countDown();
}
+
+ @Override
+ public void onData(Stream stream, DataInfo dataInfo)
+ {
+ fail("HEAD request shouldn't send any data");
+ }
});
assertTrue(handlerLatch.await(5, TimeUnit.SECONDS));
assertTrue(replyLatch.await(5, TimeUnit.SECONDS));