Merge branch 'jetty-9.4.x' of github.com:eclipse/jetty.project into jetty-9.4.x
This commit is contained in:
commit
13259d2dc0
|
@ -366,8 +366,7 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore
|
||||||
//these candidates will be for our node
|
//these candidates will be for our node
|
||||||
BasicDBObject query = new BasicDBObject();
|
BasicDBObject query = new BasicDBObject();
|
||||||
query.append(__ID,new BasicDBObject("$in", candidates));
|
query.append(__ID,new BasicDBObject("$in", candidates));
|
||||||
query.append(__EXPIRY, new BasicDBObject("$gt", 0));
|
query.append(__EXPIRY, new BasicDBObject("$gt", 0).append("$lt", upperBound));
|
||||||
query.append(__EXPIRY, new BasicDBObject("$lt", upperBound));
|
|
||||||
|
|
||||||
DBCursor verifiedExpiredSessions = null;
|
DBCursor verifiedExpiredSessions = null;
|
||||||
try
|
try
|
||||||
|
|
|
@ -271,7 +271,7 @@ public class HttpInput extends ServletInputStream implements Runnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Caclulate minimum request rate for DOS protection
|
// Calculate minimum request rate for DOS protection
|
||||||
long minRequestDataRate = _channelState.getHttpChannel().getHttpConfiguration().getMinRequestDataRate();
|
long minRequestDataRate = _channelState.getHttpChannel().getHttpConfiguration().getMinRequestDataRate();
|
||||||
if (minRequestDataRate > 0 && _firstByteTimeStamp != -1)
|
if (minRequestDataRate > 0 && _firstByteTimeStamp != -1)
|
||||||
{
|
{
|
||||||
|
@ -858,6 +858,7 @@ public class HttpInput extends ServletInputStream implements Runnable
|
||||||
{
|
{
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
|
// TODO is this necessary to add here?
|
||||||
_channelState.getHttpChannel().getResponse().getHttpFields().add(HttpConnection.CONNECTION_CLOSE);
|
_channelState.getHttpChannel().getResponse().getHttpFields().add(HttpConnection.CONNECTION_CLOSE);
|
||||||
listener.onError(error);
|
listener.onError(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,8 @@ public class SessionHandler extends ScopedHandler
|
||||||
* Session id path parameter name.
|
* Session id path parameter name.
|
||||||
* Defaults to <code>jsessionid</code>, but can be set with the
|
* Defaults to <code>jsessionid</code>, but can be set with the
|
||||||
* <code>org.eclipse.jetty.servlet.SessionIdPathParameterName</code> context init parameter.
|
* <code>org.eclipse.jetty.servlet.SessionIdPathParameterName</code> context init parameter.
|
||||||
* If set to null or "none" no URL rewriting will be done.
|
* If context init param is "none", or setSessionIdPathParameterName is called with null or "none",
|
||||||
|
* no URL rewriting will be done.
|
||||||
*/
|
*/
|
||||||
public final static String __SessionIdPathParameterNameProperty = "org.eclipse.jetty.servlet.SessionIdPathParameterName";
|
public final static String __SessionIdPathParameterNameProperty = "org.eclipse.jetty.servlet.SessionIdPathParameterName";
|
||||||
public final static String __DefaultSessionIdPathParameterName = "jsessionid";
|
public final static String __DefaultSessionIdPathParameterName = "jsessionid";
|
||||||
|
|
|
@ -124,6 +124,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
"org.eclipse.jetty.jaas.", // webapp cannot change jaas classes
|
"org.eclipse.jetty.jaas.", // webapp cannot change jaas classes
|
||||||
"org.eclipse.jetty.websocket.", // webapp cannot change / replace websocket classes
|
"org.eclipse.jetty.websocket.", // webapp cannot change / replace websocket classes
|
||||||
"org.eclipse.jetty.util.log.", // webapp should use server log
|
"org.eclipse.jetty.util.log.", // webapp should use server log
|
||||||
|
"org.eclipse.jetty.servlet.StatisticsServlet", // webapp cannot change stats servlet
|
||||||
"org.eclipse.jetty.servlet.DefaultServlet", // webapp cannot change default servlets
|
"org.eclipse.jetty.servlet.DefaultServlet", // webapp cannot change default servlets
|
||||||
"org.eclipse.jetty.jsp.JettyJspServlet", //webapp cannot change jetty jsp servlet
|
"org.eclipse.jetty.jsp.JettyJspServlet", //webapp cannot change jetty jsp servlet
|
||||||
"org.eclipse.jetty.servlets.PushCacheFilter", //must be loaded by container classpath
|
"org.eclipse.jetty.servlets.PushCacheFilter", //must be loaded by container classpath
|
||||||
|
@ -163,6 +164,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
"-org.eclipse.jetty.jndi.", // don't hide naming classes
|
"-org.eclipse.jetty.jndi.", // don't hide naming classes
|
||||||
"-org.eclipse.jetty.jaas.", // don't hide jaas classes
|
"-org.eclipse.jetty.jaas.", // don't hide jaas classes
|
||||||
"-org.eclipse.jetty.servlets.", // don't hide jetty servlets
|
"-org.eclipse.jetty.servlets.", // don't hide jetty servlets
|
||||||
|
"-org.eclipse.jetty.servlet.StatisticsServlet", // don't hide stats servlet
|
||||||
"-org.eclipse.jetty.servlet.DefaultServlet", // don't hide default servlet
|
"-org.eclipse.jetty.servlet.DefaultServlet", // don't hide default servlet
|
||||||
"-org.eclipse.jetty.servlet.NoJspServlet", // don't hide noJspServlet servlet
|
"-org.eclipse.jetty.servlet.NoJspServlet", // don't hide noJspServlet servlet
|
||||||
"-org.eclipse.jetty.jsp.", //don't hide jsp servlet
|
"-org.eclipse.jetty.jsp.", //don't hide jsp servlet
|
||||||
|
|
|
@ -51,9 +51,4 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
|
||||||
return FileTestHelper.newSessionDataStoreFactory();
|
return FileTestHelper.newSessionDataStoreFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNewSession() throws Exception
|
|
||||||
{
|
|
||||||
super.testNewSession();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,4 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
|
||||||
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
|
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNewSession() throws Exception
|
|
||||||
{
|
|
||||||
super.testNewSession();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,12 +59,4 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
|
||||||
factory.setCache(__testSupport.getCache());
|
factory.setCache(__testSupport.getCache());
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testNewSession() throws Exception
|
|
||||||
{
|
|
||||||
super.testNewSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,13 +59,4 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
|
||||||
factory.setCache(__testSupport.getCache());
|
factory.setCache(__testSupport.getCache());
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testNewSession() throws Exception
|
|
||||||
{
|
|
||||||
super.testNewSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,6 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNewSession() throws Exception
|
|
||||||
{
|
|
||||||
super.testNewSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.jetty.server.session.AbstractNonClusteredSessionScavengingTes
|
||||||
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NonClusteredSessionScavengingTest
|
* NonClusteredSessionScavengingTest
|
||||||
|
@ -51,10 +50,4 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
|
||||||
{
|
{
|
||||||
return MongoTestHelper.newSessionDataStoreFactory();
|
return MongoTestHelper.newSessionDataStoreFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNewSession() throws Exception
|
|
||||||
{
|
|
||||||
super.testNewSession();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,62 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
|
||||||
{
|
{
|
||||||
server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testImmortalSession() throws Exception
|
||||||
|
{
|
||||||
|
String servletMapping = "/server";
|
||||||
|
int scavengePeriod = 3;
|
||||||
|
int maxInactivePeriod = 0;
|
||||||
|
|
||||||
|
DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory();
|
||||||
|
cacheFactory.setEvictionPolicy(SessionCache.NEVER_EVICT);
|
||||||
|
SessionDataStoreFactory storeFactory = createSessionDataStoreFactory();
|
||||||
|
((AbstractSessionDataStoreFactory)storeFactory).setGracePeriodSec(scavengePeriod);
|
||||||
|
|
||||||
|
TestServer server = new TestServer(0, maxInactivePeriod, scavengePeriod,
|
||||||
|
cacheFactory, storeFactory);
|
||||||
|
ServletContextHandler context = server.addContext("/");
|
||||||
|
context.addServlet(TestServlet.class, servletMapping);
|
||||||
|
String contextPath = "";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
server.start();
|
||||||
|
int port=server.getPort();
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
client.start();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//create an immortal session
|
||||||
|
ContentResponse response = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=create");
|
||||||
|
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
|
||||||
|
String sessionCookie = response.getHeaders().get("Set-Cookie");
|
||||||
|
assertTrue(sessionCookie != null);
|
||||||
|
// Mangle the cookie, replacing Path with $Path, etc.
|
||||||
|
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
|
||||||
|
|
||||||
|
// Let's wait for the scavenger to run
|
||||||
|
pause(2*scavengePeriod);
|
||||||
|
|
||||||
|
// Test that the session is still there
|
||||||
|
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=old-test");
|
||||||
|
request.header("Cookie", sessionCookie);
|
||||||
|
response = request.send();
|
||||||
|
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
client.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
server.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class TestServlet extends HttpServlet
|
public static class TestServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
String id;
|
String id;
|
||||||
|
@ -135,6 +189,12 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
|
||||||
assertNotNull(s);
|
assertNotNull(s);
|
||||||
assertFalse(s.getId().equals(id));
|
assertFalse(s.getId().equals(id));
|
||||||
}
|
}
|
||||||
|
else if ("old-test".equals(action))
|
||||||
|
{
|
||||||
|
HttpSession s = request.getSession(false);
|
||||||
|
assertNotNull(s);
|
||||||
|
assertTrue(s.getId().equals(id));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
|
|
Loading…
Reference in New Issue