Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project
This commit is contained in:
commit
47c21e91a8
|
@ -16,6 +16,8 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.eclipse.jetty.server.session.AbstractSession;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -33,9 +35,9 @@ public class NoSqlSession extends AbstractSession
|
|||
private long _lastSync;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public NoSqlSession(NoSqlSessionManager manager, long created, long accessed, String clusterId)
|
||||
public NoSqlSession(NoSqlSessionManager manager, HttpServletRequest request)
|
||||
{
|
||||
super(manager, created,accessed,clusterId);
|
||||
super(manager, request);
|
||||
_manager=manager;
|
||||
save(true);
|
||||
_active.incrementAndGet();
|
||||
|
|
|
@ -117,8 +117,7 @@ public abstract class NoSqlSessionManager extends AbstractSessionManager impleme
|
|||
protected AbstractSession newSession(HttpServletRequest request)
|
||||
{
|
||||
long created=System.currentTimeMillis();
|
||||
String clusterId=getSessionIdManager().newSessionId(request,created);
|
||||
return new NoSqlSession(this,created,created,clusterId);
|
||||
return new NoSqlSession(this,request);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -61,6 +61,8 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
|
|||
|
||||
final static DBObject __version_1 = new BasicDBObject(MongoSessionManager.__VERSION,1);
|
||||
final static DBObject __valid_false = new BasicDBObject(MongoSessionManager.__VALID,false);
|
||||
final static DBObject __valid_true = new BasicDBObject(MongoSessionManager.__VALID,true);
|
||||
|
||||
|
||||
final DBCollection _sessions;
|
||||
protected Server _server;
|
||||
|
@ -434,7 +436,7 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
|
|||
/*
|
||||
* optimize this query to only return the valid variable
|
||||
*/
|
||||
DBObject o = _sessions.findOne(new BasicDBObject("id",sessionId), __valid_false);
|
||||
DBObject o = _sessions.findOne(new BasicDBObject("id",sessionId), __valid_true);
|
||||
|
||||
if ( o != null )
|
||||
{
|
||||
|
|
|
@ -118,7 +118,6 @@ public class MongoSessionManager extends NoSqlSessionManager
|
|||
|
||||
// Form query for upsert
|
||||
BasicDBObject key = new BasicDBObject(__ID,session.getClusterId());
|
||||
key.put(__VALID,true);
|
||||
|
||||
// Form updates
|
||||
BasicDBObject update = new BasicDBObject();
|
||||
|
@ -133,6 +132,7 @@ public class MongoSessionManager extends NoSqlSessionManager
|
|||
upsert = true;
|
||||
version = new Long(1);
|
||||
sets.put(__CREATED,session.getCreationTime());
|
||||
sets.put(__VALID,true);
|
||||
sets.put(getContextKey(__VERSION),version);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.jetty.websocket;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -31,9 +33,6 @@ import org.junit.Before;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
public class SafariWebsocketDraft0Test
|
||||
{
|
||||
private Server server;
|
||||
|
@ -45,7 +44,7 @@ public class SafariWebsocketDraft0Test
|
|||
{
|
||||
// Configure Logging
|
||||
// System.setProperty("org.eclipse.jetty.util.log.class",StdErrLog.class.getName());
|
||||
// System.setProperty("org.eclipse.jetty.LEVEL","DEBUG");
|
||||
System.setProperty("org.eclipse.jetty.websocket.helper.LEVEL","DEBUG");
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.jetty.websocket.helper;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -28,12 +30,13 @@ import java.net.URI;
|
|||
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class SafariD00
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SafariD00.class);
|
||||
private URI uri;
|
||||
private SocketAddress endpoint;
|
||||
private Socket socket;
|
||||
|
@ -54,7 +57,9 @@ public class SafariD00
|
|||
*/
|
||||
public Socket connect() throws IOException
|
||||
{
|
||||
LOG.info("Connecting to endpoint: " + endpoint);
|
||||
socket = new Socket();
|
||||
socket.setTcpNoDelay(true);
|
||||
socket.connect(endpoint,1000);
|
||||
|
||||
out = socket.getOutputStream();
|
||||
|
@ -70,6 +75,7 @@ public class SafariD00
|
|||
*/
|
||||
public void issueHandshake() throws IOException
|
||||
{
|
||||
LOG.debug("Issuing Handshake");
|
||||
StringBuilder req = new StringBuilder();
|
||||
req.append("GET ").append(uri.getPath()).append(" HTTP/1.1\r\n");
|
||||
req.append("Upgrade: WebSocket\r\n");
|
||||
|
@ -80,7 +86,7 @@ public class SafariD00
|
|||
req.append("Sec-WebSocket-Key2: 3? C;7~0 8 \" 3 2105 6 `_ {\r\n");
|
||||
req.append("\r\n");
|
||||
|
||||
// System.out.printf("--- Request ---%n%s",req);
|
||||
LOG.debug("Request:" + req);
|
||||
|
||||
byte reqBytes[] = req.toString().getBytes("UTF-8");
|
||||
byte hixieBytes[] = TypeUtil.fromHexString("e739617916c9daf3");
|
||||
|
@ -96,8 +102,9 @@ public class SafariD00
|
|||
InputStreamReader reader = new InputStreamReader(in);
|
||||
BufferedReader br = new BufferedReader(reader);
|
||||
|
||||
socket.setSoTimeout(5000);
|
||||
socket.setSoTimeout(10000);
|
||||
|
||||
LOG.debug("Reading http header");
|
||||
boolean foundEnd = false;
|
||||
String line;
|
||||
while (!foundEnd)
|
||||
|
@ -114,6 +121,7 @@ public class SafariD00
|
|||
byte hixieHandshakeExpected[] = TypeUtil.fromHexString("c7438d956cf611a6af70603e6fa54809");
|
||||
byte hixieHandshake[] = new byte[hixieHandshakeExpected.length];
|
||||
|
||||
LOG.debug("Reading hixie handshake bytes");
|
||||
int readLen = in.read(hixieHandshake,0,hixieHandshake.length);
|
||||
Assert.assertThat("Read hixie handshake bytes",readLen,is(hixieHandshake.length));
|
||||
}
|
||||
|
@ -123,6 +131,7 @@ public class SafariD00
|
|||
int len = 0;
|
||||
for (String msg : msgs)
|
||||
{
|
||||
LOG.debug("sending message: " + msg);
|
||||
len += (msg.length() + 2);
|
||||
}
|
||||
|
||||
|
@ -141,6 +150,7 @@ public class SafariD00
|
|||
|
||||
public void disconnect() throws IOException
|
||||
{
|
||||
LOG.debug("disconnect");
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.eclipse.jetty.client.ContentExchange;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
|
@ -109,7 +110,8 @@ public abstract class AbstractNewSessionTest
|
|||
String action = request.getParameter("action");
|
||||
if ("create".equals(action))
|
||||
{
|
||||
request.getSession(true);
|
||||
HttpSession session = request.getSession(true);
|
||||
assertTrue(session.isNew());
|
||||
}
|
||||
else if ("old-create".equals(action))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue