434447 Able to create a session after a response.sendRedirect
This commit is contained in:
parent
ce36613604
commit
ca5a086877
|
@ -1397,6 +1397,9 @@ public class Request implements HttpServletRequest
|
|||
if (!create)
|
||||
return null;
|
||||
|
||||
if (getResponse().isCommitted())
|
||||
throw new IllegalStateException("Response is committed");
|
||||
|
||||
if (_sessionManager == null)
|
||||
throw new IllegalStateException("No SessionManager");
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import static org.junit.Assert.assertNull;
|
|||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -712,6 +713,41 @@ public class RequestTest
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionAfterRedirect() throws Exception
|
||||
{
|
||||
Handler handler = new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException,
|
||||
ServletException
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
response.sendRedirect("/foo");
|
||||
try
|
||||
{
|
||||
request.getSession(true);
|
||||
fail("Session should not be created after response committed");
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail("Session creation after response commit should throw IllegalStateException");
|
||||
}
|
||||
}
|
||||
};
|
||||
_server.stop();
|
||||
_server.setHandler(handler);
|
||||
_server.start();
|
||||
String response=_connector.getResponses("GET / HTTP/1.1\n"+
|
||||
"Host: myhost\n"+
|
||||
"Connection: close\n"+
|
||||
"\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartialInput() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue