jetty-9 one connector passing most tests
This commit is contained in:
parent
d6ef039f2c
commit
96b5c05674
|
@ -30,7 +30,6 @@ import org.eclipse.jetty.server.handler.DefaultHandler;
|
|||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.RequestLogHandler;
|
||||
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
||||
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
@ -42,7 +41,11 @@ public class LikeJettyXml
|
|||
String jetty_home = System.getProperty("jetty.home","../jetty-distribution/target/distribution");
|
||||
System.setProperty("jetty.home",jetty_home);
|
||||
|
||||
Server server = new Server();
|
||||
// Setup Threadpool
|
||||
QueuedThreadPool threadPool = new QueuedThreadPool();
|
||||
threadPool.setMaxThreads(500);
|
||||
|
||||
Server server = new Server(threadPool);
|
||||
server.setDumpAfterStart(true);
|
||||
server.setDumpBeforeStop(true);
|
||||
|
||||
|
@ -53,22 +56,17 @@ public class LikeJettyXml
|
|||
server.addBean(mbContainer,true);
|
||||
mbContainer.addBean(new Log());
|
||||
|
||||
// Setup Threadpool
|
||||
QueuedThreadPool threadPool = new QueuedThreadPool();
|
||||
threadPool.setMaxThreads(500);
|
||||
server.setThreadPool(threadPool);
|
||||
|
||||
// Setup Connectors
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server);
|
||||
connector.setPort(8080);
|
||||
connector.setIdleTimeout(30000);
|
||||
connector.setConfidentialPort(8443);
|
||||
connector.getHttpConfig().setConfidentialPort(8443);
|
||||
// TODO connector.setStatsOn(false);
|
||||
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
||||
SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector();
|
||||
SelectChannelConnector ssl_connector = new SelectChannelConnector(server,true);
|
||||
ssl_connector.setPort(8443);
|
||||
SslContextFactory cf = ssl_connector.getSslContextFactory();
|
||||
cf.setKeyStorePath(jetty_home + "/etc/keystore");
|
||||
|
|
|
@ -16,9 +16,7 @@ package org.eclipse.jetty.embedded;
|
|||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -31,18 +29,16 @@ public class ManyConnectors
|
|||
{
|
||||
Server server = new Server();
|
||||
|
||||
SelectChannelConnector connector0 = new SelectChannelConnector();
|
||||
SelectChannelConnector connector0 = new SelectChannelConnector(server);
|
||||
connector0.setPort(8080);
|
||||
connector0.setIdleTimeout(30000);
|
||||
connector0.setRequestHeaderSize(8192);
|
||||
|
||||
SelectChannelConnector connector1 = new SelectChannelConnector();
|
||||
SelectChannelConnector connector1 = new SelectChannelConnector(server);
|
||||
connector1.setHost("127.0.0.1");
|
||||
connector1.setPort(8888);
|
||||
connector1.setExecutor(new QueuedThreadPool(20));
|
||||
connector1.setName("admin");
|
||||
|
||||
SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector();
|
||||
SelectChannelConnector ssl_connector = new SelectChannelConnector(server,true);
|
||||
String jetty_home = System.getProperty("jetty.home","../jetty-distribution/target/distribution");
|
||||
System.setProperty("jetty.home",jetty_home);
|
||||
ssl_connector.setPort(8443);
|
||||
|
|
|
@ -15,10 +15,10 @@ package org.eclipse.jetty.embedded;
|
|||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ public class ManyContexts
|
|||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server);
|
||||
connector.setPort(8080);
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
|||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
public class ManyServletContexts
|
||||
{
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
package org.eclipse.jetty.embedded;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
public class OneWebApp
|
||||
|
@ -24,7 +24,7 @@ public class OneWebApp
|
|||
{
|
||||
Server server = new Server();
|
||||
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(server);
|
||||
connector.setPort(Integer.getInteger("jetty.port",8080).intValue());
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
|
|
@ -27,13 +27,13 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.LocalHttpConnector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.handler.GzipHandler;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -56,14 +56,13 @@ public class GzipHandlerTest
|
|||
"et cursus magna. Donec orci enim, molestie a lobortis eu, imperdiet vitae neque.";
|
||||
|
||||
private Server _server;
|
||||
private LocalHttpConnector _connector;
|
||||
private LocalConnector _connector;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
|
||||
_connector = new LocalHttpConnector();
|
||||
_connector = new LocalConnector(_server);
|
||||
_server.addConnector(_connector);
|
||||
|
||||
Handler testHandler = new AbstractHandler()
|
||||
|
|
|
@ -130,12 +130,12 @@ public abstract class AbstractAsyncConnection implements AsyncConnection
|
|||
public void onOpen()
|
||||
{
|
||||
LOG.debug("{} opened",this);
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
LOG.debug("{} closed",this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.nio.channels.ByteChannel;
|
|||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.GatheringByteChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.BrokenBarrierException;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.io.IOException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
|
@ -28,7 +29,6 @@ import org.eclipse.jetty.io.AbstractEndPoint;
|
|||
import org.eclipse.jetty.io.AsyncConnection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.io.ReadInterest;
|
||||
import org.eclipse.jetty.io.RuntimeIOException;
|
||||
|
@ -45,7 +45,7 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
* wants unencrypted data.
|
||||
* <p>
|
||||
* The connector uses an {@link AsyncEndPoint} (typically {@link SelectChannelEndPoint}) as
|
||||
* it's source/sink of encrypted data. It then provides an endpoint via {@link #getSslEndPoint()} to
|
||||
* it's source/sink of encrypted data. It then provides an endpoint via {@link #getDecryptedEndPoint()} to
|
||||
* expose a source/sink of unencrypted data to another connection (eg HttpConnection).
|
||||
* <p>
|
||||
* The design of this class is based on a clear separation between the passive methods, which do not block nor schedule any
|
||||
|
@ -95,7 +95,7 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
return _sslEngine;
|
||||
}
|
||||
|
||||
public AsyncEndPoint getSslEndPoint()
|
||||
public AsyncEndPoint getDecryptedEndPoint()
|
||||
{
|
||||
return _decryptedEndPoint;
|
||||
}
|
||||
|
@ -112,6 +112,8 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
|
||||
if (_sslEngine.getUseClientMode())
|
||||
_decryptedEndPoint.write(null, new Callback.Empty<>(), BufferUtil.EMPTY_BUFFER);
|
||||
|
||||
getDecryptedEndPoint().getAsyncConnection().onOpen();
|
||||
}
|
||||
catch (SSLException x)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -13,13 +20,6 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class AsyncByteArrayEndPointTest
|
||||
{
|
||||
private ScheduledExecutorService _scheduler;
|
||||
|
|
|
@ -80,6 +80,13 @@ public class SelectChannelEndPointInterestsTest
|
|||
{
|
||||
return new AbstractAsyncConnection(endPoint, threadPool)
|
||||
{
|
||||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
super.onOpen();
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFillable()
|
||||
{
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
@ -7,6 +13,7 @@ import java.net.Socket;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
|
@ -21,12 +28,6 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
|
||||
{
|
||||
|
@ -58,8 +59,8 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
|
|||
engine.setUseClientMode(false);
|
||||
SslConnection sslConnection = new SslConnection(__byteBufferPool, _threadPool, endpoint, engine);
|
||||
|
||||
AsyncConnection appConnection = super.newConnection(channel,sslConnection.getSslEndPoint());
|
||||
sslConnection.getSslEndPoint().setAsyncConnection(appConnection);
|
||||
AsyncConnection appConnection = super.newConnection(channel,sslConnection.getDecryptedEndPoint());
|
||||
sslConnection.getDecryptedEndPoint().setAsyncConnection(appConnection);
|
||||
_manager.connectionOpened(appConnection);
|
||||
|
||||
return sslConnection;
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
|
||||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -42,12 +48,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SelectChannelEndPointTest
|
||||
{
|
||||
protected CountDownLatch _lastEndPointLatch;
|
||||
|
@ -124,6 +124,13 @@ public class SelectChannelEndPointTest
|
|||
super(endp, _threadPool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
super.onOpen();
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onFillable()
|
||||
{
|
||||
|
|
|
@ -13,10 +13,12 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
@ -54,8 +56,8 @@ public class SslConnectionTest
|
|||
engine.setUseClientMode(false);
|
||||
SslConnection sslConnection = new SslConnection(__byteBufferPool, _threadPool, endpoint, engine);
|
||||
|
||||
AsyncConnection appConnection = new TestConnection(sslConnection.getSslEndPoint());
|
||||
sslConnection.getSslEndPoint().setAsyncConnection(appConnection);
|
||||
AsyncConnection appConnection = new TestConnection(sslConnection.getDecryptedEndPoint());
|
||||
sslConnection.getDecryptedEndPoint().setAsyncConnection(appConnection);
|
||||
connectionOpened(appConnection);
|
||||
|
||||
return sslConnection;
|
||||
|
@ -112,9 +114,17 @@ public class SslConnectionTest
|
|||
super(endp, _threadPool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
super.onOpen();
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
|
|
@ -21,14 +21,11 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.Attribute;
|
||||
|
|
|
@ -15,13 +15,10 @@ package org.eclipse.jetty.jmx;
|
|||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import javax.management.AttributeNotFoundException;
|
||||
import javax.management.MBeanAttributeInfo;
|
||||
import javax.management.MBeanException;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.MBeanOperationInfo;
|
||||
import javax.management.MBeanParameterInfo;
|
||||
import javax.management.ReflectionException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.eclipse.jetty.security;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.security.auth.Subject;
|
||||
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.jetty.security.authentication;
|
|||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
|
|
|
@ -13,8 +13,12 @@
|
|||
|
||||
package org.eclipse.jetty.security;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -23,6 +27,7 @@ import org.eclipse.jetty.http.HttpMethod;
|
|||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -35,9 +40,6 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1441 $ $Date: 2010-04-02 12:28:17 +0200 (Fri, 02 Apr 2010) $
|
||||
*/
|
||||
|
@ -59,9 +61,8 @@ public class DataConstraintsTest
|
|||
_connector.getHttpConfig().setIntegralScheme("FTP");
|
||||
_connector.getHttpConfig().setConfidentialPort(9999);
|
||||
_connector.getHttpConfig().setConfidentialScheme("SPDY");
|
||||
_connectorS = new LocalConnector(_server)
|
||||
_connectorS = new LocalConnector(_server,new HttpConfiguration(null,false)
|
||||
{
|
||||
|
||||
@Override
|
||||
public void customize(Request request) throws IOException
|
||||
{
|
||||
|
@ -81,7 +82,7 @@ public class DataConstraintsTest
|
|||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
},null,null,null,null,false,0);
|
||||
_server.setConnectors(new Connector[]{_connector,_connectorS});
|
||||
|
||||
ContextHandler _context = new ContextHandler();
|
||||
|
|
|
@ -74,24 +74,21 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
this(server,null);
|
||||
}
|
||||
|
||||
public AbstractConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("sslContextFactory") SslContextFactory sslContextFactory)
|
||||
public AbstractConnector(Server server,SslContextFactory sslContextFactory)
|
||||
{
|
||||
this(server,null,null,null,sslContextFactory, sslContextFactory!=null, 0);
|
||||
this(server,null,null,null,null, sslContextFactory, sslContextFactory!=null, 0);
|
||||
}
|
||||
|
||||
public AbstractConnector(
|
||||
@Name("server") Server server,
|
||||
@Name("ssl") boolean ssl)
|
||||
public AbstractConnector(Server server,boolean ssl)
|
||||
{
|
||||
this(server,null,null,null,ssl?new SslContextFactory():null, ssl, 0);
|
||||
this(server,null,null,null,null, ssl?new SslContextFactory():null, ssl, 0);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param server The server this connector will be added to. Must not be null.
|
||||
* @param httpConfig TODO
|
||||
* @param executor An executor for this connector or null to use the servers executor
|
||||
* @param scheduler A scheduler for this connector or null to use the servers scheduler
|
||||
* @param pool A buffer pool for this connector or null to use a default {@link ByteBufferPool}
|
||||
|
@ -101,12 +98,12 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
*/
|
||||
public AbstractConnector(
|
||||
Server server,
|
||||
HttpConfiguration httpConfig,
|
||||
Executor executor,
|
||||
ScheduledExecutorService scheduler,
|
||||
ByteBufferPool pool,
|
||||
SslContextFactory sslContextFactory,
|
||||
boolean ssl,
|
||||
int acceptors)
|
||||
boolean ssl, int acceptors)
|
||||
{
|
||||
_server=server;
|
||||
_executor=executor!=null?executor:_server.getThreadPool();
|
||||
|
@ -123,6 +120,9 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
_ssl=ssl;
|
||||
_sslContextFactory=sslContextFactory!=null?sslContextFactory:(ssl?new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH):null);
|
||||
|
||||
// TODO make this pluggable
|
||||
_httpConfig = httpConfig!=null?httpConfig:new HttpConfiguration(_sslContextFactory,ssl);
|
||||
|
||||
addBean(_server,false);
|
||||
addBean(_executor,executor==null);
|
||||
addBean(_scheduler,scheduler==null);
|
||||
|
@ -135,9 +135,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
addBean(_sslContextFactory,false);
|
||||
setSoLingerTime(30000);
|
||||
}
|
||||
|
||||
// TODO make this pluggable
|
||||
_httpConfig = new HttpConfiguration(_sslContextFactory,ssl);
|
||||
addBean(_httpConfig,httpConfig==null);
|
||||
|
||||
if (acceptors<=0)
|
||||
acceptors=Math.max(1,(Runtime.getRuntime().availableProcessors()) / 4);
|
||||
|
@ -190,8 +188,8 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
SSLEngine engine = _sslContextFactory.createSSLEngine(endp.getRemoteAddress());
|
||||
SslConnection ssl_connection = new SslConnection(getByteBufferPool(), getExecutor(), endp, engine);
|
||||
|
||||
AsyncConnection http_connection = new HttpConnection(_httpConfig,this,ssl_connection.getSslEndPoint());
|
||||
ssl_connection.getSslEndPoint().setAsyncConnection(http_connection);
|
||||
AsyncConnection http_connection = new HttpConnection(_httpConfig,this,ssl_connection.getDecryptedEndPoint());
|
||||
ssl_connection.getDecryptedEndPoint().setAsyncConnection(http_connection);
|
||||
return ssl_connection;
|
||||
}
|
||||
return new HttpConnection(_httpConfig,this,endp);
|
||||
|
|
|
@ -33,7 +33,7 @@ public abstract class AbstractNetConnector extends AbstractConnector implements
|
|||
public AbstractNetConnector(Server server, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool, SslContextFactory sslContextFactory,
|
||||
boolean ssl, int acceptors)
|
||||
{
|
||||
super(server,executor,scheduler,pool,sslContextFactory,ssl,acceptors);
|
||||
super(server,null,executor,scheduler,pool,sslContextFactory,ssl, acceptors);
|
||||
}
|
||||
|
||||
public AbstractNetConnector(Server server, SslContextFactory sslContextFactory)
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.PrintWriter;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletInputStream;
|
||||
|
@ -380,6 +381,7 @@ public abstract class HttpChannel
|
|||
{
|
||||
try
|
||||
{
|
||||
_state.completed();
|
||||
if (_expect100Continue)
|
||||
{
|
||||
LOG.debug("100 continues not sent");
|
||||
|
@ -413,7 +415,6 @@ public abstract class HttpChannel
|
|||
}
|
||||
finally
|
||||
{
|
||||
_state.completed();
|
||||
_request.setHandled(true);
|
||||
completed();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
|
|
|
@ -2,8 +2,6 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
@ -14,7 +12,6 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.server.ssl.SslCertificates;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -308,14 +308,21 @@ public class HttpConnection extends AbstractAsyncConnection
|
|||
{
|
||||
setCurrentConnection(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
super.onOpen();
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
super.onClose();
|
||||
_channel.onClose();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,15 +17,19 @@ import java.io.IOException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.io.AsyncByteArrayEndPoint;
|
||||
import org.eclipse.jetty.io.AsyncConnection;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
public class LocalConnector extends AbstractConnector
|
||||
{
|
||||
|
@ -35,7 +39,26 @@ public class LocalConnector extends AbstractConnector
|
|||
|
||||
public LocalConnector(Server server)
|
||||
{
|
||||
super(server,null,null,null,null, false,-1);
|
||||
super(server,null,null,null,null, null,false, -1);
|
||||
}
|
||||
|
||||
public LocalConnector(Server server, boolean ssl)
|
||||
{
|
||||
super(server,ssl);
|
||||
}
|
||||
|
||||
public LocalConnector(Server server, HttpConfiguration httpConfig, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool,
|
||||
SslContextFactory sslContextFactory, boolean ssl, int acceptors)
|
||||
{
|
||||
super(server,httpConfig,executor,scheduler,pool,sslContextFactory,ssl, acceptors);
|
||||
}
|
||||
|
||||
public LocalConnector(Server server, SslContextFactory sslContextFactory)
|
||||
{
|
||||
super(server,sslContextFactory);
|
||||
}
|
||||
|
||||
{
|
||||
setIdleTimeout(30000);
|
||||
}
|
||||
|
||||
|
@ -48,6 +71,9 @@ public class LocalConnector extends AbstractConnector
|
|||
/** Sends requests and get responses based on thread activity.
|
||||
* Returns all the responses received once the thread activity has
|
||||
* returned to the level it was before the requests.
|
||||
* <p>
|
||||
* This methods waits until the connection is closed or
|
||||
* is idle for 1s before returning the responses.
|
||||
* @param requests the requests
|
||||
* @return the responses
|
||||
* @throws Exception if the requests fail
|
||||
|
@ -61,7 +87,12 @@ public class LocalConnector extends AbstractConnector
|
|||
/** Sends requests and get responses based on thread activity.
|
||||
* Returns all the responses received once the thread activity has
|
||||
* returned to the level it was before the requests.
|
||||
* <p>
|
||||
* This methods waits until the connection is closed or
|
||||
* an idle period before returning the responses.
|
||||
* @param requests the requests
|
||||
* @param idleFor The time the response stream must be idle for before returning
|
||||
* @param units The units of idleFor
|
||||
* @return the responses
|
||||
* @throws Exception if the requests fail
|
||||
*/
|
||||
|
@ -74,19 +105,27 @@ public class LocalConnector extends AbstractConnector
|
|||
/** Sends requests and get's responses based on thread activity.
|
||||
* Returns all the responses received once the thread activity has
|
||||
* returned to the level it was before the requests.
|
||||
* <p>
|
||||
* This methods waits until the connection is closed or
|
||||
* is idle for 1s before returning the responses.
|
||||
* @param requestsBuffer the requests
|
||||
* @return the responses
|
||||
* @throws Exception if the requests fail
|
||||
*/
|
||||
public ByteBuffer getResponses(ByteBuffer requestsBuffer) throws Exception
|
||||
{
|
||||
return getResponses(requestsBuffer,100,TimeUnit.MILLISECONDS);
|
||||
return getResponses(requestsBuffer,1000,TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/** Sends requests and get's responses based on thread activity.
|
||||
* Returns all the responses received once the thread activity has
|
||||
* returned to the level it was before the requests.
|
||||
* <p>
|
||||
* This methods waits until the connection is closed or
|
||||
* an idle period before returning the responses.
|
||||
* @param requestsBuffer the requests
|
||||
* @param idleFor The time the response stream must be idle for before returning
|
||||
* @param units The units of idleFor
|
||||
* @return the responses
|
||||
* @throws Exception if the requests fail
|
||||
*/
|
||||
|
@ -195,8 +234,8 @@ public class LocalConnector extends AbstractConnector
|
|||
|
||||
public void waitUntilClosedOrIdleFor(long idleFor,TimeUnit units)
|
||||
{
|
||||
Thread.yield();
|
||||
int size=getOutput().remaining();
|
||||
|
||||
while (isOpen())
|
||||
{
|
||||
try
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.eclipse.jetty.io.ByteBufferPool;
|
|||
import org.eclipse.jetty.io.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.SelectorManager;
|
||||
import org.eclipse.jetty.io.SelectorManager.ManagedSelector;
|
||||
import org.eclipse.jetty.server.Connector.NetConnector;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import javax.net.ssl.SSLContext;
|
|||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
|
||||
|
|
|
@ -13,21 +13,8 @@
|
|||
|
||||
package org.eclipse.jetty.server.ssl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.io.AsyncConnection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.RuntimeIOException;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
//========================================================================
|
||||
//Copyright (c) Webtide LLC
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -87,6 +88,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"5;\015\012"+
|
||||
"12345\015\012"+
|
||||
|
@ -100,6 +102,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"5;\015\012"+
|
||||
"ABCDE\015\012"+
|
||||
|
@ -124,6 +127,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"0\015\012\015\012");
|
||||
|
||||
|
@ -137,10 +141,12 @@ public class HttpConnectionTest
|
|||
{
|
||||
String responsePOST=connector.getResponses("POST /R1 HTTP/1.1\015\012"+
|
||||
"Host: localhost\015\012"+
|
||||
"Connection: close\015\012"+
|
||||
"\015\012");
|
||||
|
||||
String responseHEAD=connector.getResponses("HEAD /R1 HTTP/1.1\015\012"+
|
||||
"Host: localhost\015\012"+
|
||||
"Connection: close\015\012"+
|
||||
"\015\012");
|
||||
|
||||
assertThat(responsePOST,startsWith(responseHEAD.substring(0,responseHEAD.length()-2)));
|
||||
|
@ -148,6 +154,7 @@ public class HttpConnectionTest
|
|||
|
||||
responsePOST=connector.getResponses("POST /R1 HTTP/1.1\015\012"+
|
||||
"Host: localhost\015\012"+
|
||||
"Connection: close\015\012"+
|
||||
"\015\012");
|
||||
|
||||
assertThat(responsePOST,startsWith(responseHEAD.substring(0,responseHEAD.length()-2)));
|
||||
|
@ -162,16 +169,19 @@ public class HttpConnectionTest
|
|||
|
||||
response=connector.getResponses("GET http://localhost:EXPECTED_NUMBER_FORMAT_EXCEPTION/ HTTP/1.1\n"+
|
||||
"Host: localhost\n"+
|
||||
"Connection: close\015\012"+
|
||||
"\015\012");
|
||||
checkContains(response,0,"HTTP/1.1 400");
|
||||
|
||||
response=connector.getResponses("GET /bad/encoding%1 HTTP/1.1\n"+
|
||||
"Host: localhost\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012");
|
||||
checkContains(response,0,"HTTP/1.1 400");
|
||||
|
||||
response=connector.getResponses("GET % HTTP/1.1\n"+
|
||||
"Host: localhost\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012");
|
||||
checkContains(response,0,"HTTP/1.1 400");
|
||||
}
|
||||
|
@ -187,6 +197,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"5;\015\012"+
|
||||
"12345\015\012"+
|
||||
|
@ -211,6 +222,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain; charset=utf-8\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"5;\015\012"+
|
||||
"12345\015\012"+
|
||||
|
@ -225,6 +237,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain; charset = iso-8859-1 ; other=value\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"5;\015\012"+
|
||||
"12345\015\012"+
|
||||
|
@ -239,6 +252,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain; charset=unknown\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"5;\015\012"+
|
||||
"12345\015\012"+
|
||||
|
@ -281,6 +295,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Content-Type: text/plain; charset=utf-8\n"+
|
||||
"Content-Length: 10\n"+
|
||||
"Connection: close\n"+
|
||||
"\n"+
|
||||
"abcdefghij\n";
|
||||
|
||||
|
@ -527,6 +542,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain; charset=utf-8\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"5;\015\012"+
|
||||
"12345\015\012"+
|
||||
|
@ -543,6 +559,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain; charset=utf-8\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"5;\015\012"+
|
||||
"12345\015\012"+
|
||||
|
@ -554,6 +571,7 @@ public class HttpConnectionTest
|
|||
"Host: localhost\n"+
|
||||
"Transfer-Encoding: chunked\n"+
|
||||
"Content-Type: text/plain; charset=utf-8\n"+
|
||||
"Connection: close\n"+
|
||||
"\015\012"+
|
||||
"5;\015\012"+
|
||||
"12345\015\012"+
|
||||
|
@ -585,7 +603,7 @@ public class HttpConnectionTest
|
|||
|
||||
response=connector.getResponses("CONNECT www.webtide.com:8080 HTTP/1.1\n"+
|
||||
"Host: myproxy:8888\015\012"+
|
||||
"\015\012");
|
||||
"\015\012",200,TimeUnit.MILLISECONDS);
|
||||
checkContains(response,offset,"HTTP/1.1 200");
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ package org.eclipse.jetty.server;
|
|||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
@ -24,8 +26,6 @@ import org.eclipse.jetty.util.Utf8StringBuilder;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class HttpWriterTest
|
||||
{
|
||||
private HttpWriter _writer;
|
||||
|
|
|
@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
|
@ -360,7 +361,7 @@ public class RFC2616Test
|
|||
|
||||
// Default Host
|
||||
offset=0;
|
||||
response=connector.getResponses("GET http://VirtualHost:8888/path/R1 HTTP/1.1\n"+"Host: wronghost\n"+"\n");
|
||||
response=connector.getResponses("GET http://VirtualHost:8888/path/R1 HTTP/1.1\n"+"Host: wronghost\n"+"Connection: close\n"+"\n");
|
||||
offset=checkContains(response,offset,"HTTP/1.1 200","Default host")+1;
|
||||
offset=checkContains(response,offset,"Virtual Dump","virtual host")+1;
|
||||
offset=checkContains(response,offset,"pathInfo=/path/R1","Default host")+1;
|
||||
|
@ -374,14 +375,14 @@ public class RFC2616Test
|
|||
|
||||
// Default Host
|
||||
offset=0;
|
||||
response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: localhost\n"+"\n");
|
||||
response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: localhost\n"+"Connection: close\n"+"\n");
|
||||
offset=checkContains(response,offset,"HTTP/1.1 200","Default host")+1;
|
||||
offset=checkContains(response,offset,"Dump HttpHandler","Default host")+1;
|
||||
offset=checkContains(response,offset,"pathInfo=/path/R1","Default host")+1;
|
||||
|
||||
// Virtual Host
|
||||
offset=0;
|
||||
response=connector.getResponses("GET /path/R2 HTTP/1.1\n"+"Host: VirtualHost\n"+"\n");
|
||||
response=connector.getResponses("GET /path/R2 HTTP/1.1\n"+"Host: VirtualHost\n"+"Connection: close\n"+"\n");
|
||||
offset=checkContains(response,offset,"HTTP/1.1 200","Default host")+1;
|
||||
offset=checkContains(response,offset,"Virtual Dump","virtual host")+1;
|
||||
offset=checkContains(response,offset,"pathInfo=/path/R2","Default host")+1;
|
||||
|
@ -395,14 +396,14 @@ public class RFC2616Test
|
|||
|
||||
// Virtual Host
|
||||
offset=0;
|
||||
response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: VirtualHost\n"+"\n");
|
||||
response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: VirtualHost\n"+"Connection: close\n"+"\n");
|
||||
offset=checkContains(response,offset,"HTTP/1.1 200","2. virtual host field")+1;
|
||||
offset=checkContains(response,offset,"Virtual Dump","2. virtual host field")+1;
|
||||
offset=checkContains(response,offset,"pathInfo=/path/R1","2. virtual host field")+1;
|
||||
|
||||
// Virtual Host case insensitive
|
||||
offset=0;
|
||||
response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: ViRtUalhOst\n"+"\n");
|
||||
response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: ViRtUalhOst\n"+"Connection: close\n"+"\n");
|
||||
offset=checkContains(response,offset,"HTTP/1.1 200","2. virtual host field")+1;
|
||||
offset=checkContains(response,offset,"Virtual Dump","2. virtual host field")+1;
|
||||
offset=checkContains(response,offset,"pathInfo=/path/R1","2. virtual host field")+1;
|
||||
|
@ -422,7 +423,7 @@ public class RFC2616Test
|
|||
int offset=0;
|
||||
|
||||
offset=0;
|
||||
response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host: localhost\n"+"\n");
|
||||
response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host: localhost\n"+"\n",250,TimeUnit.MILLISECONDS);
|
||||
offset=checkContains(response,offset,"HTTP/1.1 200 OK\015\012","8.1.2 default")+10;
|
||||
checkContains(response,offset,"Content-Length: ","8.1.2 default");
|
||||
|
||||
|
@ -754,19 +755,19 @@ public class RFC2616Test
|
|||
|
||||
// HTTP/1.0 OK with no host
|
||||
offset=0;
|
||||
response=connector.getResponses("GET /R1 HTTP/1.0\n"+"\n");
|
||||
response=connector.getResponses("GET /R1 HTTP/1.0\n"+"Connection: close\n"+"\n");
|
||||
offset=checkContains(response,offset,"HTTP/1.1 200","200")+1;
|
||||
|
||||
offset=0;
|
||||
response=connector.getResponses("GET /R1 HTTP/1.1\n"+"\n");
|
||||
response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Connection: close\n"+"\n");
|
||||
offset=checkContains(response,offset,"HTTP/1.1 400","400")+1;
|
||||
|
||||
offset=0;
|
||||
response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host: localhost\n"+"\n");
|
||||
response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host: localhost\n"+"Connection: close\n"+"\n");
|
||||
offset=checkContains(response,offset,"HTTP/1.1 200","200")+1;
|
||||
|
||||
offset=0;
|
||||
response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host:\n"+"\n");
|
||||
response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host:\n"+"Connection: close\n"+"\n");
|
||||
offset=checkContains(response,offset,"HTTP/1.1 200","200")+1;
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,13 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -112,6 +118,7 @@ public class RequestTest
|
|||
String request="GET /?param=%ZZaaa HTTP/1.1\r\n"+
|
||||
"Host: whatever\r\n"+
|
||||
"Content-Type: text/html;charset=utf8\n"+
|
||||
"Connection: close\n"+
|
||||
"\n";
|
||||
|
||||
String responses=_connector.getResponses(request);
|
||||
|
@ -158,6 +165,7 @@ public class RequestTest
|
|||
"Host: whatever\r\n"+
|
||||
"Content-Type: multipart/form-data; boundary=\"AaB03x\"\r\n"+
|
||||
"Content-Length: "+multipart.getBytes().length+"\r\n"+
|
||||
"Connection: close\r\n"+
|
||||
"\r\n"+
|
||||
multipart;
|
||||
|
||||
|
@ -183,6 +191,7 @@ public class RequestTest
|
|||
String request="GET /?param=aaa%E7bbb HTTP/1.1\r\n"+
|
||||
"Host: whatever\r\n"+
|
||||
"Content-Type: text/html;charset=utf8\n"+
|
||||
"Connection: close\n"+
|
||||
"\n";
|
||||
|
||||
String responses=_connector.getResponses(request);
|
||||
|
@ -203,6 +212,7 @@ public class RequestTest
|
|||
String request="GET / HTTP/1.1\r\n"+
|
||||
"Host: whatever.com:\r\n"+
|
||||
"Content-Type: text/html;charset=utf8\n"+
|
||||
"Connection: close\n"+
|
||||
"\n";
|
||||
|
||||
String responses=_connector.getResponses(request);
|
||||
|
@ -245,6 +255,7 @@ public class RequestTest
|
|||
"GET / HTTP/1.1\n"+
|
||||
"Host: whatever\n"+
|
||||
"Content-Type: text/html; other=foo ; blah=\"charset=wrong;\" ; charset = \" x=z; \" ; more=values \n"+
|
||||
"Connection: close\n"+
|
||||
"\n"
|
||||
);
|
||||
|
||||
|
@ -638,6 +649,7 @@ public class RequestTest
|
|||
response=_connector.getResponses(
|
||||
"GET / HTTP/1.1\n"+
|
||||
"Host: whatever\n"+
|
||||
"Connection: close\n"+
|
||||
"\n"
|
||||
);
|
||||
assertTrue(response.startsWith("HTTP/1.1 200 OK"));
|
||||
|
@ -649,6 +661,7 @@ public class RequestTest
|
|||
"GET / HTTP/1.1\n"+
|
||||
"Host: whatever\n"+
|
||||
"Cookie: name=quoted=\\\"value\\\"\n" +
|
||||
"Connection: close\n"+
|
||||
"\n"
|
||||
);
|
||||
assertTrue(response.startsWith("HTTP/1.1 200 OK"));
|
||||
|
@ -661,6 +674,7 @@ public class RequestTest
|
|||
"GET / HTTP/1.1\n"+
|
||||
"Host: whatever\n"+
|
||||
"Cookie: name=value; other=\"quoted=;value\"\n" +
|
||||
"Connection: close\n"+
|
||||
"\n"
|
||||
);
|
||||
assertTrue(response.startsWith("HTTP/1.1 200 OK"));
|
||||
|
@ -682,6 +696,7 @@ public class RequestTest
|
|||
"Host: whatever\n"+
|
||||
"Other: header\n"+
|
||||
"Cookie: name=value; other=\"quoted=;value\"\n" +
|
||||
"Connection: close\n"+
|
||||
"\n"
|
||||
);
|
||||
assertTrue(response.startsWith("HTTP/1.1 200 OK"));
|
||||
|
@ -705,6 +720,7 @@ public class RequestTest
|
|||
"Host: whatever\n"+
|
||||
"Other: header\n"+
|
||||
"Cookie: name=value; other=\"othervalue\"\n" +
|
||||
"Connection: close\n"+
|
||||
"\n"
|
||||
);
|
||||
assertTrue(response.startsWith("HTTP/1.1 200 OK"));
|
||||
|
@ -756,6 +772,7 @@ public class RequestTest
|
|||
"Host: whatever\n"+
|
||||
"Other: header\n"+
|
||||
"Cookie: __utmz=14316.133020.1.1.utr=gna.de|ucn=(real)|utd=reral|utct=/games/hen-one,gnt-50-ba-keys:key,2072262.html\n"+
|
||||
"Connection: close\n"+
|
||||
"\n"
|
||||
);
|
||||
assertTrue(response.startsWith("HTTP/1.1 200 OK"));
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
@ -24,6 +29,7 @@ import java.util.Locale;
|
|||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -45,11 +51,6 @@ import org.junit.Before;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -81,6 +82,13 @@ public class ResponseTest
|
|||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
super.onOpen();
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFillable()
|
||||
{
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -20,6 +23,7 @@ import java.io.PrintWriter;
|
|||
import java.net.Socket;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.CyclicBarrier;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -36,9 +40,6 @@ import org.junit.Before;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SelectChannelStatisticsTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SelectChannelStatisticsTest.class);
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ public class ContextHandlerCollectionTest
|
|||
|
||||
for(String host : requestHosts)
|
||||
{
|
||||
connector.getResponses("GET / HTTP/1.1\n" + "Host: "+host+"\n\n");
|
||||
connector.getResponses("GET / HTTP/1.1\n" + "Host: "+host+"\nConnection:close\n\n");
|
||||
if(succeed)
|
||||
assertTrue("'"+host+"' should have been handled.",handler.isHandled());
|
||||
else
|
||||
|
|
|
@ -376,7 +376,7 @@ public class ContextHandlerTest
|
|||
{
|
||||
server.start();
|
||||
|
||||
String response = connector.getResponses("GET / HTTP/1.1\n" + "Host: www.example.com.\n\n");
|
||||
String response = connector.getResponses("GET / HTTP/1.1\n" + "Host: www.example.com.\nConnection:close\n\n");
|
||||
|
||||
Assert.assertTrue(response.indexOf("Goodbye")>0);
|
||||
Assert.assertTrue(response.indexOf("dead")<0);
|
||||
|
@ -398,7 +398,7 @@ public class ContextHandlerTest
|
|||
IsHandledHandler handler = (IsHandledHandler)context.getHandler();
|
||||
for(String host : requestHosts)
|
||||
{
|
||||
connector.getResponses("GET / HTTP/1.1\n" + "Host: "+host+"\n\n");
|
||||
connector.getResponses("GET / HTTP/1.1\n" + "Host: "+host+"\nConnection:close\n\n");
|
||||
if(succeed)
|
||||
assertTrue("'"+host+"' should have been handled.",handler.isHandled());
|
||||
else
|
||||
|
|
|
@ -11,11 +11,6 @@
|
|||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
// JettyTest.java --
|
||||
//
|
||||
// Junit test that shows the Jetty SSL bug.
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.server.ssl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
|
@ -45,14 +45,15 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -82,14 +83,14 @@ public class SSLEngineTest
|
|||
private static final int BODY_SIZE=300;
|
||||
|
||||
private Server server;
|
||||
private SslSelectChannelConnector connector;
|
||||
private SelectChannelConnector connector;
|
||||
|
||||
|
||||
@Before
|
||||
public void startServer() throws Exception
|
||||
{
|
||||
server=new Server();
|
||||
connector=new SslSelectChannelConnector(server);
|
||||
connector=new SelectChannelConnector(server,true);
|
||||
String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath();
|
||||
|
||||
connector.setPort(0);
|
||||
|
@ -110,6 +111,36 @@ public class SSLEngineTest
|
|||
server.join();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHelloWorld() throws Exception
|
||||
{
|
||||
server.setHandler(new HelloWorldHandler());
|
||||
server.start();
|
||||
|
||||
SSLContext ctx=SSLContext.getInstance("TLS");
|
||||
ctx.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom());
|
||||
|
||||
int port=connector.getLocalPort();
|
||||
|
||||
Socket client=ctx.getSocketFactory().createSocket("localhost",port);
|
||||
OutputStream os=client.getOutputStream();
|
||||
|
||||
String request =
|
||||
"GET / HTTP/1.1\r\n"+
|
||||
"Host: localhost:"+port+"\r\n"+
|
||||
"Connection: close\r\n"+
|
||||
"\r\n";
|
||||
|
||||
os.write(request.getBytes());
|
||||
os.flush();
|
||||
|
||||
String response = IO.toString(client.getInputStream());
|
||||
|
||||
assertThat(response,Matchers.containsString("200 OK"));
|
||||
assertThat(response,Matchers.containsString(HELLO_WORLD));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBigResponse() throws Exception
|
||||
{
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
|
|||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SSLSelectChannelConnectorLoadTest
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletInputStream;
|
||||
|
@ -43,12 +42,9 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.io.AsyncConnection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.SelectorManager.ManagedSelector;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.security.KeyStore;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
|
|
@ -34,16 +34,12 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.eclipse.jetty.http.HttpContent;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.io.WriterOutputStream;
|
||||
import org.eclipse.jetty.server.AbstractConnector;
|
||||
import org.eclipse.jetty.server.HttpConnection;
|
||||
import org.eclipse.jetty.server.HttpChannel;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Dispatcher;
|
||||
import org.eclipse.jetty.server.HttpChannel;
|
||||
import org.eclipse.jetty.server.HttpOutput;
|
||||
import org.eclipse.jetty.server.InclusiveByteRange;
|
||||
import org.eclipse.jetty.server.ResourceCache;
|
||||
|
@ -778,9 +774,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
}
|
||||
else
|
||||
{
|
||||
// TODO sometimes we should be direct!
|
||||
Connector connector = HttpChannel.getCurrentHttpChannel().getConnector();
|
||||
// TODO either make this more targeted and/or configurable or just get rid of the choice
|
||||
direct=!(connector instanceof SslConnector);
|
||||
direct=false;
|
||||
content_length=content.getContentLength();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import javax.servlet.FilterConfig;
|
|||
import javax.servlet.FilterRegistration;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.eclipse.jetty.servlet.Holder.Source;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.io.IOException;
|
|||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
import org.eclipse.jetty.http.PathMap;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
|
|
|
@ -28,9 +28,9 @@ import java.util.Stack;
|
|||
import javax.servlet.MultipartConfigElement;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRegistration;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.ServletSecurityElement;
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
|
@ -12,17 +10,11 @@ import javax.servlet.DispatcherType;
|
|||
import javax.servlet.Filter;
|
||||
import javax.servlet.Servlet;
|
||||
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.Attributes;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
|
|
|
@ -12,7 +12,11 @@ package org.eclipse.jetty.servlet;
|
|||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -31,9 +35,6 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* This tests verifies that merging of queryStrings works when dispatching
|
||||
* Requests via {@link Continuation} multiple times.
|
||||
|
|
|
@ -12,9 +12,15 @@ package org.eclipse.jetty.servlet;
|
|||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -24,6 +30,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
|
@ -35,11 +42,6 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* This tests the correct functioning of the AsyncContext
|
||||
*
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
|
|
|
@ -20,18 +20,17 @@
|
|||
|
||||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.Registration;
|
||||
import javax.servlet.ServletRegistration;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @version $Rev$ $Date$
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Enumeration;
|
|||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
package org.eclipse.jetty.servlets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
|
|
@ -33,8 +33,8 @@ import org.eclipse.jetty.continuation.Continuation;
|
|||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.continuation.ContinuationSupport;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.gzip.CompressedResponseWrapper;
|
||||
import org.eclipse.jetty.http.gzip.AbstractCompressedStream;
|
||||
import org.eclipse.jetty.http.gzip.CompressedResponseWrapper;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.gzip.CompressedResponseWrapper;
|
||||
import org.eclipse.jetty.http.gzip.AbstractCompressedStream;
|
||||
import org.eclipse.jetty.http.gzip.CompressedResponseWrapper;
|
||||
import org.eclipse.jetty.io.UncheckedPrintWriter;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.Map;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
|
|
|
@ -18,6 +18,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.Servlet;
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.servlets;
|
|||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
|
|
|
@ -28,9 +28,9 @@ import java.io.InputStream;
|
|||
import java.net.URI;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
package org.eclipse.jetty.servlets;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
|
|
@ -14,17 +14,13 @@
|
|||
package org.eclipse.jetty.servlets;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -32,9 +28,8 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.ServletTester;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.junit.After;
|
||||
|
|
|
@ -12,6 +12,8 @@ package org.eclipse.jetty.servlets;
|
|||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -27,8 +29,6 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
public class PipelineHelper
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(PipelineHelper.class);
|
||||
|
|
|
@ -21,16 +21,16 @@ import java.io.FileInputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.EnumSet;
|
||||
import javax.servlet.DispatcherType;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.ServletTester;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.net.URL;
|
|||
import java.util.EnumSet;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -28,10 +29,9 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.servlet.ServletTester;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -35,18 +35,17 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.Inflater;
|
||||
import javax.servlet.DispatcherType;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
import org.eclipse.jetty.servlets.MultipartFilterTest.TestServletParameterMap;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.servlet.ServletTester;
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
import org.eclipse.jetty.toolchain.test.IO;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
|
|
|
@ -15,8 +15,8 @@ package org.eclipse.jetty.util.annotation;
|
|||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
|
|
|
@ -23,8 +23,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.SecureRandom;
|
||||
|
|
|
@ -12,6 +12,11 @@ package org.eclipse.jetty.util.ssl;
|
|||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.KeyStore;
|
||||
|
@ -24,11 +29,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
public class SslContextFactoryTest
|
||||
{
|
||||
|
|
|
@ -14,11 +14,7 @@
|
|||
package org.eclipse.jetty.webapp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashSet;
|
||||
|
@ -30,11 +26,7 @@ import java.util.Set;
|
|||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRegistration;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.descriptor.JspConfigDescriptor;
|
||||
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
|
||||
import javax.servlet.descriptor.TaglibDescriptor;
|
||||
|
||||
import org.eclipse.jetty.security.ConstraintAware;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
|
@ -43,7 +35,6 @@ import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
|||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.servlet.Holder;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler.JspConfig;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler.JspPropertyGroup;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler.TagLib;
|
||||
|
@ -53,7 +44,6 @@ import org.eclipse.jetty.util.LazyList;
|
|||
import org.eclipse.jetty.util.Loader;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.xml.XmlParser;
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
import java.security.PermissionCollection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashMap;
|
||||
|
@ -45,7 +44,6 @@ import org.eclipse.jetty.servlet.ServletHandler;
|
|||
import org.eclipse.jetty.util.LazyList;
|
||||
import org.eclipse.jetty.util.Loader;
|
||||
import org.eclipse.jetty.util.MultiException;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -111,7 +111,7 @@ public class WebSocketClientSelectorManager extends SelectorManager
|
|||
}
|
||||
};
|
||||
endPoint.setAsyncConnection(sslConnection);
|
||||
AsyncEndPoint sslEndPoint = sslConnection.getSslEndPoint();
|
||||
AsyncEndPoint sslEndPoint = sslConnection.getDecryptedEndPoint();
|
||||
sslEndPointRef.set(sslEndPoint);
|
||||
|
||||
startHandshake(engine);
|
||||
|
|
|
@ -77,6 +77,13 @@ public abstract class WebSocketAsyncConnection extends AbstractAsyncConnection i
|
|||
this.writes = new AtomicLong(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
super.onOpen();
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
|
|
|
@ -354,7 +354,7 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock
|
|||
// Create connection
|
||||
HttpConnection http = HttpConnection.getCurrentConnection();
|
||||
AsyncEndPoint endp = http.getEndPoint();
|
||||
Executor executor = http.getConnector().findExecutor();
|
||||
Executor executor = http.getConnector().getExecutor();
|
||||
ByteBufferPool bufferPool = http.getConnector().getByteBufferPool();
|
||||
WebSocketServerAsyncConnection connection = new WebSocketServerAsyncConnection(endp,executor,scheduler,websocket.getPolicy(),bufferPool,this);
|
||||
// Tell jetty about the new connection
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SimpleServletServer
|
|||
{
|
||||
// Configure Server
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector();
|
||||
connector = new SelectChannelConnector(server);
|
||||
server.addConnector(connector);
|
||||
|
||||
ServletContextHandler context = new ServletContextHandler();
|
||||
|
|
|
@ -158,14 +158,12 @@ public class WebSocketLoadRFC6455Test
|
|||
@BeforeClass
|
||||
public static void startServer() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
|
||||
_connector = new SelectChannelConnector();
|
||||
_server.addConnector(_connector);
|
||||
|
||||
QueuedThreadPool threadPool = new QueuedThreadPool(200);
|
||||
threadPool.setMaxStopTimeMs(1000);
|
||||
_server.setThreadPool(threadPool);
|
||||
_server = new Server(threadPool);
|
||||
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_server.addConnector(_connector);
|
||||
|
||||
WebSocketHandler wsHandler = new WebSocketHandler.Simple(MyEchoSocket.class);
|
||||
wsHandler.setHandler(new DefaultHandler());
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Arrays;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
@ -95,7 +96,7 @@ public class WebSocketOverSSLTest
|
|||
private void startServer(final Object websocket) throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
SslSelectChannelConnector connector = new SslSelectChannelConnector();
|
||||
SelectChannelConnector connector = new SelectChannelConnector(_server,true);
|
||||
_server.addConnector(connector);
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStorePath(MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath());
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ExampleEchoServer
|
|||
public ExampleEchoServer(int port)
|
||||
{
|
||||
server = new Server();
|
||||
connector = new SelectChannelConnector();
|
||||
connector = new SelectChannelConnector(server);
|
||||
connector.setPort(port);
|
||||
|
||||
server.addConnector(connector);
|
||||
|
|
|
@ -13,6 +13,13 @@
|
|||
|
||||
package org.eclipse.jetty.xml;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -20,14 +27,6 @@ import java.util.Map;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class XmlConfigurationTest
|
||||
{
|
||||
protected String _configure="org/eclipse/jetty/xml/configure.xml";
|
||||
|
|
|
@ -76,6 +76,7 @@ public abstract class ContinuationBase
|
|||
protected void doSuspendResume() throws Exception
|
||||
{
|
||||
String response=process("suspend=200&resume=0",null);
|
||||
System.err.println(response);
|
||||
assertContains("RESUMED",response);
|
||||
assertNotContains("history: onTimeout",response);
|
||||
assertContains("history: onComplete",response);
|
||||
|
@ -243,6 +244,7 @@ public abstract class ContinuationBase
|
|||
Socket socket = new Socket("localhost",port);
|
||||
socket.setSoTimeout(10000);
|
||||
socket.getOutputStream().write(request.getBytes("UTF-8"));
|
||||
socket.getOutputStream().flush();
|
||||
|
||||
response = toString(socket.getInputStream());
|
||||
}
|
||||
|
@ -490,11 +492,13 @@ public abstract class ContinuationBase
|
|||
|
||||
private static ContinuationListener __listener = new ContinuationListener()
|
||||
{
|
||||
@Override
|
||||
public void onComplete(Continuation continuation)
|
||||
{
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","onComplete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout(Continuation continuation)
|
||||
{
|
||||
((HttpServletResponse)continuation.getServletResponse()).addHeader("history","onTimeout");
|
||||
|
|
|
@ -15,12 +15,11 @@ package org.eclipse.jetty.continuation;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.eclipse.jetty.continuation.test.ContinuationBase;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
|
@ -42,7 +41,7 @@ public class ContinuationTest extends ContinuationBase
|
|||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
_connector = new SelectChannelConnector();
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_server.setConnectors(new Connector[]{ _connector });
|
||||
ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.NO_SECURITY|ServletContextHandler.NO_SESSIONS);
|
||||
_server.setHandler(servletContext);
|
||||
|
@ -64,7 +63,7 @@ public class ContinuationTest extends ContinuationBase
|
|||
@Test
|
||||
public void testContinuation() throws Exception
|
||||
{
|
||||
doNormal("AsyncContinuation");
|
||||
doNormal("HttpChannelState");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -15,14 +15,11 @@ package org.eclipse.jetty.continuation;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
import org.eclipse.jetty.continuation.test.ContinuationBase;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
|
@ -39,7 +36,7 @@ public class FauxContinuationTest extends ContinuationBase
|
|||
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
_connector = new SelectChannelConnector();
|
||||
_connector = new SelectChannelConnector(_server);
|
||||
_server.setConnectors(new Connector[]{ _connector });
|
||||
ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.NO_SECURITY|ServletContextHandler.NO_SESSIONS);
|
||||
_server.setHandler(servletContext);
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.lang.reflect.Array;
|
|||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
|
@ -50,7 +49,6 @@ import org.eclipse.jetty.continuation.Continuation;
|
|||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.continuation.ContinuationSupport;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -13,18 +13,15 @@ package com.acme;
|
|||
//========================================================================
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.WebSocket;
|
||||
import org.eclipse.jetty.websocket.WebSocketServlet;
|
||||
|
||||
public class WebSocketChatServlet extends WebSocketServlet
|
||||
{
|
||||
|
|
|
@ -21,12 +21,12 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.jmx.MBeanContainer;
|
||||
import org.eclipse.jetty.security.HashLoginService;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.NCSARequestLog;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
|
@ -35,12 +35,12 @@ import org.eclipse.jetty.server.handler.HandlerCollection;
|
|||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.server.handler.RequestLogHandler;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.server.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.session.HashSessionManager;
|
||||
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.junit.Ignore;
|
||||
|
|
Loading…
Reference in New Issue