413066 SPDY HEAD requests don't send response body anymore

This commit is contained in:
Thomas Becker 2013-07-16 14:35:45 +02:00
parent 7b162460d7
commit b858f266d6
2 changed files with 13 additions and 2 deletions

View File

@ -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;

View File

@ -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));