@@ -297,6 +297,33 @@ public void putRequestToToadletThatDoesNotSupportPutResultsInHttpStatus405() thr
297297 assertThat (parse (outputStream .toByteArray ()), contains (hasStatus (equalTo (405 ), equalTo ("Method Not Allowed" ))));
298298 }
299299
300+ @ Test
301+ public void pipeliningTwoGetRequestsWithPersistentConnectionsEnabledResultsInTwoHttpStatus200 () throws Exception {
302+ setupInputStream ("GET / HTTP/1.1\r \n \r \n GET / HTTP/1.1\r \n \r \n " );
303+ when (toadletContainer .enablePersistentConnections ()).thenReturn (true );
304+ when (toadletContainer .findToadlet (any ())).thenReturn (homepageToadlet );
305+ ToadletContextImpl .handle (socket , toadletContainer , pageMaker , null , null );
306+ assertThat (parse (outputStream .toByteArray ()), contains (
307+ allOf (hasStatus (200 ), hasBody (equalTo ("GET OK\n " .getBytes (UTF_8 )))),
308+ allOf (hasStatus (200 ), hasBody (equalTo ("GET OK\n " .getBytes (UTF_8 ))))
309+ ));
310+ }
311+
312+ @ Test
313+ public void pipeliningAPutAndAGetRequestResultsInTwoSuccessfulRequests () throws Exception {
314+ setupInputStream ("POST /post-request HTTP/1.1\r \n Content-Length: 0\r \n \r \n GET /get-request HTTP/1.1\r \n \r \n " );
315+ when (toadletContainer .enablePersistentConnections ()).thenReturn (true );
316+ when (toadletContainer .allowPosts ()).thenReturn (true );
317+ postToadlet .allowPostWithoutPassword ();
318+ when (toadletContainer .findToadlet (new URI ("/post-request" ))).thenReturn (postToadlet );
319+ when (toadletContainer .findToadlet (new URI ("/get-request" ))).thenReturn (homepageToadlet );
320+ ToadletContextImpl .handle (socket , toadletContainer , pageMaker , null , null );
321+ assertThat (parse (outputStream .toByteArray ()), contains (
322+ allOf (hasStatus (200 ), hasBody (equalTo ("POST OK\n " .getBytes (UTF_8 )))),
323+ allOf (hasStatus (200 ), hasBody (equalTo ("GET OK\n " .getBytes (UTF_8 ))))
324+ ));
325+ }
326+
300327 private void setupInputStream (String request ) throws IOException {
301328 when (socket .getInputStream ()).thenReturn (new ByteArrayInputStream (request .getBytes (UTF_8 )));
302329 }
0 commit comments