From 7586e5c9e9d31d3495042b917fcd6b14d8a62e03 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 29 Aug 2012 22:42:14 +0200 Subject: [PATCH] Jetty9 - More tests for HTTP over SPDY. --- .../jetty/spdy/http/ServerHTTPSPDYTest.java | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java index c455192257d..786cffe90f4 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java @@ -882,7 +882,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest } @Test - public void testGETWithSmallResponseChunked() throws Exception + public void testGETWithSmallResponseContentChunked() throws Exception { final String pangram1 = "the quick brown fox jumps over the lazy dog"; final String pangram2 = "qualche vago ione tipo zolfo, bromo, sodio"; @@ -1290,4 +1290,44 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); Assert.assertTrue(responseLatch.await(5, TimeUnit.SECONDS)); } + + @Test + public void testPOSTThenResponseWithoutReadingContent() throws Exception + { + final byte[] data = new byte[1000]; + final CountDownLatch latch = new CountDownLatch(1); + Session session = startClient(version, startHTTPServer(version, new AbstractHandler() + { + @Override + public void handle(String target, final Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) + throws IOException, ServletException + { + request.setHandled(true); + latch.countDown(); + } + }), null); + + Headers headers = new Headers(); + headers.put(HTTPSPDYHeader.METHOD.name(version), "POST"); + headers.put(HTTPSPDYHeader.URI.name(version), "/foo"); + headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); + headers.put(HTTPSPDYHeader.SCHEME.name(version), "http"); + headers.put(HTTPSPDYHeader.HOST.name(version), "localhost:" + connector.getLocalPort()); + final CountDownLatch responseLatch = new CountDownLatch(1); + Stream stream = session.syn(new SynInfo(headers, false), new StreamFrameListener.Adapter() + { + @Override + public void onReply(Stream stream, ReplyInfo replyInfo) + { + Headers replyHeaders = replyInfo.getHeaders(); + Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version)).value().contains("200")); + responseLatch.countDown(); + } + }).get(5, TimeUnit.SECONDS); + stream.data(new BytesDataInfo(data, false)); + stream.data(new BytesDataInfo(data, true)).get(5, TimeUnit.SECONDS); + + Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); + Assert.assertTrue(responseLatch.await(5, TimeUnit.SECONDS)); + } }