From 468e6c284dd0157d16be435afeb268fcf0b1b57e Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 2 Dec 2011 10:04:03 +1100 Subject: [PATCH 01/56] 365267 NullPointerException in bad Address --- .../src/main/java/org/eclipse/jetty/client/Address.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/Address.java b/jetty-client/src/main/java/org/eclipse/jetty/client/Address.java index f6a84649bb7..447b0628c46 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/Address.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/Address.java @@ -43,6 +43,9 @@ public class Address public Address(String host, int port) { + if (host == null) + throw new IllegalArgumentException("Host is null"); + this.host = host.trim(); this.port = port; } From c6480fc6592b4de099b310c2da559c78b3c95506 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 2 Dec 2011 15:32:33 +1100 Subject: [PATCH 02/56] 365375 ResourceHandler should be a HandlerWrapper --- .../org/eclipse/jetty/server/handler/ResourceHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index e240aef47dc..da12ef46296 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -51,7 +51,7 @@ import org.eclipse.jetty.util.resource.Resource; * * @org.apache.xbean.XBean */ -public class ResourceHandler extends AbstractHandler +public class ResourceHandler extends HandlerWrapper { private static final Logger LOG = Log.getLogger(ResourceHandler.class); @@ -358,6 +358,8 @@ public class ResourceHandler extends AbstractHandler { if(!HttpMethods.HEAD.equals(request.getMethod())) { + //try another handler + super.handle(target, baseRequest, request, response); return; } skipContentBody = true; @@ -373,7 +375,11 @@ public class ResourceHandler extends AbstractHandler resource = getStylesheet(); } else + { + //no resource - try other handlers + super.handle(target, baseRequest, request, response); return; + } } if (!_aliases && resource.getAlias()!=null) From 0689e05e9bb020f3fb8996d7e42db0261a96ae5c Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 6 Dec 2011 16:25:15 +0100 Subject: [PATCH 03/56] 365750 - Support WebSocket over SSL, aka wss:// This is now implemented, using the new architecture of wrapping the connection with SslConnection. The only refactoring was to avoid that the HTTP handshake was sent from the HandshakeConnection constructor, because at that point the SSL wiring is not ready yet. Now the handshake is sent from handle(), guarded by a boolean variable to sent it once. --- .../jetty/websocket/WebSocketClient.java | 4 +- .../websocket/WebSocketClientFactory.java | 300 ++++++++++-------- .../jetty/websocket/WebSocketOverSSLTest.java | 124 ++++++++ jetty-websocket/src/test/resources/keystore | Bin 0 -> 1426 bytes 4 files changed, 296 insertions(+), 132 deletions(-) create mode 100644 jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java create mode 100644 jetty-websocket/src/test/resources/keystore diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java index 4bde98307e9..ef9520ff325 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java @@ -320,8 +320,6 @@ public class WebSocketClient String scheme=uri.getScheme(); if (!("ws".equalsIgnoreCase(scheme) || "wss".equalsIgnoreCase(scheme))) throw new IllegalArgumentException("Bad WebSocket scheme '"+scheme+"'"); - if ("wss".equalsIgnoreCase(scheme)) - throw new IOException("wss not supported"); SocketChannel channel = SocketChannel.open(); if (_bindAddress != null) @@ -334,7 +332,7 @@ public class WebSocketClient channel.configureBlocking(false); channel.connect(address); - _factory.getSelectorManager().register( channel, holder); + _factory.getSelectorManager().register(channel, holder); return holder; } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java index 9bcfe30442d..5f13fecdcff 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java @@ -5,7 +5,9 @@ import java.io.IOException; import java.net.ProtocolException; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; +import java.util.Map; import java.util.Random; +import javax.net.ssl.SSLEngine; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpParser; @@ -20,30 +22,31 @@ import org.eclipse.jetty.io.SimpleBuffers; import org.eclipse.jetty.io.nio.AsyncConnection; import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.io.nio.SelectorManager; +import org.eclipse.jetty.io.nio.SslConnection; import org.eclipse.jetty.util.B64Code; import org.eclipse.jetty.util.QuotedStringTokenizer; import org.eclipse.jetty.util.component.AggregateLifeCycle; -import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.ThreadPool; - /* ------------------------------------------------------------ */ /** *

WebSocketClientFactory contains the common components needed by multiple {@link WebSocketClient} instances * (for example, a {@link ThreadPool}, a {@link SelectorManager NIO selector}, etc).

*

WebSocketClients with different configurations should share the same factory to avoid to waste resources.

*

If a ThreadPool or MaskGen is passed in the constructor, then it is not added with {@link AggregateLifeCycle#addBean(Object)}, - * so it's lifecycle must be controlled externally. + * so it's lifecycle must be controlled externally. + * * @see WebSocketClient */ public class WebSocketClientFactory extends AggregateLifeCycle { private final static Logger __log = org.eclipse.jetty.util.log.Log.getLogger(WebSocketClientFactory.class.getName()); - private final static Random __random = new Random(); private final static ByteArrayBuffer __ACCEPT = new ByteArrayBuffer.CaseInsensitive("Sec-WebSocket-Accept"); + private SslContextFactory _sslContextFactory = new SslContextFactory(); private final ThreadPool _threadPool; private final WebSocketClientSelector _selector; private MaskGen _maskGen; @@ -55,54 +58,67 @@ public class WebSocketClientFactory extends AggregateLifeCycle */ public WebSocketClientFactory() { - _threadPool=new QueuedThreadPool(); - addBean(_threadPool); - _buffers=new WebSocketBuffers(8*1024); - addBean(_buffers); - _maskGen=new RandomMaskGen(); - addBean(_maskGen); - _selector=new WebSocketClientSelector(); - addBean(_selector); + this(new QueuedThreadPool()); } /* ------------------------------------------------------------ */ /** *

Creates a WebSocketClientFactory with the given ThreadPool and the default configuration.

+ * * @param threadPool the ThreadPool instance to use */ public WebSocketClientFactory(ThreadPool threadPool) { - _threadPool=threadPool; - addBean(threadPool); - _buffers=new WebSocketBuffers(8*1024); - addBean(_buffers); - _maskGen=new RandomMaskGen(); - addBean(_maskGen); - _selector=new WebSocketClientSelector(); - addBean(_selector); + this(threadPool, new RandomMaskGen()); } /* ------------------------------------------------------------ */ /** - *

Creates a WebSocketClientFactory with the specified configuration.

+ *

Creates a WebSocketClientFactory with the given ThreadPool and the given MaskGen.

+ * * @param threadPool the ThreadPool instance to use - * @param maskGen the mask generator to use + * @param maskGen the MaskGen instance to use + */ + public WebSocketClientFactory(ThreadPool threadPool, MaskGen maskGen) + { + this(threadPool, maskGen, 8192); + } + + /* ------------------------------------------------------------ */ + + /** + *

Creates a WebSocketClientFactory with the specified configuration.

+ * + * @param threadPool the ThreadPool instance to use + * @param maskGen the mask generator to use * @param bufferSize the read buffer size */ - public WebSocketClientFactory(ThreadPool threadPool,MaskGen maskGen,int bufferSize) + public WebSocketClientFactory(ThreadPool threadPool, MaskGen maskGen, int bufferSize) { - _threadPool=threadPool; + _threadPool = threadPool; addBean(threadPool); - _buffers=new WebSocketBuffers(bufferSize); + _buffers = new WebSocketBuffers(bufferSize); addBean(_buffers); - _maskGen=maskGen; - _selector=new WebSocketClientSelector(); + _maskGen = maskGen; + addBean(_maskGen); + _selector = new WebSocketClientSelector(); addBean(_selector); + addBean(_sslContextFactory); + } + + /* ------------------------------------------------------------ */ + /** + * @return the SslContextFactory used to configure SSL parameters + */ + public SslContextFactory getSslContextFactory() + { + return _sslContextFactory; } /* ------------------------------------------------------------ */ /** * Get the selectorManager. Used to configure the manager. + * * @return The {@link SelectorManager} instance. */ public SelectorManager getSelectorManager() @@ -111,8 +127,10 @@ public class WebSocketClientFactory extends AggregateLifeCycle } /* ------------------------------------------------------------ */ - /** Get the ThreadPool. + /** + * Get the ThreadPool. * Used to set/query the thread pool configuration. + * * @return The {@link ThreadPool} */ public ThreadPool getThreadPool() @@ -139,9 +157,9 @@ public class WebSocketClientFactory extends AggregateLifeCycle { if (isRunning()) throw new IllegalStateException(getState()); - if (removeBean(_maskGen)) - addBean(maskGen); - _maskGen=maskGen; + removeBean(_maskGen); + _maskGen = maskGen; + addBean(maskGen); } /* ------------------------------------------------------------ */ @@ -154,7 +172,7 @@ public class WebSocketClientFactory extends AggregateLifeCycle if (isRunning()) throw new IllegalStateException(getState()); removeBean(_buffers); - _buffers=new WebSocketBuffers(bufferSize); + _buffers = new WebSocketBuffers(bufferSize); addBean(_buffers); } @@ -179,24 +197,28 @@ public class WebSocketClientFactory extends AggregateLifeCycle return new WebSocketClient(this); } - /* ------------------------------------------------------------ */ - @Override - protected void doStart() throws Exception + protected SSLEngine newSslEngine(SocketChannel channel) throws IOException { - super.doStart(); - if (getThreadPool() instanceof LifeCycle && !((LifeCycle)getThreadPool()).isStarted()) - ((LifeCycle)getThreadPool()).start(); + SSLEngine sslEngine; + if (channel != null) + { + String peerHost = channel.socket().getInetAddress().getHostAddress(); + int peerPort = channel.socket().getPort(); + sslEngine = _sslContextFactory.newSslEngine(peerHost, peerPort); + } + else + { + sslEngine = _sslContextFactory.newSslEngine(); + } + sslEngine.setUseClientMode(true); + sslEngine.beginHandshake(); + + return sslEngine; } /* ------------------------------------------------------------ */ - @Override - protected void doStop() throws Exception - { - super.doStop(); - } - - /* ------------------------------------------------------------ */ - /** WebSocket Client Selector Manager + /** + * WebSocket Client Selector Manager */ class WebSocketClientSelector extends SelectorManager { @@ -209,16 +231,33 @@ public class WebSocketClientFactory extends AggregateLifeCycle @Override protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, final SelectionKey key) throws IOException { - SelectChannelEndPoint endp= new SelectChannelEndPoint(channel,selectSet,key,channel.socket().getSoTimeout()); - endp.setConnection(selectSet.getManager().newConnection(channel,endp, key.attachment())); - return endp; + WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)key.attachment(); + int maxIdleTime = holder.getMaxIdleTime(); + if (maxIdleTime < 0) + maxIdleTime = (int)getMaxIdleTime(); + SelectChannelEndPoint result = new SelectChannelEndPoint(channel, selectSet, key, maxIdleTime); + AsyncEndPoint endPoint = result; + + // Detect if it is SSL, and wrap the connection if so + if ("wss".equals(holder.getURI().getScheme())) + { + SSLEngine sslEngine = newSslEngine(channel); + SslConnection sslConnection = new SslConnection(sslEngine, endPoint); + endPoint.setConnection(sslConnection); + endPoint = sslConnection.getSslEndPoint(); + } + + AsyncConnection connection = selectSet.getManager().newConnection(channel, endPoint, holder); + endPoint.setConnection(connection); + + return result; } @Override public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment) { - WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture) attachment; - return new HandshakeConnection(endpoint,holder); + WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)attachment; + return new HandshakeConnection(endpoint, holder); } @Override @@ -230,7 +269,7 @@ public class WebSocketClientFactory extends AggregateLifeCycle @Override protected void endPointUpgraded(ConnectedEndPoint endpoint, Connection oldConnection) { - LOG.debug("upgrade {} -> {}",oldConnection,endpoint.getConnection()); + LOG.debug("upgrade {} -> {}", oldConnection, endpoint.getConnection()); } @Override @@ -243,7 +282,7 @@ public class WebSocketClientFactory extends AggregateLifeCycle protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment) { if (!(attachment instanceof WebSocketClient.WebSocketFuture)) - super.connectionFailed(channel,ex,attachment); + super.connectionFailed(channel, ex, attachment); else { __log.debug(ex); @@ -254,9 +293,9 @@ public class WebSocketClientFactory extends AggregateLifeCycle } } - /* ------------------------------------------------------------ */ - /** Handshake Connection. + /** + * Handshake Connection. * Handles the connection until the handshake succeeds or fails. */ class HandshakeConnection extends AbstractConnection implements AsyncConnection @@ -267,29 +306,27 @@ public class WebSocketClientFactory extends AggregateLifeCycle private final HttpParser _parser; private String _accept; private String _error; + private boolean _handshaken; public HandshakeConnection(AsyncEndPoint endpoint, WebSocketClient.WebSocketFuture future) { - super(endpoint,System.currentTimeMillis()); - _endp=endpoint; - _future=future; + super(endpoint, System.currentTimeMillis()); + _endp = endpoint; + _future = future; - byte[] bytes=new byte[16]; - __random.nextBytes(bytes); - _key=new String(B64Code.encode(bytes)); + byte[] bytes = new byte[16]; + new Random().nextBytes(bytes); + _key = new String(B64Code.encode(bytes)); - - Buffers buffers = new SimpleBuffers(_buffers.getBuffer(),null); - _parser=new HttpParser(buffers,_endp, - - new HttpParser.EventHandler() + Buffers buffers = new SimpleBuffers(_buffers.getBuffer(), null); + _parser = new HttpParser(buffers, _endp, new HttpParser.EventHandler() { @Override public void startResponse(Buffer version, int status, Buffer reason) throws IOException { - if (status!=101) + if (status != 101) { - _error="Bad response status "+status+" "+reason; + _error = "Bad response status " + status + " " + reason; _endp.close(); } } @@ -298,65 +335,64 @@ public class WebSocketClientFactory extends AggregateLifeCycle public void parsedHeader(Buffer name, Buffer value) throws IOException { if (__ACCEPT.equals(name)) - _accept=value.toString(); + _accept = value.toString(); } @Override public void startRequest(Buffer method, Buffer url, Buffer version) throws IOException { - if (_error==null) - _error="Bad response: "+method+" "+url+" "+version; + if (_error == null) + _error = "Bad response: " + method + " " + url + " " + version; _endp.close(); } @Override public void content(Buffer ref) throws IOException { - if (_error==null) - _error="Bad response. "+ref.length()+"B of content?"; + if (_error == null) + _error = "Bad response. " + ref.length() + "B of content?"; _endp.close(); } }); + } - String path=_future.getURI().getPath(); - if (path==null || path.length()==0) - { - path="/"; - } - - if(_future.getURI().getRawQuery() != null) - { + private void handshake() + { + String path = _future.getURI().getPath(); + if (path == null || path.length() == 0) + path = "/"; + + if (_future.getURI().getRawQuery() != null) path += "?" + _future.getURI().getRawQuery(); - } - String origin = future.getOrigin(); + String origin = _future.getOrigin(); StringBuilder request = new StringBuilder(512); - request - .append("GET ").append(path).append(" HTTP/1.1\r\n") - .append("Host: ").append(future.getURI().getHost()).append(":").append(_future.getURI().getPort()).append("\r\n") - .append("Upgrade: websocket\r\n") - .append("Connection: Upgrade\r\n") - .append("Sec-WebSocket-Key: ") - .append(_key).append("\r\n"); - - if(origin!=null) + request.append("GET ").append(path).append(" HTTP/1.1\r\n") + .append("Host: ").append(_future.getURI().getHost()).append(":") + .append(_future.getURI().getPort()).append("\r\n") + .append("Upgrade: websocket\r\n") + .append("Connection: Upgrade\r\n") + .append("Sec-WebSocket-Key: ") + .append(_key).append("\r\n"); + + if (origin != null) request.append("Origin: ").append(origin).append("\r\n"); - + request.append("Sec-WebSocket-Version: ").append(WebSocketConnectionD13.VERSION).append("\r\n"); - if (future.getProtocol()!=null) - request.append("Sec-WebSocket-Protocol: ").append(future.getProtocol()).append("\r\n"); + if (_future.getProtocol() != null) + request.append("Sec-WebSocket-Protocol: ").append(_future.getProtocol()).append("\r\n"); - if (future.getCookies()!=null && future.getCookies().size()>0) + Map cookies = _future.getCookies(); + if (cookies != null && cookies.size() > 0) { - for (String cookie : future.getCookies().keySet()) - request - .append("Cookie: ") - .append(QuotedStringTokenizer.quoteIfNeeded(cookie,HttpFields.__COOKIE_DELIM)) - .append("=") - .append(QuotedStringTokenizer.quoteIfNeeded(future.getCookies().get(cookie),HttpFields.__COOKIE_DELIM)) - .append("\r\n"); + for (String cookie : cookies.keySet()) + request.append("Cookie: ") + .append(QuotedStringTokenizer.quoteIfNeeded(cookie, HttpFields.__COOKIE_DELIM)) + .append("=") + .append(QuotedStringTokenizer.quoteIfNeeded(cookies.get(cookie), HttpFields.__COOKIE_DELIM)) + .append("\r\n"); } request.append("\r\n"); @@ -365,14 +401,18 @@ public class WebSocketClientFactory extends AggregateLifeCycle try { - Buffer handshake = new ByteArrayBuffer(request.toString(),false); - int len=handshake.length(); - if (len!=_endp.flush(handshake)) + Buffer handshake = new ByteArrayBuffer(request.toString(), false); + int len = handshake.length(); + if (len != _endp.flush(handshake)) throw new IOException("incomplete"); } - catch(IOException e) + catch (IOException e) { - future.handshakeFailed(e); + _future.handshakeFailed(e); + } + finally + { + _handshaken = true; } } @@ -380,6 +420,9 @@ public class WebSocketClientFactory extends AggregateLifeCycle { while (_endp.isOpen() && !_parser.isComplete()) { + if (!_handshaken) + handshake(); + if (!_parser.parseAvailable()) { if (_endp.isInputShutdown()) @@ -387,25 +430,29 @@ public class WebSocketClientFactory extends AggregateLifeCycle return this; } } - if (_error==null) + if (_error == null) { - if (_accept==null) - _error="No Sec-WebSocket-Accept"; + if (_accept == null) + { + _error = "No Sec-WebSocket-Accept"; + } else if (!WebSocketConnectionD13.hashKey(_key).equals(_accept)) - _error="Bad Sec-WebSocket-Accept"; + { + _error = "Bad Sec-WebSocket-Accept"; + } else { - Buffer header=_parser.getHeaderBuffer(); - MaskGen maskGen=_future.getMaskGen(); - WebSocketConnectionD13 connection = - new WebSocketConnectionD13(_future.getWebSocket(), - _endp, - _buffers,System.currentTimeMillis(), - _future.getMaxIdleTime(), - _future.getProtocol(), - null, - WebSocketConnectionD13.VERSION, - maskGen); + Buffer header = _parser.getHeaderBuffer(); + MaskGen maskGen = _future.getMaskGen(); + WebSocketConnectionD13 connection = + new WebSocketConnectionD13(_future.getWebSocket(), + _endp, + _buffers, System.currentTimeMillis(), + _future.getMaxIdleTime(), + _future.getProtocol(), + null, + WebSocketConnectionD13.VERSION, + maskGen); if (header.hasContent()) connection.fillBuffersFrom(header); @@ -438,15 +485,10 @@ public class WebSocketClientFactory extends AggregateLifeCycle public void onClose() { - if (_error!=null) + if (_error != null) _future.handshakeFailed(new ProtocolException(_error)); else _future.handshakeFailed(new EOFException()); } - - public String toString() - { - return "HS"+super.toString(); - } } } diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java new file mode 100644 index 00000000000..b78baf44de9 --- /dev/null +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java @@ -0,0 +1,124 @@ +package org.eclipse.jetty.websocket; + +import java.io.IOException; +import java.net.URI; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import javax.servlet.http.HttpServletRequest; + +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; + +public class WebSocketOverSSLTest +{ + private Server _server; + private int _port; + private WebSocket.Connection _connection; + + private void startServer(final WebSocket webSocket) throws Exception + { + _server = new Server(); + SslSelectChannelConnector connector = new SslSelectChannelConnector(); + _server.addConnector(connector); + SslContextFactory cf = connector.getSslContextFactory(); + cf.setKeyStorePath(MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath()); + cf.setKeyStorePassword("storepwd"); + cf.setKeyManagerPassword("keypwd"); + _server.setHandler(new WebSocketHandler() + { + public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) + { + return webSocket; + } + }); + _server.start(); + _port = connector.getLocalPort(); + } + + private void startClient(final WebSocket webSocket) throws Exception + { + Assert.assertTrue(_server.isStarted()); + + WebSocketClientFactory factory = new WebSocketClientFactory(new QueuedThreadPool(), new ZeroMaskGen()); + SslContextFactory cf = factory.getSslContextFactory(); + cf.setKeyStorePath(MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath()); + cf.setKeyStorePassword("storepwd"); + cf.setKeyManagerPassword("keypwd"); + factory.start(); + WebSocketClient client = new WebSocketClient(factory); + _connection = client.open(new URI("wss://localhost:" + _port), webSocket).get(5, TimeUnit.SECONDS); + } + + @After + public void destroy() throws Exception + { + if (_connection != null) + _connection.close(); + if (_server != null) + { + _server.stop(); + _server.join(); + } + } + + @Test + public void testWebSocketOverSSL() throws Exception + { + final String message = "message"; + final CountDownLatch serverLatch = new CountDownLatch(1); + startServer(new WebSocket.OnTextMessage() + { + private Connection connection; + + public void onOpen(Connection connection) + { + this.connection = connection; + } + + public void onMessage(String data) + { + try + { + Assert.assertEquals(message, data); + connection.sendMessage(data); + serverLatch.countDown(); + } + catch (IOException x) + { + x.printStackTrace(); + } + } + + public void onClose(int closeCode, String message) + { + } + }); + final CountDownLatch clientLatch = new CountDownLatch(1); + startClient(new WebSocket.OnTextMessage() + { + public void onOpen(Connection connection) + { + } + + public void onMessage(String data) + { + Assert.assertEquals(message, data); + clientLatch.countDown(); + } + + public void onClose(int closeCode, String message) + { + } + }); + _connection.sendMessage(message); + + Assert.assertTrue(serverLatch.await(5, TimeUnit.SECONDS)); + Assert.assertTrue(clientLatch.await(5, TimeUnit.SECONDS)); + } +} diff --git a/jetty-websocket/src/test/resources/keystore b/jetty-websocket/src/test/resources/keystore new file mode 100644 index 0000000000000000000000000000000000000000..b727bd0fb777fddb3463c81cb56963a7541f7b45 GIT binary patch literal 1426 zcmezO_TO6u1_mY|W&~r_+{*0KN+9!5EW=$#pv*3VCZ=r$d~96WY>X_7T1LX-9cnmv_92vyZY^nksPD zdgGz_%YMiA%<+G`?zc{_^OTmKsam}GdFt7neK!{P|Bco8Yq|9PvTGT0HqQC!@x9l1 z+kfrLjk$U4PfrzX4>?lEY_X)NU`c_upzVKwLzZV_Z=OB7;%H;~#q=-kB7C15mGAK^ zvQDWpwV1Q=%|)J*vS+h8eD_X&KBLa;y!Ym4fd?y?u6<@yiQRcgW4YSWJ1qI-Q@4qE za4m1Vxao>O&#^E1)!s>&+m1~AFk#ErRgE9c$R|1RHZn>ST)F2PCX`h;GftH|P3C*s zWzB^ZGW^U2Io6G9jl> z6zzz+mrM40Funf&SL@T49sAWnZvUNcc-}kaM`;+(`I*O}e=OTwz2vdB%C^t0KV2dN z8|5bLIJC=m`3p1S>EdUM&gly9o_)k?62R=&u_P~(KYzPEv+V7u$GBF7Yt*targsEg zTQzgVqnKmgxtO%H)!0fto_uWX^v1c;QdM?#toT{0*tgvCKBx=r`VraapZ2`+cgggB z-Pvqw9={ifyv(DLz=%jkh_cpEkNBn#fQtx!K-V#22ApgPb-K(wNrdO3Et=(zk zH%r#4Uj9|=lZlRA5;d`xvpUaban7~tb)L?vqO(?31t6P_KXXUmI|NTdEW^*XD%W$kc6J6C`ZJL_TRc(ux#yKj=Ue_0-Rb!XA^BcIEU@^esCUfRc7B*q_(7f!t{PH}Q2nU7; zJ3>UpKnkRbOIX-9zos$!bwcyY3l3?6uy+&YLB9AjrXwMJ9=TVxnh^gTTRrgQDAx z_HixoIbPSC|G?I^w5omSz6+C2WR&Q742Af!tZ{F_B0c(^#Lh& zza|JWF*7nSB0CQl;mkmH*$SFDWnY}}>VU(o3#<5V+huGG`Dn2??1_qdd2)==i--F? zs#KSqOx?Wrm7jRA(!0Yuu5HVhrWZZce5Lb}5Bq8!uvR=V-JM%7`INM|?JE9h{&PR9 zPS5OYv=7|qeAeX{<0}8%Th2N96wN*x(D1*r!0!3JEkDAd&tKmoUZ_-IpH*z9SS Date: Wed, 7 Dec 2011 10:17:20 -0700 Subject: [PATCH 04/56] 365932 - Produce jetty-websocket aggregate jar for android use + Adding maven-shade-plugin default configuration (no bytecode manipulation) to produce an aggregate classifier jar for jetty-websocket use. --- jetty-websocket/pom.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index 1bc5214b513..d8dfc3076e0 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -92,6 +92,24 @@ org.eclipse.jetty.websocket.* + + org.apache.maven.plugins + maven-shade-plugin + 1.5 + + + make-aggregate-jar + + shade + + + aggregate + true + false + + + + From 6d2ad43cc46291d3733cd6b7ecc6451e403d126a Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 7 Dec 2011 12:13:57 -0700 Subject: [PATCH 05/56] 365932 - Produce jetty-websocket aggregate jar for android use + revert last change using maven-shade-plugin as it didn't address the now redundant transitive dependencies present in the jetty-websocket pom. + made a formal jetty-aggregate/jetty-websocket build instead. --- jetty-aggregate/jetty-websocket/pom.xml | 88 +++++++++++++++++++++++++ jetty-aggregate/pom.xml | 1 + jetty-websocket/pom.xml | 18 ----- 3 files changed, 89 insertions(+), 18 deletions(-) create mode 100644 jetty-aggregate/jetty-websocket/pom.xml diff --git a/jetty-aggregate/jetty-websocket/pom.xml b/jetty-aggregate/jetty-websocket/pom.xml new file mode 100644 index 00000000000..c650ef55103 --- /dev/null +++ b/jetty-aggregate/jetty-websocket/pom.xml @@ -0,0 +1,88 @@ + + + org.eclipse.jetty.aggregate + jetty-aggregate-project + 7.6.0-SNAPSHOT + + 4.0.0 + jetty-websocket + Jetty :: Aggregate :: Websocket + + + ${project.build.directory}/sources + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack-dependencies + + unpack-dependencies + + + META-INF/**,org/eclipse/** + **/MANIFEST.MF,javax/**,about.html + ${project.build.directory}/classes + false + true + + + + unpack-source + generate-sources + + unpack-dependencies + + + sources + **/* + META-INF/** + org.eclipse.jetty + ${project.build.directory}/sources + true + true + + + + + + org.apache.maven.plugins + + maven-jar-plugin + + + package + package + + jar + + + + + + + development + http://eclipse.org/jetty + ${user.name} + org.eclipse.jetty + http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/NOTICE.txt + Jetty HTTP Server + + + + + + + + + + + + org.eclipse.jetty + jetty-websocket + ${project.version} + provided + + + diff --git a/jetty-aggregate/pom.xml b/jetty-aggregate/pom.xml index 41d2d360551..7de1ac8d379 100644 --- a/jetty-aggregate/pom.xml +++ b/jetty-aggregate/pom.xml @@ -35,6 +35,7 @@ jetty-client jetty-servlet jetty-webapp + jetty-websocket jetty-plus jetty-all-server jetty-all diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index d8dfc3076e0..1bc5214b513 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -92,24 +92,6 @@ org.eclipse.jetty.websocket.* - - org.apache.maven.plugins - maven-shade-plugin - 1.5 - - - make-aggregate-jar - - shade - - - aggregate - true - false - - - - From 0b1becf58d6a13dbd290e8fa170e78a808243a6a Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 8 Dec 2011 12:16:36 +1100 Subject: [PATCH 06/56] 364936 use Resource for opening URL streams --- .../jetty/annotations/AnnotationParser.java | 20 +++++++++++++++---- .../serverfactory/ServerInstanceWrapper.java | 3 ++- .../webapp/WebBundleDeployerHelper.java | 3 ++- .../jetty/policy/entry/KeystoreEntry.java | 4 +++- .../jetty/server/handler/ContextHandler.java | 3 ++- .../jetty/server/handler/DefaultHandler.java | 6 +++++- 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java index 84a8c00954a..bfe0031a442 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java @@ -454,7 +454,10 @@ public class AnnotationParser className = className.replace('.', '/')+".class"; URL resource = Loader.getResource(this.getClass(), className, false); if (resource!= null) - scanClass(resource.openStream()); + { + Resource r = Resource.newResource(resource); + scanClass(r.getInputStream()); + } } } } @@ -472,7 +475,10 @@ public class AnnotationParser String nameAsResource = cz.getName().replace('.', '/')+".class"; URL resource = Loader.getResource(this.getClass(), nameAsResource, false); if (resource!= null) - scanClass(resource.openStream()); + { + Resource r = Resource.newResource(resource); + scanClass(r.getInputStream()); + } } } if (visitSuperClasses) @@ -501,7 +507,10 @@ public class AnnotationParser s = s.replace('.', '/')+".class"; URL resource = Loader.getResource(this.getClass(), s, false); if (resource!= null) - scanClass(resource.openStream()); + { + Resource r = Resource.newResource(resource); + scanClass(r.getInputStream()); + } } } } @@ -525,7 +534,10 @@ public class AnnotationParser if (name.endsWith(".class")) { if ((resolver == null)|| (!resolver.isExcluded(name) && (!isParsed(name) || resolver.shouldOverride(name)))) - scanClass(res.getURL().openStream()); + { + Resource r = Resource.newResource(res.getURL()); + scanClass(r.getInputStream()); + } } } diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java index bb89bfe4889..21d0d6adb7d 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java @@ -271,7 +271,8 @@ public class ServerInstanceWrapper { try { // Execute a Jetty configuration file - is = jettyConfiguration.openStream(); + Resource r = Resource.newResource(jettyConfiguration); + is = r.getInputStream(); XmlConfiguration config = new XmlConfiguration(is); config.getIdMap().putAll(id_map); diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleDeployerHelper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleDeployerHelper.java index 27068cb1167..ea8fc5192b9 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleDeployerHelper.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleDeployerHelper.java @@ -376,7 +376,8 @@ public class WebBundleDeployerHelper implements IWebBundleDeployerHelper URL contextURL = contributor.getEntry(contextFileRelativePath); if (contextURL != null) { - return registerContext(contributor,contextFileRelativePath,contextURL.openStream(),extraClasspath,overrideBundleInstallLocation,requireTldBundle,handler); + Resource r = Resource.newResource(contextURL); + return registerContext(contributor,contextFileRelativePath,r.getInputStream(),extraClasspath,overrideBundleInstallLocation,requireTldBundle,handler); } throw new IllegalArgumentException("Could not find the context " + "file " + contextFileRelativePath + " for the bundle " + contributor.getSymbolicName() + (overrideBundleInstallLocation != null?" using the install location " + overrideBundleInstallLocation:"")); diff --git a/jetty-policy/src/main/java/org/eclipse/jetty/policy/entry/KeystoreEntry.java b/jetty-policy/src/main/java/org/eclipse/jetty/policy/entry/KeystoreEntry.java index a89b422bea4..b8d7a719ed4 100644 --- a/jetty-policy/src/main/java/org/eclipse/jetty/policy/entry/KeystoreEntry.java +++ b/jetty-policy/src/main/java/org/eclipse/jetty/policy/entry/KeystoreEntry.java @@ -21,6 +21,7 @@ import java.security.KeyStore; import org.eclipse.jetty.policy.PolicyContext; import org.eclipse.jetty.policy.PolicyException; +import org.eclipse.jetty.util.resource.Resource; public class KeystoreEntry extends AbstractEntry { @@ -49,7 +50,8 @@ public class KeystoreEntry extends AbstractEntry keystore = KeyStore.getInstance( type ); URL keyStoreLocation = new URL ( url ); - InputStream istream = keyStoreLocation.openStream(); + Resource r = Resource.newResource(keyStoreLocation); + InputStream istream = r.getInputStream(); keystore.load( istream, null ); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 01cf65535c0..8af31771943 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -1787,7 +1787,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. URL url = getResource(path); if (url == null) return null; - return url.openStream(); + Resource r = Resource.newResource(url); + return r.getInputStream(); } catch (Exception e) { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java index f9319837dd6..6ac3dcc2ff2 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java @@ -31,6 +31,7 @@ import org.eclipse.jetty.util.ByteArrayISO8859Writer; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.util.resource.Resource; /* ------------------------------------------------------------ */ @@ -60,7 +61,10 @@ public class DefaultHandler extends AbstractHandler { URL fav = this.getClass().getClassLoader().getResource("org/eclipse/jetty/favicon.ico"); if (fav!=null) - _favicon=IO.readBytes(fav.openStream()); + { + Resource r = Resource.newResource(fav); + _favicon=IO.readBytes(r.getInputStream()); + } } catch(Exception e) { From 600ae6043b4b1e5721af1084bb0fa08a1abd9bf5 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 8 Dec 2011 11:06:06 -0700 Subject: [PATCH 07/56] Bug 363415 - Update start.ini DEBUG enable + Fixing syntax for DEBUG of eclipse jetty specific classes. --- jetty-distribution/src/main/resources/start.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-distribution/src/main/resources/start.ini b/jetty-distribution/src/main/resources/start.ini index 6dec0543b5a..0ada4c02051 100644 --- a/jetty-distribution/src/main/resources/start.ini +++ b/jetty-distribution/src/main/resources/start.ini @@ -21,7 +21,7 @@ # -Dorg.apache.jasper.compiler.disablejsr199=true # -Dcom.sun.management.jmxremote # -Dorg.eclipse.jetty.util.log.IGNORED=true -# -Dorg.eclipse.jetty.util.log.stderr.DEBUG=true +# -Dorg.eclipse.jetty.LEVEL=DEBUG # -Dorg.eclipse.jetty.util.log.stderr.SOURCE=true # -Xmx2000m # -Xmn512m From ec297a5456d2710598b72153b5f617e74f6116bc Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 8 Dec 2011 14:30:38 -0700 Subject: [PATCH 08/56] Bug 366106 - IncludableGzipFilter does not honor minGzipSize init param setting + IncludableGzipFilter#IncludableGzipWrapper now properly copies minGzipSize, mimeTypes, and bufferSize configurables. --- .../jetty/servlets/IncludableGzipFilter.java | 8 +- .../IncludableGzipFilterMinSizeTest.java | 85 ++ .../jetty/servlets/gzip/GzipTester.java | 35 +- .../servlets/gzip/TestMinGzipSizeServlet.java | 52 ++ .../src/test/resources/big_script.js | 792 ++++++++++++++++++ .../src/test/resources/big_script.js.sha1 | 1 + .../src/test/resources/small_script.js | 29 + .../src/test/resources/small_script.js.sha1 | 1 + 8 files changed, 991 insertions(+), 12 deletions(-) create mode 100644 jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludableGzipFilterMinSizeTest.java create mode 100644 jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestMinGzipSizeServlet.java create mode 100644 jetty-servlets/src/test/resources/big_script.js create mode 100644 jetty-servlets/src/test/resources/big_script.js.sha1 create mode 100644 jetty-servlets/src/test/resources/small_script.js create mode 100644 jetty-servlets/src/test/resources/small_script.js.sha1 diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludableGzipFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludableGzipFilter.java index 0084ddaf861..7d9a24ac58a 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludableGzipFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludableGzipFilter.java @@ -67,10 +67,10 @@ public class IncludableGzipFilter extends GzipFilter public IncludableResponseWrapper(HttpServletRequest request, HttpServletResponse response) { super(request,response); - - _mimeTypes = IncludableGzipFilter.this._mimeTypes; - _bufferSize = IncludableGzipFilter.this._bufferSize; - _minGzipSize = IncludableGzipFilter.this._minGzipSize; + + super.setMimeTypes(IncludableGzipFilter.this._mimeTypes); + super.setBufferSize(IncludableGzipFilter.this._bufferSize); + super.setMinGzipSize(IncludableGzipFilter.this._minGzipSize); } @Override diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludableGzipFilterMinSizeTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludableGzipFilterMinSizeTest.java new file mode 100644 index 00000000000..6e37eb311fb --- /dev/null +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludableGzipFilterMinSizeTest.java @@ -0,0 +1,85 @@ +// ======================================================================== +// Copyright (c) 2004-2009 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.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + +package org.eclipse.jetty.servlets; + +import javax.servlet.Servlet; + +import org.eclipse.jetty.servlet.FilterHolder; +import org.eclipse.jetty.servlets.gzip.GzipTester; +import org.eclipse.jetty.servlets.gzip.TestMinGzipSizeServlet; +import org.eclipse.jetty.toolchain.test.TestingDir; +import org.junit.Rule; +import org.junit.Test; + +/** + * Perform specific tests on the IncludableGzipFilter's ability to manage + * minGzipSize initialization parameter. + * + * @see http://bugs.eclipse.org/366106 + */ +public class IncludableGzipFilterMinSizeTest +{ + @Rule + public TestingDir testdir = new TestingDir(); + + private Class testServlet = TestMinGzipSizeServlet.class; + + @Test + public void testUnderMinSize() throws Exception + { + GzipTester tester = new GzipTester(testdir); + // Use IncludableGzipFilter + tester.setGzipFilterClass(IncludableGzipFilter.class); + + FilterHolder holder = tester.setContentServlet(testServlet); + // A valid mime type that we will never use in this test. + // configured here to prevent mimeType==null logic + holder.setInitParameter("mimeTypes","application/soap+xml"); + holder.setInitParameter("minGzipSize", "2048"); + holder.setInitParameter("uncheckedPrintWriter","true"); + + tester.copyTestServerFile("small_script.js"); + + try { + tester.start(); + tester.assertIsResponseNotGzipFiltered("small_script.js", + "small_script.js.sha1", + "text/javascript; charset=utf-8"); + } finally { + tester.stop(); + } + } + + @Test + public void testOverMinSize() throws Exception + { + GzipTester tester = new GzipTester(testdir); + // Use IncludableGzipFilter + tester.setGzipFilterClass(IncludableGzipFilter.class); + + FilterHolder holder = tester.setContentServlet(testServlet); + holder.setInitParameter("mimeTypes","application/soap+xml,text/javascript"); + holder.setInitParameter("minGzipSize", "2048"); + holder.setInitParameter("uncheckedPrintWriter","true"); + + tester.copyTestServerFile("big_script.js"); + + try { + tester.start(); + tester.assertIsResponseGzipCompressed("big_script.js"); + } finally { + tester.stop(); + } + } +} diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java index d0d3e09531a..2c72e5eb6ed 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java @@ -1,10 +1,6 @@ package org.eclipse.jetty.servlets.gzip; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; +import static org.hamcrest.Matchers.*; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; @@ -36,6 +32,7 @@ import org.junit.Assert; public class GzipTester { + private Class gzipFilterClass = GzipFilter.class; private String encoding = "ISO8859_1"; private ServletTester servletTester; private TestingDir testdir; @@ -333,6 +330,20 @@ public class GzipTester IO.close(fos); } } + + /** + * Copy a src/test/resource file into the server tree for eventual serving. + * + * @param filename + * the filename to look for in src/test/resources + */ + public void copyTestServerFile(String filename) throws IOException + { + File srcFile = MavenTestingUtils.getTestResourceFile(filename); + File testFile = testdir.getFile(filename); + + IO.copy(srcFile,testFile); + } /** * Set the servlet that provides content for the GzipFilter in being tested. @@ -348,11 +359,19 @@ public class GzipTester servletTester.setResourceBase(testdir.getDir().getCanonicalPath()); ServletHolder servletHolder = servletTester.addServlet(servletClass,"/"); servletHolder.setInitParameter("baseDir",testdir.getDir().getAbsolutePath()); - FilterHolder holder = servletTester.addFilter(GzipFilter.class,"/*",0); + FilterHolder holder = servletTester.addFilter(gzipFilterClass,"/*",0); return holder; } - - + + public Class getGzipFilterClass() + { + return gzipFilterClass; + } + + public void setGzipFilterClass(Class gzipFilterClass) + { + this.gzipFilterClass = gzipFilterClass; + } public void setEncoding(String encoding) { diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestMinGzipSizeServlet.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestMinGzipSizeServlet.java new file mode 100644 index 00000000000..3a3c9897f6c --- /dev/null +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestMinGzipSizeServlet.java @@ -0,0 +1,52 @@ +package org.eclipse.jetty.servlets.gzip; + +import java.io.IOException; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.http.MimeTypes; +import org.eclipse.jetty.io.Buffer; + +/** + * Test servlet for testing against unusual minGzip configurable. + */ +@SuppressWarnings("serial") +public class TestMinGzipSizeServlet extends TestDirContentServlet +{ + private MimeTypes mimeTypes; + + @Override + public void init(ServletConfig config) throws ServletException + { + super.init(config); + mimeTypes = new MimeTypes(); + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + String fileName = request.getServletPath(); + byte[] dataBytes = loadContentFileBytes(fileName); + + response.setContentLength(dataBytes.length); + if (fileName.endsWith(".js")) + { + // intentionally long-form content type to test ";" splitting in code + response.setContentType("text/javascript; charset=utf-8"); + } + else + { + Buffer buf = mimeTypes.getMimeByExtension(fileName); + if (buf != null) + { + response.setContentType(buf.toString()); + } + } + ServletOutputStream out = response.getOutputStream(); + out.write(dataBytes); + } +} diff --git a/jetty-servlets/src/test/resources/big_script.js b/jetty-servlets/src/test/resources/big_script.js new file mode 100644 index 00000000000..938a413c3fd --- /dev/null +++ b/jetty-servlets/src/test/resources/big_script.js @@ -0,0 +1,792 @@ +//---------------------------------------------------------------------- +// +// Silly / Pointless Javascript to test GZIP compression. +// +//---------------------------------------------------------------------- + +var LOGO = { + dat: [ + 0x50, 0x89, 0x47, 0x4e, 0x0a, 0x0d, 0x0a, 0x1a, 0x00, 0x00, 0x0d, 0x00, 0x48, 0x49, 0x52, 0x44, + 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x78, 0x00, 0x06, 0x08, 0x00, 0x00, 0x2a, 0x00, 0x21, 0x96, + 0x00, 0x0f, 0x00, 0x00, 0x73, 0x04, 0x49, 0x42, 0x08, 0x54, 0x08, 0x08, 0x7c, 0x08, 0x64, 0x08, + 0x00, 0x88, 0x00, 0x00, 0x70, 0x09, 0x59, 0x48, 0x00, 0x73, 0x04, 0x00, 0x00, 0x27, 0x04, 0x00, + 0x01, 0x27, 0x4f, 0xd9, 0x80, 0x1d, 0x00, 0x00, 0x19, 0x00, 0x45, 0x74, 0x74, 0x58, 0x6f, 0x53, + 0x74, 0x66, 0x61, 0x77, 0x65, 0x72, 0x77, 0x00, 0x77, 0x77, 0x69, 0x2e, 0x6b, 0x6e, 0x63, 0x73, + 0x70, 0x61, 0x2e, 0x65, 0x72, 0x6f, 0x9b, 0x67, 0x3c, 0xee, 0x00, 0x1a, 0x20, 0x00, 0x49, 0x00, + 0x41, 0x44, 0x78, 0x54, 0xed, 0x9c, 0x79, 0x9d, 0x1c, 0xd8, 0x95, 0x55, 0x3f, 0xff, 0xfb, 0xa7, + 0xb2, 0xdd, 0x24, 0xef, 0x24, 0x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, 0x6e, 0x7e, 0x8c, + 0xc0, 0x73, 0x89, 0x0d, 0x12, 0x4e, 0xad, 0x83, 0xf0, 0x11, 0xf8, 0x59, 0x82, 0x46, 0xc2, 0x36, + 0x2f, 0xcf, 0x48, 0x2d, 0xfc, 0x37, 0x24, 0x5c, 0x76, 0x10, 0xd3, 0x3f, 0xc3, 0x7e, 0x89, 0xde, + 0x6c, 0x57, 0x51, 0xdc, 0x50, 0x9d, 0xba, 0xa6, 0x8e, 0xf5, 0x17, 0x52, 0xfc, 0x0d, 0x89, 0x3b, + 0x14, 0xc8, 0x15, 0x7c, 0x5e, 0xdf, 0x3c, 0x3b, 0xc2, 0x4b, 0x8e, 0x65, 0x71, 0x89, 0xf7, 0x99, + 0x04, 0x8e, 0x03, 0xbc, 0x0a, 0x9f, 0xf1, 0xde, 0x32, 0x43, 0x38, 0x5c, 0xd9, 0x26, 0x77, 0x3b, + 0xc6, 0xcb, 0x70, 0xbe, 0xc5, 0x0e, 0x54, 0x8f, 0x63, 0x75, 0xc3, 0x85, 0x04, 0x2f, 0xa8, 0x4e, + 0xde, 0xc7, 0x37, 0xb7, 0x85, 0xf6, 0x98, 0x3b, 0x37, 0x77, 0xb7, 0x22, 0x96, 0xc6, 0x0e, 0x03, + 0x60, 0x25, 0x28, 0x59, 0x11, 0xc0, 0xff, 0x9d, 0x3a, 0xb5, 0x16, 0x02, 0x36, 0x91, 0x65, 0x7c, + 0x8f, 0x37, 0xc8, 0xee, 0xd1, 0x30, 0x16, 0x70, 0xba, 0xcc, 0x02, 0xbe, 0x82, 0x6b, 0xe5, 0x4f, + 0xb5, 0x13, 0x47, 0x94, 0x08, 0x3b, 0x44, 0x09, 0x4c, 0x2a, 0x94, 0x77, 0x07, 0xd6, 0x74, 0xeb, + 0xf7, 0x83, 0x6a, 0x77, 0xba, 0xe4, 0xab, 0x59, 0x67, 0xe1, 0x91, 0x70, 0x47, 0x17, 0x02, 0x22, + 0x27, 0x65, 0x73, 0x3f, 0x7b, 0x58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xdb, 0x01, 0x40, 0x51, 0x5d, 0x4a, 0x61, 0x80, 0x3e, 0x2c, 0x86, 0x01, 0x87, 0x93, 0x17, 0x99, + 0x58, 0x60, 0x99, 0xda, 0x77, 0x67, 0x14, 0x70, 0xc1, 0x98, 0xb8, 0x4b, 0x73, 0x2a, 0xc4, 0xc5, + 0xfe, 0x36, 0xc2, 0x74, 0x66, 0x50, 0xbe, 0x9a, 0xcb, 0x18, 0xd2, 0x1c, 0x7c, 0x2a, 0xe8, 0xff, + 0xfc, 0x21, 0xd8, 0xe2, 0x55, 0xa1, 0x37, 0xeb, 0x58, 0xdb, 0xe4, 0x5e, 0x9f, 0xa8, 0xba, 0xe7, + 0xcf, 0x82, 0x13, 0x72, 0x9f, 0xae, 0x96, 0x0f, 0x1d, 0x97, 0xb6, 0x69, 0x8b, 0x4d, 0xb7, 0x79, + 0xd7, 0x4b, 0x96, 0x76, 0xe7, 0x7f, 0x86, 0xd9, 0x03, 0xaf, 0xab, 0x6a, 0x10, 0x33, 0x01, 0x27, + 0x75, 0x78, 0x11, 0x42, 0x67, 0x84, 0xf3, 0x3b, 0xb4, 0x3c, 0xd0, 0x33, 0x6f, 0xae, 0x7e, 0x06, + 0xc1, 0x50, 0xd0, 0xde, 0xed, 0x7a, 0xd7, 0x3d, 0xe0, 0x55, 0x0d, 0x77, 0x1c, 0x94, 0x86, 0xac, + 0x07, 0x35, 0x31, 0xdc, 0x38, 0x4c, 0x96, 0x7c, 0x01, 0x79, 0x95, 0x86, 0x83, 0x0b, 0x0a, 0x61, + 0x7d, 0x55, 0xa8, 0xd5, 0x28, 0xd1, 0x10, 0x81, 0x4a, 0x55, 0x0c, 0x02, 0xf1, 0x13, 0x5f, 0x85, + 0x3f, 0x5f, 0x85, 0xaa, 0x1d, 0x6f, 0x36, 0x69, 0x9f, 0xf4, 0x17, 0x36, 0x6d, 0x8d, 0xbe, 0xe1, + 0x86, 0xe3, 0x96, 0xc6, 0x9c, 0x5c, 0x26, 0xdc, 0x69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 0x9c, 0x9e, 0x5e, 0x93, 0x90, 0x11, 0xcf, + 0xc3, 0x0c, 0x95, 0x34, 0x83, 0x00, 0x02, 0xad, 0xcd, 0x1c, 0x23, 0xca, 0x90, 0xd1, 0x63, 0xd9, + 0xee, 0x50, 0x05, 0x28, 0xf2, 0xe6, 0x77, 0x4c, 0x1a, 0x94, 0xac, 0xed, 0x48, 0x62, 0xf6, 0xbb, + 0x76, 0xf8, 0x85, 0xe0, 0x4f, 0x3a, 0x2c, 0x19, 0xd8, 0xf1, 0x09, 0xc4, 0x36, 0x58, 0xdb, 0xaa, + 0x30, 0x0d, 0xf1, 0x65, 0xe0, 0x43, 0xa3, 0x7e, 0x50, 0x17, 0x05, 0x99, 0x87, 0xc4, 0x03, 0x84, + 0x83, 0x92, 0xd6, 0x67, 0x01, 0x20, 0x63, 0x78, 0x8a, 0xb4, 0xf7, 0xde, 0x75, 0x54, 0x85, 0x47, + 0x2f, 0xc3, 0x37, 0xc1, 0xaa, 0xa8, 0xde, 0xc9, 0x88, 0x86, 0xe0, 0xe4, 0xaa, 0x9d, 0x35, 0xba, + 0x49, 0xd1, 0x44, 0x1a, 0x5a, 0xc3, 0x62, 0xeb, 0xb6, 0x4f, 0x63, 0x7c, 0x3e, 0x8e, 0x4b, 0x2d, + 0xb0, 0xd6, 0xd8, 0x2f, 0x3a, 0xbc, 0x80, 0x56, 0xbf, 0xc1, 0x14, 0x23, 0x4f, 0x12, 0x72, 0xfe, + 0xed, 0x77, 0xd6, 0x52, 0x8b, 0x05, 0x3c, 0x7c, 0x0a, 0x1b, 0x04, 0x55, 0x21, 0x47, 0x1c, 0x16, + 0x25, 0x60, 0x86, 0x01, 0xad, 0x09, 0x1b, 0xe6, 0x66, 0x88, 0x47, 0x66, 0x12, 0x2e, 0x5c, 0x5a, + 0xd3, 0xe8, 0x3d, 0x76, 0xf4, 0x95, 0x4a, 0x3b, 0x4e, 0x8d, 0xb2, 0xc0, 0xca, 0x2a, 0xac, 0xbe, + 0x10,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 0x47, 0xf1, 0xf5, + 0x63, 0xb8, 0xc9, 0x8b, 0x17, 0x70, 0x63, 0xd5, 0xee, 0xef, 0xc9, 0x78, 0x47, 0xc1, 0x9d, 0x13, + 0x00, 0xc4, 0xf2, 0x8d, 0xf6, 0x18, 0x7f, 0xe7, 0xcc, 0xab, 0x86, 0xcd, 0xa8, 0x1b, 0x13, 0xd1, + 0x4c, 0x33, 0x96, 0x98, 0x81, 0xbc, 0x44, 0x1a, 0x0f, 0x91, 0x21, 0xab, 0x98, 0xaa, 0x92, 0x04, + 0xaf, 0x32, 0x75, 0x1b, 0x26, 0xf0, 0xf5, 0x60, 0xe0, 0x16, 0x60, 0xfe, 0xb9, 0xf8, 0x78, 0x13, + 0xb7, 0xd0, 0xb6, 0x9d, 0xc3, 0x00, 0x55, 0x46, 0x59, 0x5d, 0xf0, 0xe1, 0x38, 0x5a, 0xcb, 0x01, + 0xec, 0xa2, 0x02, 0x31, 0xf5, 0x0c, 0xff, 0xae, 0xe2, 0xcd, 0xa3, 0x09, 0x70, 0x00, 0x7b, 0x78, + 0x29, 0x86, 0x05, 0x86, 0x62, 0x18, 0x05, 0x84, 0x09, 0xaa, 0x58, 0x30, 0xff, 0x9d, 0x10, 0x2d, + 0xb7, 0x79, 0xfb, 0xd7, 0x83, 0x92, 0x07, 0x6e, 0x6c, 0xde, 0x02, 0xf4, 0xb4, 0xa2, 0xb7, 0x01, + 0xc8, 0x8b, 0x55, 0x14, 0x2e, 0xbd, 0x6f, 0xf4, 0x4b, 0x75, 0xc6, 0x00, 0x0e, 0x48, 0x1b, 0x56, + 0x5e, 0x8d, 0xaf, 0x5d, 0x6f, 0xbd, 0x88, 0xc4, 0x0c, 0x2e, 0x04, 0xfa, 0x69, 0x06, 0x53, 0xd4, + 0x50, 0x15, 0xb2, 0x40, 0x82, 0x51, 0x9a, 0xb2, 0x54, 0x73, 0x15, 0x55, 0xf2, 0x91, 0x3c, 0xd3, + 0x92, 0x66, 0xf4, 0xf0, 0x92, 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, 0x5d, 0xbd, 0xe3, 0xaa, 0x15, 0xf1, 0xb7, 0x04, 0xff, 0x31, 0x65, 0xbb, + 0x81, 0x4d, 0x9b, 0x9d, 0x0d, 0x02, 0xfc, 0xc2, 0x91, 0x70, 0x0b, 0x70, 0x1d, 0xa4, 0x0a, 0xa2, + 0xba, 0x60, 0x58, 0x81, 0x5d, 0x13, 0xd1, 0xbe, 0xe7, 0x81, 0x9a, 0x4c, 0xed, 0x81, 0x72, 0x22, + 0xaa, 0xa9, 0x66, 0xc6, 0x12, 0x51, 0x58, 0x72, 0x5a, 0x13, 0xde, 0xcc, 0x18, 0xab, 0x75, 0x67, + 0xbe, 0x28, 0x7c, 0x9e, 0x88, 0x2d, 0x42, 0xc8, 0xe2, 0xe0, 0x61, 0x62, 0xe0, 0x84, 0x69, 0xef, + 0xdf, 0x35, 0x5a, 0xf9, 0xfd, 0x19, 0x17, 0x4d, 0xf2, 0x37, 0x29, 0xfc, 0xe0, 0x39, 0x17, 0x6f, + 0xab, 0xff, 0x8d, 0x8a, 0x2d, 0xa2, 0xd6, 0x55, 0x37, 0x8c, 0xa1, 0x43, 0xb9, 0x9f, 0x90, 0x8d, + 0x7c, 0x1c, 0xb7, 0xa5, 0x5e, 0x10, 0xdf, 0xab, 0x75, 0x49, 0xc1, 0xc9, 0xd4, 0xcf, 0xaf, 0x63, + 0x24, 0x99, 0xab, 0x07, 0xef, 0x51, 0x9b, 0xdb, 0xfa, 0xc2, 0xe3, 0x5f, 0xa6, 0x19, 0x21, 0x83, + 0x04, 0xed, 0x00, 0x92, 0x47, 0xa6, 0xd5, 0xc0, 0x7f, 0x9c, 0x30, 0x13, 0x78, 0x16, 0x44, 0x40, + 0xaa, 0xae, 0xef, 0xf0, 0x4b, 0x13, 0x46, 0x1f, 0x05, 0x64, 0x11, 0xd3, 0x13, 0xdb, 0x66, 0x86, + 0x30, 0x31, 0x77, 0x4d, 0xf0, 0x32, 0x88, 0xa4, 0x8d, 0x9c, 0xf7, 0xef, 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x97, 0x8d, 0x59, 0x30, 0x3d, 0xfa, 0x80, 0xd3, 0xd8, 0x09, 0xaa, 0x8f, 0xbc, 0x03, + 0xfc, 0x0a, 0xaf, 0x00, 0x70, 0x16, 0xa4, 0xec, 0xaa, 0xa3, 0xe3, 0x76, 0xd2, 0x85, 0x11, 0xef, + 0x91, 0x91, 0x1c, 0xc0, 0x67, 0xbc, 0x50, 0xf8, 0x67, 0xbc, 0x32, 0x78, 0xf5, 0xde, 0xed, 0x27, + 0x67, 0x01, 0x12, 0xf0, 0x46, 0x7d, 0x49, 0xe3, 0x75, 0xfc, 0x3a, 0x54, 0xe2, 0xf0, 0xe6, 0x71, + 0xbf, 0x55, 0x14, 0xaa, 0x28, 0xe0, 0xec, 0x65, 0x5e, 0x7f, 0x16, 0x44, 0x97, 0x02, 0x92, 0x13, + 0x34, 0x9f, 0x4b, 0xc4, 0xd3, 0x78, 0xe5, 0x6b, 0x99, 0x29, 0xa3, 0xa4, 0xad, 0xd1, 0xe5, 0x39, + 0xc9, 0x07, 0x00, 0x24, 0x65, 0x03, 0x6b, 0x27, 0xb7, 0xb1, 0x48, 0xbf, 0x56, 0x0e, 0xe6, 0xa3, + 0xb9, 0x46, 0x42, 0x18, 0xe8, 0xfa, 0x07, 0x80, 0x87, 0xee, 0xc8, 0x88, 0xc0, 0x21, 0x89, 0x8f, + 0x58, 0xe9, 0x08, 0xb4, 0x6b, 0xbc, 0x79, 0xac, 0x56, 0x5f, 0xa6, 0x4b, 0x89, 0x6f, 0x88, 0xe2, + 0xc0, 0x69, 0x93, 0x51, 0x1f, 0x63, 0xda, 0xaa, 0xe7, 0x8b, 0xfe, 0xf4, 0xf6, 0x92, 0x34, 0xb5, + 0x55, 0x0a, 0x41, 0x5d, 0x8c, 0x48, 0x2d, 0x22, 0x64, 0x44, 0xf0, 0x22, 0xc0, 0x77, 0x44, 0x67, + 0xb4, 0xc4, 0x2b, 0x97, 0x85, 0xe0, 0x4b, 0xe1, 0x77, 0x0e, 0x83,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 0xe3, 0x5e, 0x08, 0xb1, + 0x98, 0xf8, 0x3e, 0xaa, 0xc9, 0x6e, 0xc3, 0x9e, 0x1c, 0x61, 0x99, 0x11, 0xdc, 0x01, 0x1c, 0x07, + 0xf6, 0x97, 0x18, 0xb5, 0x13, 0xa2, 0xe9, 0x58, 0xef, 0xfb, 0xe2, 0xe5, 0x97, 0xff, 0xea, 0xa9, + 0x34, 0xca, 0xcc, 0x2f, 0x7f, 0xb1, 0x1c, 0xe0, 0x05, 0x70, 0x64, 0x44, 0xf0, 0x0c, 0xe0, 0x19, + 0xc0, 0x63, 0x2a, 0x10, 0x9c, 0x44, 0xdc, 0x6b, 0xaa, 0x57, 0xbc, 0xef, 0x78, 0x00, 0x39, 0xc4, + 0xc7, 0x5e, 0x8a, 0x81, 0x8c, 0x88, 0xde, 0x00, 0x8c, 0x06, 0xbe, 0xc3, 0xc9, 0xae, 0x51, 0x60, + 0xd3, 0x8a, 0x78, 0xc0, 0x0e, 0x25, 0xff, 0xfd, 0xdb, 0x8f, 0x09, 0xd7, 0x52, 0xac, 0x4d, 0xd5, + 0x5c, 0xa9, 0xe3, 0xad, 0xc1, 0x80, 0x60, 0x39, 0xc3, 0x87, 0x70, 0xe1, 0x52, 0x38, 0x15, 0xc0, + 0x70, 0xe2, 0x1c, 0x38, 0x87, 0x0e, 0x05, 0x23, 0x03, 0x9c, 0x38, 0x76, 0x0e, 0x1c, 0x23, 0x87, + 0x9c, 0x05, 0x76, 0x03, 0x1c, 0x38, 0x87, 0x0e, 0x05, 0x23, 0x03, 0x9c, 0x38, 0x76, 0x0e, 0x1c, + 0x23, 0x87, 0x9c, 0x05, 0x76, 0x03, 0x1c, 0x38, 0x87, 0x0e, 0x05, 0x23, 0x03, 0x9c, 0x38, 0x76, + 0x0e, 0x1c, 0x23, 0x87, 0x9c, 0x05, 0x76, 0x03, 0x1c, 0x38, 0x87, 0x0e, 0x05, 0x23, 0x03, 0x9c, + 0x38, 0x76, 0x0e, 0x1c, 0x23, 0x87, 0x9c, 0x05, 0x76, 0x03, 0x1c, 0x38, 0x87, 0x0e, 0x05, 0x23, + 0x03, 0x9c, 0x38, 0x76, 0x0e, 0x1c, 0x23, 0x87, 0x9c, 0x05, 0x76, 0x03, 0x1c, 0x38, 0x87, 0x0e, + 0x05, 0x23, 0x03, 0x9c, 0x38, 0x76, 0x0e, 0x1c, 0x23, 0x87, 0x9c, 0x05, 0x76, 0x03, 0x1c, 0x38, + 0x87, 0x0e, 0x05, 0x23, 0x0f, 0xfe, 0xf6, 0xa7, 0xbf, 0x78, 0xfb, 0x2d, 0xfb, 0xc5, 0x00, 0x00, + 0x00, 0x00, 0x45, 0x49, 0x44, 0x4e, 0x42, 0xae, 0x82, 0x60, + ], + disp: function() + { + // Do Nothing + + throw "Does Nothing!"; + } + +}; + +try +{ + LOGO.disp(); +} +catch(e) +{ + alert("Error: " + e + "\n"); +} + diff --git a/jetty-servlets/src/test/resources/big_script.js.sha1 b/jetty-servlets/src/test/resources/big_script.js.sha1 new file mode 100644 index 00000000000..5ac71c8b8b3 --- /dev/null +++ b/jetty-servlets/src/test/resources/big_script.js.sha1 @@ -0,0 +1 @@ +77634b336741a98d2ef79484281245b12e9db939 big_script.js diff --git a/jetty-servlets/src/test/resources/small_script.js b/jetty-servlets/src/test/resources/small_script.js new file mode 100644 index 00000000000..207de2be410 --- /dev/null +++ b/jetty-servlets/src/test/resources/small_script.js @@ -0,0 +1,29 @@ +//---------------------------------------------------------------------- +// +// Silly / Pointless Javascript to test GZIP compression. +// +//---------------------------------------------------------------------- + +var LOGO = { + dat: [ + 0x50, 0x89, 0x47, 0x4e, 0x0a, 0x0d, 0x0a, 0x1a, 0x00, 0x00, 0x0d, 0x00, 0x48, 0x49, 0x52, 0x44, + 0x00, 0x00, 0x45, 0x49, 0x44, 0x4e, 0x42, 0xae, 0x82, 0x60, + ], + disp: function() + { + // Do Nothing + + throw "Does Nothing!"; + } + +}; + +try +{ + LOGO.disp(); +} +catch(e) +{ + alert("Error: " + e + "\n"); +} + diff --git a/jetty-servlets/src/test/resources/small_script.js.sha1 b/jetty-servlets/src/test/resources/small_script.js.sha1 new file mode 100644 index 00000000000..ca4c476094a --- /dev/null +++ b/jetty-servlets/src/test/resources/small_script.js.sha1 @@ -0,0 +1 @@ +b8455ea37194b938cfc1773a73ecee2c994fa98e small_script.js From 2c650a5fddf13bd55c19f6e6386cff260be54ea6 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 12 Dec 2011 12:17:16 +1100 Subject: [PATCH 09/56] 366316 Superfluous printStackTrace on 404 --- .../src/main/java/org/eclipse/jetty/servlet/ServletHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java index 50912613853..1a5e485f216 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java @@ -1230,7 +1230,6 @@ public class ServletHandler extends ScopedHandler HttpServletResponse response) throws IOException { - new Throwable().printStackTrace(); if(LOG.isDebugEnabled()) LOG.debug("Not Found "+request.getRequestURI()); response.sendError(HttpServletResponse.SC_NOT_FOUND); From 416b6a8a15ed109bf7d2539225dd008a72357d0e Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 12 Dec 2011 16:57:14 +0100 Subject: [PATCH 10/56] Added guard against multiple closes: if the endPoint is already closed, skip updating the SSLEngine and/or the endPoint. --- .../java/org/eclipse/jetty/io/nio/SslConnection.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index 9bda79b9191..82d6fbeceb7 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -16,7 +16,6 @@ package org.eclipse.jetty.io.nio; import java.io.IOException; import java.nio.ByteBuffer; import java.util.concurrent.atomic.AtomicBoolean; - import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLEngineResult; import javax.net.ssl.SSLEngineResult.HandshakeStatus; @@ -381,9 +380,10 @@ public class SslConnection extends AbstractConnection implements AsyncConnection } // pass on ishut/oshut state - if (!_inbound.hasContent() && _endp.isInputShutdown()) + if (_endp.isOpen() && _endp.isInputShutdown() && !_inbound.hasContent()) _engine.closeInbound(); - if (!_outbound.hasContent() && _engine.isOutboundDone()) + + if (_endp.isOpen() && _engine.isOutboundDone() && !_outbound.hasContent()) _endp.shutdownOutput(); some_progress|=progress; @@ -570,11 +570,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection public String toString() { - Buffer i=_inbound; - Buffer o=_outbound; - Buffer u=_unwrapBuf; - - return super.toString()+"|"+_engine.getHandshakeStatus()+" i/u/o="+(i==null?0:i.length())+"/"+(u==null?0:u.length())+"/"+(o==null?0:o.length()); + return String.format("%s | %s", super.toString(), _sslEndPoint); } /* ------------------------------------------------------------ */ From 004fa1ce1ca5f57f55f8cadb749d33b510ba30df Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 12 Dec 2011 09:02:40 -0700 Subject: [PATCH 11/56] Bug 365973 - Websocket client on android causes many VFY errors and warnings. + Splitting out WebSocketConnection#handshake() into new WebSocketServletConnection interface and refactoring accordingly, in order to remove servlet-api dep on WebSocketConnection for appropriate websocket client use. --- .../websocket/WebSocketClientFactory.java | 5 +- .../jetty/websocket/WebSocketConnection.java | 6 -- .../websocket/WebSocketConnectionD00.java | 53 ------------ .../websocket/WebSocketConnectionD06.java | 32 ++------ .../websocket/WebSocketConnectionD08.java | 33 +------- .../websocket/WebSocketConnectionD13.java | 32 +------- .../jetty/websocket/WebSocketFactory.java | 20 +++-- .../jetty/websocket/WebSocketServlet.java | 1 + .../websocket/WebSocketServletConnection.java | 11 +++ .../WebSocketServletConnectionD00.java | 81 +++++++++++++++++++ .../WebSocketServletConnectionD06.java | 39 +++++++++ .../WebSocketServletConnectionD08.java | 51 ++++++++++++ .../WebSocketServletConnectionD13.java | 52 ++++++++++++ 13 files changed, 263 insertions(+), 153 deletions(-) create mode 100644 jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnection.java create mode 100644 jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java create mode 100644 jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java create mode 100644 jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java create mode 100644 jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java index 5f13fecdcff..59c51d1ca8a 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java @@ -7,6 +7,7 @@ import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.util.Map; import java.util.Random; + import javax.net.ssl.SSLEngine; import org.eclipse.jetty.http.HttpFields; @@ -141,7 +142,7 @@ public class WebSocketClientFactory extends AggregateLifeCycle /* ------------------------------------------------------------ */ /** * @return the shared mask generator, or null if no shared mask generator is used - * @see {@link WebSocketClient#getMaskGen()} + * @see WebSocketClient#getMaskGen() */ public MaskGen getMaskGen() { @@ -151,7 +152,7 @@ public class WebSocketClientFactory extends AggregateLifeCycle /* ------------------------------------------------------------ */ /** * @param maskGen the shared mask generator, or null if no shared mask generator is used - * @see {@link WebSocketClient#setMaskGen(MaskGen)} + * @see WebSocketClient#setMaskGen(MaskGen) */ public void setMaskGen(MaskGen maskGen) { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java index bb3192c41f8..983c186649c 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java @@ -1,12 +1,8 @@ package org.eclipse.jetty.websocket; -import java.io.IOException; import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.nio.AsyncConnection; @@ -14,8 +10,6 @@ public interface WebSocketConnection extends AsyncConnection { void fillBuffersFrom(Buffer buffer); - void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException; - List getExtensions(); WebSocket.Connection getConnection(); diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java index aa37a0c65ba..cd7ecec8782 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java @@ -19,10 +19,6 @@ import java.security.NoSuchAlgorithmException; import java.util.Collections; import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.Buffer; @@ -30,7 +26,6 @@ import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.nio.IndirectNIOBuffer; -import org.eclipse.jetty.util.QuotedStringTokenizer; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -340,54 +335,6 @@ public class WebSocketConnectionD00 extends AbstractConnection implements WebSoc } } - public void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException - { - String uri=request.getRequestURI(); - String query=request.getQueryString(); - if (query!=null && query.length()>0) - uri+="?"+query; - uri=new HttpURI(uri).toString(); - String host=request.getHeader("Host"); - - String origin=request.getHeader("Sec-WebSocket-Origin"); - if (origin==null) - origin=request.getHeader("Origin"); - if (origin!=null) - origin= QuotedStringTokenizer.quoteIfNeeded(origin, "\r\n"); - - - String key1 = request.getHeader("Sec-WebSocket-Key1"); - - if (key1!=null) - { - String key2 = request.getHeader("Sec-WebSocket-Key2"); - setHixieKeys(key1,key2); - - response.setHeader("Upgrade","WebSocket"); - response.addHeader("Connection","Upgrade"); - if (origin!=null) - response.addHeader("Sec-WebSocket-Origin",origin); - response.addHeader("Sec-WebSocket-Location",(request.isSecure()?"wss://":"ws://")+host+uri); - if (subprotocol!=null) - response.addHeader("Sec-WebSocket-Protocol",subprotocol); - response.sendError(101,"WebSocket Protocol Handshake"); - } - else - { - response.setHeader("Upgrade","WebSocket"); - response.addHeader("Connection","Upgrade"); - response.addHeader("WebSocket-Origin",origin); - response.addHeader("WebSocket-Location",(request.isSecure()?"wss://":"ws://")+host+uri); - if (subprotocol!=null) - response.addHeader("WebSocket-Protocol",subprotocol); - response.sendError(101,"Web Socket Protocol Handshake"); - response.flushBuffer(); - if (_websocket instanceof OnFrame) - ((OnFrame)_websocket).onHandshake(this); - _websocket.onOpen(this); - } - } - public void setMaxTextMessageSize(int size) { } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java index 4ee7947c9b4..7078d51b851 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java @@ -19,9 +19,6 @@ import java.security.MessageDigest; import java.util.Collections; import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.Buffer; @@ -77,8 +74,8 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc private final static byte[] MAGIC; private final WebSocketParser _parser; private final WebSocketGenerator _generator; - private final WebSocket _webSocket; - private final OnFrame _onFrame; + protected final WebSocket _webSocket; + protected final OnFrame _onFrame; private final OnBinaryMessage _onBinaryMessage; private final OnTextMessage _onTextMessage; private final OnControl _onControl; @@ -101,11 +98,7 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc } private final WebSocketParser.FrameHandler _frameHandler= new FrameHandlerD06(); - - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - private final WebSocket.FrameConnection _connection = new FrameConnectionD06(); + protected final WebSocket.FrameConnection _connection = new FrameConnectionD06(); /* ------------------------------------------------------------ */ @@ -487,6 +480,7 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc } /* ------------------------------------------------------------ */ + @Override public String toString() { return this.getClass().getSimpleName()+"@"+_endp.getLocalAddr()+":"+_endp.getLocalPort()+"<->"+_endp.getRemoteAddr()+":"+_endp.getRemotePort(); @@ -693,29 +687,13 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc _connection.close(code,message); } + @Override public String toString() { return WebSocketConnectionD06.this.toString()+"FH"; } } - /* ------------------------------------------------------------ */ - public void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException - { - String key = request.getHeader("Sec-WebSocket-Key"); - - response.setHeader("Upgrade","WebSocket"); - response.addHeader("Connection","Upgrade"); - response.addHeader("Sec-WebSocket-Accept",hashKey(key)); - if (subprotocol!=null) - response.addHeader("Sec-WebSocket-Protocol",subprotocol); - response.sendError(101); - - if (_onFrame!=null) - _onFrame.onHandshake(_connection); - _webSocket.onOpen(_connection); - } - /* ------------------------------------------------------------ */ public static String hashKey(String key) { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java index 9839a554a3e..13294e03fa1 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java @@ -19,9 +19,6 @@ import java.security.MessageDigest; import java.util.Collections; import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.Buffer; @@ -77,13 +74,13 @@ public class WebSocketConnectionD08 extends AbstractConnection implements WebSoc } private final static byte[] MAGIC; - private final List _extensions; + protected final List _extensions; private final WebSocketParserD08 _parser; private final WebSocketParser.FrameHandler _inbound; private final WebSocketGeneratorD08 _generator; private final WebSocketGenerator _outbound; - private final WebSocket _webSocket; - private final OnFrame _onFrame; + protected final WebSocket _webSocket; + protected final OnFrame _onFrame; private final OnBinaryMessage _onBinaryMessage; private final OnTextMessage _onTextMessage; private final OnControl _onControl; @@ -110,8 +107,7 @@ public class WebSocketConnectionD08 extends AbstractConnection implements WebSoc } private final WebSocketParser.FrameHandler _frameHandler= new WSFrameHandler(); - - private final WebSocket.FrameConnection _connection = new WSFrameConnection(); + protected final WebSocket.FrameConnection _connection = new WSFrameConnection(); /* ------------------------------------------------------------ */ @@ -800,27 +796,6 @@ public class WebSocketConnectionD08 extends AbstractConnection implements WebSoc } } - /* ------------------------------------------------------------ */ - public void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException - { - String key = request.getHeader("Sec-WebSocket-Key"); - - response.setHeader("Upgrade", "WebSocket"); - response.addHeader("Connection","Upgrade"); - response.addHeader("Sec-WebSocket-Accept",hashKey(key)); - if (subprotocol!=null) - response.addHeader("Sec-WebSocket-Protocol",subprotocol); - - for(Extension ext : _extensions) - response.addHeader("Sec-WebSocket-Extensions",ext.getParameterizedName()); - - response.sendError(101); - - if (_onFrame!=null) - _onFrame.onHandshake(_connection); - _webSocket.onOpen(_connection); - } - /* ------------------------------------------------------------ */ public static String hashKey(String key) { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java index 7525ff14462..3b1962a4024 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java @@ -19,9 +19,6 @@ import java.security.MessageDigest; import java.util.Collections; import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.Buffer; @@ -106,12 +103,12 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc } private final static byte[] MAGIC; - private final List _extensions; + protected final List _extensions; private final WebSocketParserD13 _parser; private final WebSocketGeneratorD13 _generator; private final WebSocketGenerator _outbound; - private final WebSocket _webSocket; - private final OnFrame _onFrame; + protected final WebSocket _webSocket; + protected final OnFrame _onFrame; private final OnBinaryMessage _onBinaryMessage; private final OnTextMessage _onTextMessage; private final OnControl _onControl; @@ -137,7 +134,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc } } - private final WebSocket.FrameConnection _connection = new WSFrameConnection(); + protected final WebSocket.FrameConnection _connection = new WSFrameConnection(); /* ------------------------------------------------------------ */ @@ -918,27 +915,6 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc } } - /* ------------------------------------------------------------ */ - public void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException - { - String key = request.getHeader("Sec-WebSocket-Key"); - - response.setHeader("Upgrade","WebSocket"); - response.addHeader("Connection","Upgrade"); - response.addHeader("Sec-WebSocket-Accept",hashKey(key)); - if (subprotocol!=null) - response.addHeader("Sec-WebSocket-Protocol",subprotocol); - - for(Extension ext : _extensions) - response.addHeader("Sec-WebSocket-Extensions",ext.getParameterizedName()); - - response.sendError(101); - - if (_onFrame!=null) - _onFrame.onHandshake(_connection); - _webSocket.onOpen(_connection); - } - /* ------------------------------------------------------------ */ public static String hashKey(String key) { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java index ed663826e3c..b95c04eddda 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java @@ -201,22 +201,25 @@ public class WebSocketFactory ConnectedEndPoint endp = (ConnectedEndPoint)http.getEndPoint(); List extensions_requested = new ArrayList(); - for (Enumeration e=request.getHeaders("Sec-WebSocket-Extensions");e.hasMoreElements();) + @SuppressWarnings("unchecked") + Enumeration e = request.getHeaders("Sec-WebSocket-Extensions"); + while (e.hasMoreElements()) { - QuotedStringTokenizer tok = new QuotedStringTokenizer((String)e.nextElement(),","); + QuotedStringTokenizer tok = new QuotedStringTokenizer(e.nextElement(),","); while (tok.hasMoreTokens()) + { extensions_requested.add(tok.nextToken()); + } } - - final WebSocketConnection connection; + final WebSocketServletConnection connection; final List extensions; switch (draft) { case -1: case 0: extensions=Collections.emptyList(); - connection = new WebSocketConnectionD00(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol); + connection = new WebSocketServletConnectionD00(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol); break; case 1: case 2: @@ -225,16 +228,16 @@ public class WebSocketFactory case 5: case 6: extensions=Collections.emptyList(); - connection = new WebSocketConnectionD06(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol); + connection = new WebSocketServletConnectionD06(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol); break; case 7: case 8: extensions= initExtensions(extensions_requested,8-WebSocketConnectionD08.OP_EXT_DATA, 16-WebSocketConnectionD08.OP_EXT_CTRL,3); - connection = new WebSocketConnectionD08(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft); + connection = new WebSocketServletConnectionD08(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft); break; case 13: extensions= initExtensions(extensions_requested,8-WebSocketConnectionD13.OP_EXT_DATA, 16-WebSocketConnectionD13.OP_EXT_CTRL,3); - connection = new WebSocketConnectionD13(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft); + connection = new WebSocketServletConnectionD13(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft); break; default: LOG.warn("Unsupported Websocket version: "+draft); @@ -293,6 +296,7 @@ public class WebSocketFactory // Try each requested protocol WebSocket websocket = null; + @SuppressWarnings("unchecked") Enumeration protocols = request.getHeaders("Sec-WebSocket-Protocol"); String protocol=null; while (protocol==null && protocols!=null && protocols.hasMoreElements()) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java index 562c50cd871..8873c7026b1 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java @@ -41,6 +41,7 @@ import javax.servlet.http.HttpServletResponse; * that a websocket may be accept before closing. * */ +@SuppressWarnings("serial") public abstract class WebSocketServlet extends HttpServlet implements WebSocketFactory.Acceptor { WebSocketFactory _webSocketFactory; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnection.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnection.java new file mode 100644 index 00000000000..136c68ace51 --- /dev/null +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnection.java @@ -0,0 +1,11 @@ +package org.eclipse.jetty.websocket; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public interface WebSocketServletConnection extends WebSocketConnection +{ + void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException; +} diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java new file mode 100644 index 00000000000..3b9514e2696 --- /dev/null +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java @@ -0,0 +1,81 @@ +package org.eclipse.jetty.websocket; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.http.HttpURI; +import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.util.QuotedStringTokenizer; +import org.eclipse.jetty.websocket.WebSocket.OnFrame; + +public class WebSocketServletConnectionD00 extends WebSocketConnectionD00 implements WebSocketServletConnection +{ + public WebSocketServletConnectionD00(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol) + throws IOException + { + super(websocket,endpoint,buffers,timestamp,maxIdleTime,protocol); + } + + public void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException + { + String uri = request.getRequestURI(); + String query = request.getQueryString(); + if (query != null && query.length() > 0) + { + uri += "?" + query; + } + uri = new HttpURI(uri).toString(); + String host = request.getHeader("Host"); + + String origin = request.getHeader("Sec-WebSocket-Origin"); + if (origin == null) + { + origin = request.getHeader("Origin"); + } + if (origin != null) + { + origin = QuotedStringTokenizer.quoteIfNeeded(origin,"\r\n"); + } + + String key1 = request.getHeader("Sec-WebSocket-Key1"); + + if (key1 != null) + { + String key2 = request.getHeader("Sec-WebSocket-Key2"); + setHixieKeys(key1,key2); + + response.setHeader("Upgrade","WebSocket"); + response.addHeader("Connection","Upgrade"); + if (origin != null) + { + response.addHeader("Sec-WebSocket-Origin",origin); + } + response.addHeader("Sec-WebSocket-Location",(request.isSecure()?"wss://":"ws://") + host + uri); + if (subprotocol != null) + { + response.addHeader("Sec-WebSocket-Protocol",subprotocol); + } + response.sendError(101,"WebSocket Protocol Handshake"); + } + else + { + response.setHeader("Upgrade","WebSocket"); + response.addHeader("Connection","Upgrade"); + response.addHeader("WebSocket-Origin",origin); + response.addHeader("WebSocket-Location",(request.isSecure()?"wss://":"ws://") + host + uri); + if (subprotocol != null) + { + response.addHeader("WebSocket-Protocol",subprotocol); + } + response.sendError(101,"Web Socket Protocol Handshake"); + response.flushBuffer(); + if (_websocket instanceof OnFrame) + { + ((OnFrame)_websocket).onHandshake(this); + } + _websocket.onOpen(this); + } + } +} diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java new file mode 100644 index 00000000000..74b71ccea11 --- /dev/null +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java @@ -0,0 +1,39 @@ +package org.eclipse.jetty.websocket; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.io.EndPoint; + +public class WebSocketServletConnectionD06 extends WebSocketConnectionD06 implements WebSocketServletConnection +{ + public WebSocketServletConnectionD06(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol) + throws IOException + { + super(websocket,endpoint,buffers,timestamp,maxIdleTime,protocol); + } + + /* ------------------------------------------------------------ */ + public void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException + { + String key = request.getHeader("Sec-WebSocket-Key"); + + response.setHeader("Upgrade","WebSocket"); + response.addHeader("Connection","Upgrade"); + response.addHeader("Sec-WebSocket-Accept",hashKey(key)); + if (subprotocol!=null) + { + response.addHeader("Sec-WebSocket-Protocol",subprotocol); + } + + response.sendError(101); + + if (_onFrame!=null) + { + _onFrame.onHandshake(_connection); + } + _webSocket.onOpen(_connection); + } +} diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java new file mode 100644 index 00000000000..bac9be7f0da --- /dev/null +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java @@ -0,0 +1,51 @@ +package org.eclipse.jetty.websocket; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.io.EndPoint; + +public class WebSocketServletConnectionD08 extends WebSocketConnectionD08 implements WebSocketServletConnection +{ + public WebSocketServletConnectionD08(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, + List extensions, int draft, MaskGen maskgen) throws IOException + { + super(websocket,endpoint,buffers,timestamp,maxIdleTime,protocol,extensions,draft,maskgen); + } + + public WebSocketServletConnectionD08(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, + List extensions, int draft) throws IOException + { + super(websocket,endpoint,buffers,timestamp,maxIdleTime,protocol,extensions,draft); + } + + /* ------------------------------------------------------------ */ + public void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException + { + String key = request.getHeader("Sec-WebSocket-Key"); + + response.setHeader("Upgrade","WebSocket"); + response.addHeader("Connection","Upgrade"); + response.addHeader("Sec-WebSocket-Accept",hashKey(key)); + if (subprotocol != null) + { + response.addHeader("Sec-WebSocket-Protocol",subprotocol); + } + + for (Extension ext : _extensions) + { + response.addHeader("Sec-WebSocket-Extensions",ext.getParameterizedName()); + } + + response.sendError(101); + + if (_onFrame != null) + { + _onFrame.onHandshake(_connection); + } + _webSocket.onOpen(_connection); + } +} diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java new file mode 100644 index 00000000000..a55a113b367 --- /dev/null +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java @@ -0,0 +1,52 @@ +package org.eclipse.jetty.websocket; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.io.EndPoint; + +public class WebSocketServletConnectionD13 extends WebSocketConnectionD13 implements WebSocketServletConnection +{ + public WebSocketServletConnectionD13(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, + List extensions, int draft, MaskGen maskgen) throws IOException + { + super(websocket,endpoint,buffers,timestamp,maxIdleTime,protocol,extensions,draft,maskgen); + } + + public WebSocketServletConnectionD13(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, + List extensions, int draft) throws IOException + { + super(websocket,endpoint,buffers,timestamp,maxIdleTime,protocol,extensions,draft); + } + + /* ------------------------------------------------------------ */ + public void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException + { + String key = request.getHeader("Sec-WebSocket-Key"); + + response.setHeader("Upgrade","WebSocket"); + response.addHeader("Connection","Upgrade"); + response.addHeader("Sec-WebSocket-Accept",hashKey(key)); + if (subprotocol != null) + { + response.addHeader("Sec-WebSocket-Protocol",subprotocol); + } + + for (Extension ext : _extensions) + { + response.addHeader("Sec-WebSocket-Extensions",ext.getParameterizedName()); + } + + response.sendError(101); + + if (_onFrame != null) + { + _onFrame.onHandshake(_connection); + } + + _webSocket.onOpen(_connection); + } +} From c1dac27886c606110856bdf9f685c8f7dd6b6724 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Mon, 12 Dec 2011 16:17:30 -0600 Subject: [PATCH 12/56] Bug 366362 - JAX-WS over https returns the wrong request address. Applied patch by Kenny Stridh . Thanks! --- .../jetty/http/spi/HttpSpiContextHandler.java | 65 ++- .../eclipse/jetty/http/spi/JettyExchange.java | 28 + .../jetty/http/spi/JettyHttpExchange.java | 479 +++++++++--------- .../http/spi/JettyHttpExchangeDelegate.java | 228 +++++++++ .../jetty/http/spi/JettyHttpsExchange.java | 179 +++++++ 5 files changed, 728 insertions(+), 251 deletions(-) create mode 100644 jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyExchange.java create mode 100644 jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpExchangeDelegate.java create mode 100644 jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpsExchange.java diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/HttpSpiContextHandler.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/HttpSpiContextHandler.java index 9f6198e8598..62c30cac169 100644 --- a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/HttpSpiContextHandler.java +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/HttpSpiContextHandler.java @@ -1,4 +1,5 @@ package org.eclipse.jetty.http.spi; + //======================================================================== //Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd. //------------------------------------------------------------------------ @@ -12,19 +13,22 @@ package org.eclipse.jetty.http.spi; //You may elect to redistribute this code under either of these licenses. //======================================================================== -import com.sun.net.httpserver.Authenticator; -import com.sun.net.httpserver.Authenticator.Result; -import com.sun.net.httpserver.HttpContext; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpPrincipal; -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.handler.ContextHandler; +import java.io.IOException; +import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; + +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.handler.ContextHandler; + +import com.sun.net.httpserver.Authenticator; +import com.sun.net.httpserver.Authenticator.Result; +import com.sun.net.httpserver.HttpContext; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpPrincipal; /** * Jetty handler that bridges requests to {@link HttpHandler}. @@ -36,7 +40,6 @@ public class HttpSpiContextHandler extends ContextHandler private HttpHandler _httpHandler; - public HttpSpiContextHandler(HttpContext httpContext, HttpHandler httpHandler) { this._httpContext = httpContext; @@ -46,9 +49,20 @@ public class HttpSpiContextHandler extends ContextHandler @Override public void doScope(String target, Request baseRequest, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { - if (!target.startsWith(getContextPath())) return; + if (!target.startsWith(getContextPath())) + { + return; + } - JettyHttpExchange jettyHttpExchange = new JettyHttpExchange(_httpContext, req, resp); + HttpExchange jettyHttpExchange; + if (baseRequest.isSecure()) + { + jettyHttpExchange = new JettyHttpsExchange(_httpContext,req,resp); + } + else + { + jettyHttpExchange = new JettyHttpExchange(_httpContext,req,resp); + } // TODO: add filters processing @@ -56,38 +70,41 @@ public class HttpSpiContextHandler extends ContextHandler { Authenticator auth = _httpContext.getAuthenticator(); if (auth != null) - handleAuthentication(resp, jettyHttpExchange, auth); + { + handleAuthentication(resp,jettyHttpExchange,auth); + } else + { _httpHandler.handle(jettyHttpExchange); + } } - catch(Exception ex) + catch (Exception ex) { PrintWriter writer = new PrintWriter(jettyHttpExchange.getResponseBody()); - + resp.setStatus(500); writer.println("

HTTP ERROR: 500

"); writer.println("
INTERNAL_SERVER_ERROR
"); writer.println("

RequestURI=" + req.getRequestURI() + "

"); - + writer.println("
");
             ex.printStackTrace(writer);
             writer.println("
"); - + writer.println("

Powered by jetty://

"); - + writer.close(); } finally { baseRequest.setHandled(true); } - + } - - private void handleAuthentication(HttpServletResponse resp, JettyHttpExchange jettyHttpExchange, Authenticator auth) throws IOException + private void handleAuthentication(HttpServletResponse resp, HttpExchange httpExchange, Authenticator auth) throws IOException { - Result result = auth.authenticate(jettyHttpExchange); + Result result = auth.authenticate(httpExchange); if (result instanceof Authenticator.Failure) { int rc = ((Authenticator.Failure)result).getResponseCode(); @@ -101,8 +118,8 @@ public class HttpSpiContextHandler extends ContextHandler else if (result instanceof Authenticator.Success) { HttpPrincipal principal = ((Authenticator.Success)result).getPrincipal(); - jettyHttpExchange.setPrincipal(principal); - _httpHandler.handle(jettyHttpExchange); + ((JettyExchange)httpExchange).setPrincipal(principal); + _httpHandler.handle(httpExchange); } } diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyExchange.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyExchange.java new file mode 100644 index 00000000000..f448c118185 --- /dev/null +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyExchange.java @@ -0,0 +1,28 @@ +// ======================================================================== +// Copyright (c) 2009-2009 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.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + +package org.eclipse.jetty.http.spi; + +import com.sun.net.httpserver.HttpPrincipal; + +/* ------------------------------------------------------------ */ +/** + */ +public interface JettyExchange +{ + + HttpPrincipal getPrincipal(); + + void setPrincipal(HttpPrincipal principal); + +} \ No newline at end of file diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpExchange.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpExchange.java index 9ce8e959d83..41809d036e3 100644 --- a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpExchange.java +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpExchange.java @@ -1,227 +1,252 @@ -package org.eclipse.jetty.http.spi; - -//======================================================================== -//Copyright (c) 2004-2009 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.opensource.org/licenses/apache2.0.php -//You may elect to redistribute this code under either of these licenses. -//======================================================================== - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.InetSocketAddress; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Enumeration; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.sun.net.httpserver.Headers; -import com.sun.net.httpserver.HttpContext; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpPrincipal; - -/** - * Jetty implementation of {@link com.sun.net.httpserver.HttpExchange} - */ -public class JettyHttpExchange extends HttpExchange -{ - - private HttpContext _httpContext; - - private HttpServletRequest _req; - - private HttpServletResponse _resp; - - private Headers _responseHeaders = new Headers(); - - private int _responseCode = 0; - - private InputStream _is; - - private OutputStream _os; - - private HttpPrincipal _httpPrincipal; - - - public JettyHttpExchange(HttpContext jaxWsContext , HttpServletRequest req, - HttpServletResponse resp) - { - this._httpContext = jaxWsContext; - this._req = req; - this._resp = resp; - try - { - this._is = req.getInputStream(); - this._os = resp.getOutputStream(); - } - catch (IOException ex) - { - throw new RuntimeException(ex); - } - } - - @Override - public Headers getRequestHeaders() - { - Headers headers = new Headers(); - Enumeration en = _req.getHeaderNames(); - while (en.hasMoreElements()) - { - String name = (String) en.nextElement(); - Enumeration en2 = _req.getHeaders(name); - while (en2.hasMoreElements()) - { - String value = (String) en2.nextElement(); - headers.add(name, value); - } - } - return headers; - } - - @Override - public Headers getResponseHeaders() - { - return _responseHeaders; - } - - @Override - public URI getRequestURI() - { - try - { - String uriAsString = _req.getRequestURI(); - if (_req.getQueryString() != null) - uriAsString += "?" + _req.getQueryString(); - - return new URI(uriAsString); - } - catch (URISyntaxException ex) - { - throw new RuntimeException(ex); - } - } - - @Override - public String getRequestMethod() - { - return _req.getMethod(); - } - - @Override - public HttpContext getHttpContext() - { - return _httpContext; - } - - @Override - public void close() - { - try - { - _resp.getOutputStream().close(); - } - catch (IOException ex) - { - throw new RuntimeException(ex); - } - } - - @Override - public InputStream getRequestBody() - { - return _is; - } - - @Override - public OutputStream getResponseBody() - { - return _os; - } - - @Override - public void sendResponseHeaders(int rCode, long responseLength) - throws IOException - { - this._responseCode = rCode; - - for (Map.Entry> stringListEntry : _responseHeaders.entrySet()) - { - String name = stringListEntry.getKey(); - List values = stringListEntry.getValue(); - - for (String value : values) - { - _resp.setHeader(name, value); - } - } - if (responseLength > 0) - _resp.setHeader("content-length", "" + responseLength); - _resp.setStatus(rCode); - } - - @Override - public InetSocketAddress getRemoteAddress() - { - return new InetSocketAddress(_req.getRemoteAddr(), _req.getRemotePort()); - } - - @Override - public int getResponseCode() - { - return _responseCode; - } - - @Override - public InetSocketAddress getLocalAddress() - { - return new InetSocketAddress(_req.getLocalAddr(), _req.getLocalPort()); - } - - @Override - public String getProtocol() - { - return _req.getProtocol(); - } - - @Override - public Object getAttribute(String name) - { - return _req.getAttribute(name); - } - - @Override - public void setAttribute(String name, Object value) - { - _req.setAttribute(name, value); - } - - @Override - public void setStreams(InputStream i, OutputStream o) - { - _is = i; - _os = o; - } - - @Override - public HttpPrincipal getPrincipal() - { - return _httpPrincipal; - } - - public void setPrincipal(HttpPrincipal principal) - { - this._httpPrincipal = principal; - } - -} +// ======================================================================== +// Copyright (c) 2009-2009 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.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + +package org.eclipse.jetty.http.spi; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpContext; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpPrincipal; + +/* ------------------------------------------------------------ */ +/** + */ +public class JettyHttpExchange extends HttpExchange implements JettyExchange +{ + private JettyHttpExchangeDelegate _delegate; + + public JettyHttpExchange(HttpContext jaxWsContext, HttpServletRequest req, HttpServletResponse resp) + { + super(); + _delegate = new JettyHttpExchangeDelegate(jaxWsContext,req,resp); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#hashCode() + */ + @Override + public int hashCode() + { + return _delegate.hashCode(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getRequestHeaders() + */ + @Override + public Headers getRequestHeaders() + { + return _delegate.getRequestHeaders(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getResponseHeaders() + */ + @Override + public Headers getResponseHeaders() + { + return _delegate.getResponseHeaders(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getRequestURI() + */ + @Override + public URI getRequestURI() + { + return _delegate.getRequestURI(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getRequestMethod() + */ + @Override + public String getRequestMethod() + { + return _delegate.getRequestMethod(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getHttpContext() + */ + @Override + public HttpContext getHttpContext() + { + return _delegate.getHttpContext(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#close() + */ + @Override + public void close() + { + _delegate.close(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + return _delegate.equals(obj); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getRequestBody() + */ + @Override + public InputStream getRequestBody() + { + return _delegate.getRequestBody(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getResponseBody() + */ + @Override + public OutputStream getResponseBody() + { + return _delegate.getResponseBody(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#sendResponseHeaders(int, long) + */ + @Override + public void sendResponseHeaders(int rCode, long responseLength) throws IOException + { + _delegate.sendResponseHeaders(rCode,responseLength); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getRemoteAddress() + */ + @Override + public InetSocketAddress getRemoteAddress() + { + return _delegate.getRemoteAddress(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getResponseCode() + */ + @Override + public int getResponseCode() + { + return _delegate.getResponseCode(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getLocalAddress() + */ + @Override + public InetSocketAddress getLocalAddress() + { + return _delegate.getLocalAddress(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getProtocol() + */ + @Override + public String getProtocol() + { + return _delegate.getProtocol(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getAttribute(java.lang.String) + */ + @Override + public Object getAttribute(String name) + { + return _delegate.getAttribute(name); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#setAttribute(java.lang.String, java.lang.Object) + */ + @Override + public void setAttribute(String name, Object value) + { + _delegate.setAttribute(name,value); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#setStreams(java.io.InputStream, java.io.OutputStream) + */ + @Override + public void setStreams(InputStream i, OutputStream o) + { + _delegate.setStreams(i,o); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#getPrincipal() + */ + @Override + public HttpPrincipal getPrincipal() + { + return _delegate.getPrincipal(); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#setPrincipal(com.sun.net.httpserver.HttpPrincipal) + */ + public void setPrincipal(HttpPrincipal principal) + { + _delegate.setPrincipal(principal); + } + + /* ------------------------------------------------------------ */ + /** + * @see org.eclipse.jetty.http.spi.JettyExchange#toString() + */ + @Override + public String toString() + { + return _delegate.toString(); + } + +} diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpExchangeDelegate.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpExchangeDelegate.java new file mode 100644 index 00000000000..b772afbe598 --- /dev/null +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpExchangeDelegate.java @@ -0,0 +1,228 @@ +package org.eclipse.jetty.http.spi; + +//======================================================================== +//Copyright (c) 2004-2009 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.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Enumeration; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpContext; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpPrincipal; + +/** + * Jetty implementation of {@link com.sun.net.httpserver.HttpExchange} + */ +public class JettyHttpExchangeDelegate extends HttpExchange +{ + + private HttpContext _httpContext; + + private HttpServletRequest _req; + + private HttpServletResponse _resp; + + private Headers _responseHeaders = new Headers(); + + private int _responseCode = 0; + + private InputStream _is; + + private OutputStream _os; + + private HttpPrincipal _httpPrincipal; + + JettyHttpExchangeDelegate(HttpContext jaxWsContext, HttpServletRequest req, HttpServletResponse resp) + { + this._httpContext = jaxWsContext; + this._req = req; + this._resp = resp; + try + { + this._is = req.getInputStream(); + this._os = resp.getOutputStream(); + } + catch (IOException ex) + { + throw new RuntimeException(ex); + } + } + + @Override + public Headers getRequestHeaders() + { + Headers headers = new Headers(); + Enumeration en = _req.getHeaderNames(); + while (en.hasMoreElements()) + { + String name = (String)en.nextElement(); + Enumeration en2 = _req.getHeaders(name); + while (en2.hasMoreElements()) + { + String value = (String)en2.nextElement(); + headers.add(name,value); + } + } + return headers; + } + + @Override + public Headers getResponseHeaders() + { + return _responseHeaders; + } + + @Override + public URI getRequestURI() + { + try + { + String uriAsString = _req.getRequestURI(); + if (_req.getQueryString() != null) + { + uriAsString += "?" + _req.getQueryString(); + } + + return new URI(uriAsString); + } + catch (URISyntaxException ex) + { + throw new RuntimeException(ex); + } + } + + @Override + public String getRequestMethod() + { + return _req.getMethod(); + } + + @Override + public HttpContext getHttpContext() + { + return _httpContext; + } + + @Override + public void close() + { + try + { + _resp.getOutputStream().close(); + } + catch (IOException ex) + { + throw new RuntimeException(ex); + } + } + + @Override + public InputStream getRequestBody() + { + return _is; + } + + @Override + public OutputStream getResponseBody() + { + return _os; + } + + @Override + public void sendResponseHeaders(int rCode, long responseLength) throws IOException + { + this._responseCode = rCode; + + for (Map.Entry> stringListEntry : _responseHeaders.entrySet()) + { + String name = stringListEntry.getKey(); + List values = stringListEntry.getValue(); + + for (String value : values) + { + _resp.setHeader(name,value); + } + } + if (responseLength > 0) + { + _resp.setHeader("content-length","" + responseLength); + } + _resp.setStatus(rCode); + } + + @Override + public InetSocketAddress getRemoteAddress() + { + return new InetSocketAddress(_req.getRemoteAddr(),_req.getRemotePort()); + } + + @Override + public int getResponseCode() + { + return _responseCode; + } + + @Override + public InetSocketAddress getLocalAddress() + { + return new InetSocketAddress(_req.getLocalAddr(),_req.getLocalPort()); + } + + @Override + public String getProtocol() + { + return _req.getProtocol(); + } + + @Override + public Object getAttribute(String name) + { + return _req.getAttribute(name); + } + + @Override + public void setAttribute(String name, Object value) + { + _req.setAttribute(name,value); + } + + @Override + public void setStreams(InputStream i, OutputStream o) + { + _is = i; + _os = o; + } + + @Override + public HttpPrincipal getPrincipal() + { + return _httpPrincipal; + } + + public void setPrincipal(HttpPrincipal principal) + { + this._httpPrincipal = principal; + } + +} diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpsExchange.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpsExchange.java new file mode 100644 index 00000000000..f4af2b99ce9 --- /dev/null +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpsExchange.java @@ -0,0 +1,179 @@ +// ======================================================================== +// Copyright (c) 2009-2009 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.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + +package org.eclipse.jetty.http.spi; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.URI; + +import javax.net.ssl.SSLSession; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpContext; +import com.sun.net.httpserver.HttpPrincipal; +import com.sun.net.httpserver.HttpsExchange; + +/* ------------------------------------------------------------ */ +/** + */ +public class JettyHttpsExchange extends HttpsExchange implements JettyExchange +{ + private JettyHttpExchangeDelegate _delegate; + + public JettyHttpsExchange(HttpContext jaxWsContext, HttpServletRequest req, HttpServletResponse resp) + { + super(); + _delegate = new JettyHttpExchangeDelegate(jaxWsContext,req,resp); + } + + @Override + public int hashCode() + { + return _delegate.hashCode(); + } + + @Override + public Headers getRequestHeaders() + { + return _delegate.getRequestHeaders(); + } + + @Override + public Headers getResponseHeaders() + { + return _delegate.getResponseHeaders(); + } + + @Override + public URI getRequestURI() + { + return _delegate.getRequestURI(); + } + + @Override + public String getRequestMethod() + { + return _delegate.getRequestMethod(); + } + + @Override + public HttpContext getHttpContext() + { + return _delegate.getHttpContext(); + } + + @Override + public void close() + { + _delegate.close(); + } + + @Override + public boolean equals(Object obj) + { + return _delegate.equals(obj); + } + + @Override + public InputStream getRequestBody() + { + return _delegate.getRequestBody(); + } + + @Override + public OutputStream getResponseBody() + { + return _delegate.getResponseBody(); + } + + @Override + public void sendResponseHeaders(int rCode, long responseLength) throws IOException + { + _delegate.sendResponseHeaders(rCode,responseLength); + } + + @Override + public InetSocketAddress getRemoteAddress() + { + return _delegate.getRemoteAddress(); + } + + @Override + public int getResponseCode() + { + return _delegate.getResponseCode(); + } + + @Override + public InetSocketAddress getLocalAddress() + { + return _delegate.getLocalAddress(); + } + + @Override + public String getProtocol() + { + return _delegate.getProtocol(); + } + + @Override + public Object getAttribute(String name) + { + return _delegate.getAttribute(name); + } + + @Override + public void setAttribute(String name, Object value) + { + _delegate.setAttribute(name,value); + } + + @Override + public void setStreams(InputStream i, OutputStream o) + { + _delegate.setStreams(i,o); + } + + @Override + public HttpPrincipal getPrincipal() + { + return _delegate.getPrincipal(); + } + + public void setPrincipal(HttpPrincipal principal) + { + _delegate.setPrincipal(principal); + } + + @Override + public String toString() + { + return _delegate.toString(); + } + + /* ------------------------------------------------------------ */ + /** + * @see com.sun.net.httpserver.HttpsExchange#getSSLSession() + */ + @Override + public SSLSession getSSLSession() + { + return null; + } + +} From dfb96dfeeb7dbbdafae87496da671cb0ee5b71e4 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Tue, 13 Dec 2011 11:07:26 +1100 Subject: [PATCH 13/56] 366342 Dont persist DosFilter trackers in http session --- .../org/eclipse/jetty/servlets/DoSFilter.java | 63 ++++++++++++++----- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java index 69bd7d89265..6c12e2e75b3 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java @@ -14,7 +14,9 @@ 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; @@ -32,8 +34,10 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpSessionActivationListener; import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingListener; +import javax.servlet.http.HttpSessionEvent; import org.eclipse.jetty.continuation.Continuation; import org.eclipse.jetty.continuation.ContinuationListener; @@ -908,13 +912,14 @@ public class DoSFilter implements Filter * A RateTracker is associated with a connection, and stores request rate * data. */ - class RateTracker extends Timeout.Task implements HttpSessionBindingListener + class RateTracker extends Timeout.Task implements HttpSessionBindingListener, HttpSessionActivationListener { - protected final String _id; - protected final int _type; - protected final long[] _timestamps; - protected int _next; - + transient protected final String _id; + transient protected final int _type; + transient protected final long[] _timestamps; + transient protected int _next; + + public RateTracker(String id, int type,int maxRequestsPerSecond) { _id = id; @@ -953,25 +958,49 @@ public class DoSFilter implements Filter public void valueBound(HttpSessionBindingEvent event) - { + { + if (LOG.isDebugEnabled()) + LOG.debug("Value bound:"+_id); } public void valueUnbound(HttpSessionBindingEvent event) { - _rateTrackers.remove(_id); + //take the tracker out of the list of trackers + if (_rateTrackers != null) + _rateTrackers.remove(_id); + if (LOG.isDebugEnabled()) LOG.debug("Tracker removed: "+_id); } + public void sessionWillPassivate(HttpSessionEvent se) + { + //take the tracker of the list of trackers (if its still there) + //and ensure that we take ourselves out of the session so we are not saved + if (_rateTrackers != null) + _rateTrackers.remove(_id); + se.getSession().removeAttribute(__TRACKER); + if (LOG.isDebugEnabled()) LOG.debug("Value removed: "+_id); + } + + public void sessionDidActivate(HttpSessionEvent se) + { + LOG.warn("Unexpected session activation"); + } + + public void expired() { - long now = _trackerTimeoutQ.getNow(); - int latestIndex = _next == 0 ? 3 : (_next - 1 ) % _timestamps.length; - long last=_timestamps[latestIndex]; - boolean hasRecentRequest = last != 0 && (now-last)<1000L; + if (_rateTrackers != null && _trackerTimeoutQ != null) + { + long now = _trackerTimeoutQ.getNow(); + int latestIndex = _next == 0 ? 3 : (_next - 1 ) % _timestamps.length; + long last=_timestamps[latestIndex]; + boolean hasRecentRequest = last != 0 && (now-last)<1000L; - if (hasRecentRequest) - reschedule(); - else - _rateTrackers.remove(_id); + if (hasRecentRequest) + reschedule(); + else + _rateTrackers.remove(_id); + } } @Override @@ -979,6 +1008,8 @@ public class DoSFilter implements Filter { return "RateTracker/"+_id+"/"+_type; } + + } class FixedRateTracker extends RateTracker From fa0e06d186723b95cc70602f34ae15364771fc61 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 13 Dec 2011 11:14:25 +0100 Subject: [PATCH 14/56] Removed guard whether the channel is closed in checkIdleTimestamp(). This follows commit ff29a1cc51325ebf4f95feaa4bed847023a7e3fc for JETTY-1322. The reason to remove the guard is that the channel may be closed multiple times, and if for any reason a check to the idle timestamp triggers, then the idle callback is invoked, but it's not really idle: it is already closed. When used with SSL, this causes a truncation attack exception thrown by SSLEngine, because the idle callback causes a shutdown of the SSLEngine without having received a SSL close alert. --- .../org/eclipse/jetty/io/nio/SelectChannelEndPoint.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index cf69878278a..cc698d5e4e7 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -262,25 +262,25 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo { _idleTimestamp=check?System.currentTimeMillis():0; } - + /* ------------------------------------------------------------ */ public boolean isCheckForIdle() { return _idleTimestamp!=0; } - + /* ------------------------------------------------------------ */ protected void notIdle() { if (_idleTimestamp!=0) _idleTimestamp=System.currentTimeMillis(); } - + /* ------------------------------------------------------------ */ public void checkIdleTimestamp(long now) { long idleTimestamp=_idleTimestamp; - if (!getChannel().isOpen() || idleTimestamp!=0 && _maxIdleTime>0 && now>(idleTimestamp+_maxIdleTime)) + if (idleTimestamp!=0 && _maxIdleTime>0 && now>(idleTimestamp+_maxIdleTime)) { onIdleExpired(); _idleTimestamp=now; From bcbcbafb14bdefd43ffb28c033acffe0dde33dbf Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 13 Dec 2011 11:15:04 +0100 Subject: [PATCH 15/56] More tests for WebSocket over SSL. --- .../jetty/websocket/WebSocketOverSSLTest.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java index b78baf44de9..a9e07a0b60d 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java @@ -2,6 +2,7 @@ package org.eclipse.jetty.websocket; import java.io.IOException; import java.net.URI; +import java.util.Arrays; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletRequest; @@ -121,4 +122,63 @@ public class WebSocketOverSSLTest Assert.assertTrue(serverLatch.await(5, TimeUnit.SECONDS)); Assert.assertTrue(clientLatch.await(5, TimeUnit.SECONDS)); } + + @Test + public void testManyMessages() throws Exception + { + startServer(new WebSocket.OnTextMessage() + { + private Connection connection; + + public void onOpen(Connection connection) + { + this.connection = connection; + } + + public void onMessage(String data) + { + try + { + connection.sendMessage(data); + } + catch (IOException x) + { + x.printStackTrace(); + } + } + + public void onClose(int closeCode, String message) + { + } + }); + int count = 1000; + final CountDownLatch clientLatch = new CountDownLatch(count); + startClient(new WebSocket.OnTextMessage() + { + public void onOpen(Connection connection) + { + } + + public void onMessage(String data) + { + clientLatch.countDown(); + } + + public void onClose(int closeCode, String message) + { + } + }); + + char[] chars = new char[256]; + Arrays.fill(chars, 'x'); + String message = new String(chars); + for (int i = 0; i < count; ++i) + _connection.sendMessage(message); + + Assert.assertTrue(clientLatch.await(5, TimeUnit.SECONDS)); + + // While messages may have all arrived, the SSL close alert + // may be in the way so give some time for it to be processed. + TimeUnit.SECONDS.sleep(1); + } } From 42816041c08de44852d4987329b2ab4a05003612 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 13 Dec 2011 11:26:30 -0700 Subject: [PATCH 16/56] JETTY-1463 - WebSockets with Safari gets messages stuck as if in a buffer that needs to be flushed. + Adding unit test to attempt to replicate behavior (test passes) --- jetty-websocket/pom.xml | 6 + .../jetty/websocket/WebSocketCommTest.java | 217 ++++++++++++++++++ 2 files changed, 223 insertions(+) create mode 100644 jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index 1bc5214b513..cfb4b91e581 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -46,6 +46,12 @@ jetty-test-helper test + + org.eclipse.jetty + jetty-servlet + ${project.version} + test + diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java new file mode 100644 index 00000000000..88f311d6527 --- /dev/null +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java @@ -0,0 +1,217 @@ +package org.eclipse.jetty.websocket; + +import static org.hamcrest.Matchers.*; + +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.log.StdErrLog; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * WebSocketCommTest - to test reported undelivered messages in bug JETTY-1463 + */ +public class WebSocketCommTest +{ + @SuppressWarnings("serial") + private static class WebSocketCaptureServlet extends WebSocketServlet + { + public List captures = new ArrayList();; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + resp.sendError(404); + } + + public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) + { + CaptureSocket capture = new CaptureSocket(); + captures.add(capture); + return capture; + } + } + + private static class CaptureSocket implements WebSocket, WebSocket.OnTextMessage + { + private Connection conn; + public List messages; + + public CaptureSocket() + { + messages = new ArrayList(); + } + + public boolean isConnected() + { + if (conn == null) + { + return false; + } + return conn.isOpen(); + } + + public void onMessage(String data) + { + System.out.printf("Received Message \"%s\" [size %d]%n", data, data.length()); + messages.add(data); + } + + public void onOpen(Connection connection) + { + this.conn = connection; + } + + public void onClose(int closeCode, String message) + { + this.conn = null; + } + } + + public static class MessageSender implements WebSocket + { + private Connection conn; + private CountDownLatch connectLatch = new CountDownLatch(1); + + public void onOpen(Connection connection) + { + this.conn = connection; + connectLatch.countDown(); + } + + public void onClose(int closeCode, String message) + { + this.conn = null; + } + + public boolean isConnected() + { + if (this.conn == null) + { + return false; + } + return this.conn.isOpen(); + } + + public void sendMessage(String format, Object... args) throws IOException + { + this.conn.sendMessage(String.format(format,args)); + } + + public void awaitConnect() throws InterruptedException + { + connectLatch.await(1,TimeUnit.SECONDS); + } + + public void close() + { + if (this.conn == null) + { + return; + } + this.conn.close(); + } + } + + private Server server; + private WebSocketCaptureServlet servlet; + private URI serverUri; + + @BeforeClass + public static void initLogging() + { + // Configure Logging + System.setProperty("org.eclipse.jetty.util.log.class",StdErrLog.class.getName()); + System.setProperty("org.eclipse.jetty.LEVEL","DEBUG"); + } + + @Before + public void startServer() throws Exception + { + // Configure Server + server = new Server(0); + + ServletContextHandler context = new ServletContextHandler(); + context.setContextPath("/"); + server.setHandler(context); + + // Serve capture servlet + servlet = new WebSocketCaptureServlet(); + context.addServlet(new ServletHolder(servlet),"/"); + + // Start Server + server.start(); + + Connector conn = server.getConnectors()[0]; + String host = conn.getHost(); + if (host == null) + { + host = "localhost"; + } + int port = conn.getLocalPort(); + serverUri = new URI(String.format("ws://%s:%d/",host,port)); + System.out.printf("Server URI: %s%n",serverUri); + } + + @Test + public void testSendTextMessages() throws Exception + { + WebSocketClientFactory clientFactory = new WebSocketClientFactory(); + clientFactory.start(); + + WebSocketClient wsc = clientFactory.newWebSocketClient(); + MessageSender sender = new MessageSender(); + wsc.open(serverUri,sender); + + try + { + sender.awaitConnect(); + + // Send 5 short messages + for (int i = 0; i < 5; i++) + { + System.out.printf("Sending msg-%d%n",i); + sender.sendMessage("msg-%d",i); + } + + // Servlet should show only 1 connection. + Assert.assertThat("Servlet.captureSockets.size",servlet.captures.size(),is(1)); + + CaptureSocket socket = servlet.captures.get(0); + Assert.assertThat("CaptureSocket",socket,notNullValue()); + Assert.assertThat("CaptureSocket.isConnected", socket.isConnected(), is(true)); + + // Give servlet 500 millisecond to process messages + threadSleep(500,TimeUnit.MILLISECONDS); + // Should have captured 5 messages. + Assert.assertThat("CaptureSocket.messages.size",socket.messages.size(),is(5)); + } + finally + { + System.out.println("Closing client socket"); + sender.close(); + } + } + + public static void threadSleep(int dur, TimeUnit unit) throws InterruptedException + { + long ms = TimeUnit.MILLISECONDS.convert(dur,unit); + Thread.sleep(ms); + } +} From 6b42a1c45d6c62f9eedd72e547b62f93bac7a253 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 14 Dec 2011 10:23:40 -0700 Subject: [PATCH 17/56] JETTY-1463 - WebSockets with Safari gets messages stuck as if in a buffer that needs to be flushed. + Implementation of Safari WebSocket Draft-0 behavior in a unit test. (Test fails, and is currently set as @Ignore) --- .../websocket/SafariWebsocketDraft0Test.java | 110 +++++++++++++++ .../jetty/websocket/WebSocketCommTest.java | 111 +-------------- .../jetty/websocket/helper/CaptureSocket.java | 42 ++++++ .../jetty/websocket/helper/MessageSender.java | 52 +++++++ .../jetty/websocket/helper/SafariD00.java | 129 ++++++++++++++++++ .../helper/WebSocketCaptureServlet.java | 31 +++++ 6 files changed, 367 insertions(+), 108 deletions(-) create mode 100644 jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java create mode 100644 jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java create mode 100644 jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java create mode 100644 jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java create mode 100644 jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/WebSocketCaptureServlet.java diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java new file mode 100644 index 00000000000..3d7f2864143 --- /dev/null +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java @@ -0,0 +1,110 @@ +package org.eclipse.jetty.websocket; + +import static org.hamcrest.Matchers.*; + +import java.net.URI; +import java.util.concurrent.TimeUnit; + +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.log.StdErrLog; +import org.eclipse.jetty.websocket.helper.CaptureSocket; +import org.eclipse.jetty.websocket.helper.SafariD00; +import org.eclipse.jetty.websocket.helper.WebSocketCaptureServlet; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +public class SafariWebsocketDraft0Test +{ + private Server server; + private WebSocketCaptureServlet servlet; + private URI serverUri; + + @BeforeClass + public static void initLogging() + { + // Configure Logging + System.setProperty("org.eclipse.jetty.util.log.class",StdErrLog.class.getName()); + System.setProperty("org.eclipse.jetty.LEVEL","DEBUG"); + } + + @Before + public void startServer() throws Exception + { + // Configure Server + server = new Server(0); + + ServletContextHandler context = new ServletContextHandler(); + context.setContextPath("/"); + server.setHandler(context); + + // Serve capture servlet + servlet = new WebSocketCaptureServlet(); + context.addServlet(new ServletHolder(servlet),"/"); + + // Start Server + server.start(); + + Connector conn = server.getConnectors()[0]; + String host = conn.getHost(); + if (host == null) + { + host = "localhost"; + } + int port = conn.getLocalPort(); + serverUri = new URI(String.format("ws://%s:%d/",host,port)); + System.out.printf("Server URI: %s%n",serverUri); + } + + @Test + @Ignore + public void testSendTextMessages() throws Exception + { + SafariD00 safari = new SafariD00(serverUri); + + try + { + safari.connect(); + safari.issueHandshake(); + + // Send 5 short messages, using technique seen in Safari. + safari.sendMessage("aa-0"); // single msg + safari.sendMessage("aa-1", "aa-2", "aa-3", "aa-4"); + + // Servlet should show only 1 connection. + Assert.assertThat("Servlet.captureSockets.size",servlet.captures.size(),is(1)); + + CaptureSocket socket = servlet.captures.get(0); + Assert.assertThat("CaptureSocket",socket,notNullValue()); + Assert.assertThat("CaptureSocket.isConnected", socket.isConnected(), is(true)); + + // Give servlet 500 millisecond to process messages + threadSleep(1,TimeUnit.SECONDS); + // Should have captured 5 messages. + Assert.assertThat("CaptureSocket.messages.size",socket.messages.size(),is(5)); + } + finally + { + System.out.println("Closing client socket"); + safari.disconnect(); + } + } + + public static void threadSleep(int dur, TimeUnit unit) throws InterruptedException + { + long ms = TimeUnit.MILLISECONDS.convert(dur,unit); + Thread.sleep(ms); + } + + @After + public void stopServer() throws Exception + { + server.stop(); + } +} diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java index 88f311d6527..c2017f7c0a9 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java @@ -2,22 +2,17 @@ package org.eclipse.jetty.websocket; import static org.hamcrest.Matchers.*; -import java.io.IOException; import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.util.log.StdErrLog; +import org.eclipse.jetty.websocket.helper.CaptureSocket; +import org.eclipse.jetty.websocket.helper.MessageSender; +import org.eclipse.jetty.websocket.helper.WebSocketCaptureServlet; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; @@ -29,106 +24,6 @@ import org.junit.Test; */ public class WebSocketCommTest { - @SuppressWarnings("serial") - private static class WebSocketCaptureServlet extends WebSocketServlet - { - public List captures = new ArrayList();; - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException - { - resp.sendError(404); - } - - public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) - { - CaptureSocket capture = new CaptureSocket(); - captures.add(capture); - return capture; - } - } - - private static class CaptureSocket implements WebSocket, WebSocket.OnTextMessage - { - private Connection conn; - public List messages; - - public CaptureSocket() - { - messages = new ArrayList(); - } - - public boolean isConnected() - { - if (conn == null) - { - return false; - } - return conn.isOpen(); - } - - public void onMessage(String data) - { - System.out.printf("Received Message \"%s\" [size %d]%n", data, data.length()); - messages.add(data); - } - - public void onOpen(Connection connection) - { - this.conn = connection; - } - - public void onClose(int closeCode, String message) - { - this.conn = null; - } - } - - public static class MessageSender implements WebSocket - { - private Connection conn; - private CountDownLatch connectLatch = new CountDownLatch(1); - - public void onOpen(Connection connection) - { - this.conn = connection; - connectLatch.countDown(); - } - - public void onClose(int closeCode, String message) - { - this.conn = null; - } - - public boolean isConnected() - { - if (this.conn == null) - { - return false; - } - return this.conn.isOpen(); - } - - public void sendMessage(String format, Object... args) throws IOException - { - this.conn.sendMessage(String.format(format,args)); - } - - public void awaitConnect() throws InterruptedException - { - connectLatch.await(1,TimeUnit.SECONDS); - } - - public void close() - { - if (this.conn == null) - { - return; - } - this.conn.close(); - } - } - private Server server; private WebSocketCaptureServlet servlet; private URI serverUri; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java new file mode 100644 index 00000000000..45842596af3 --- /dev/null +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java @@ -0,0 +1,42 @@ +package org.eclipse.jetty.websocket.helper; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jetty.websocket.WebSocket; + +public class CaptureSocket implements WebSocket, WebSocket.OnTextMessage +{ + private Connection conn; + public List messages; + + public CaptureSocket() + { + messages = new ArrayList(); + } + + public boolean isConnected() + { + if (conn == null) + { + return false; + } + return conn.isOpen(); + } + + public void onMessage(String data) + { + System.out.printf("Received Message \"%s\" [size %d]%n", data, data.length()); + messages.add(data); + } + + public void onOpen(Connection connection) + { + this.conn = connection; + } + + public void onClose(int closeCode, String message) + { + this.conn = null; + } +} \ No newline at end of file diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java new file mode 100644 index 00000000000..1a039ceb192 --- /dev/null +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java @@ -0,0 +1,52 @@ +package org.eclipse.jetty.websocket.helper; + +import java.io.IOException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.eclipse.jetty.websocket.WebSocket; + +public class MessageSender implements WebSocket +{ + private Connection conn; + private CountDownLatch connectLatch = new CountDownLatch(1); + + public void onOpen(Connection connection) + { + this.conn = connection; + connectLatch.countDown(); + } + + public void onClose(int closeCode, String message) + { + this.conn = null; + } + + public boolean isConnected() + { + if (this.conn == null) + { + return false; + } + return this.conn.isOpen(); + } + + public void sendMessage(String format, Object... args) throws IOException + { + this.conn.sendMessage(String.format(format,args)); + } + + public void awaitConnect() throws InterruptedException + { + connectLatch.await(1,TimeUnit.SECONDS); + } + + public void close() + { + if (this.conn == null) + { + return; + } + this.conn.close(); + } +} \ No newline at end of file diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java new file mode 100644 index 00000000000..a1370f092a0 --- /dev/null +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java @@ -0,0 +1,129 @@ +package org.eclipse.jetty.websocket.helper; + +import static org.hamcrest.Matchers.*; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketAddress; +import java.net.URI; + +import org.eclipse.jetty.io.ByteArrayBuffer; +import org.eclipse.jetty.util.TypeUtil; +import org.junit.Assert; + +public class SafariD00 +{ + private URI uri; + private SocketAddress endpoint; + private Socket socket; + private OutputStream out; + private InputStream in; + + public SafariD00(URI uri) + { + this.uri = uri; + this.endpoint = new InetSocketAddress(uri.getHost(),uri.getPort()); + } + + /** + * Open the Socket to the destination endpoint and + * + * @return the open java Socket. + * @throws IOException + */ + public Socket connect() throws IOException + { + socket = new Socket(); + socket.connect(endpoint,1000); + + out = socket.getOutputStream(); + in = socket.getInputStream(); + + return socket; + } + + /** + * Issue an Http websocket (Draft-0) upgrade request using the Safari particulars. + * + * @throws UnsupportedEncodingException + */ + public void issueHandshake() throws IOException + { + StringBuilder req = new StringBuilder(); + req.append("GET ").append(uri.getPath()).append(" HTTP/1.1\r\n"); + req.append("Upgrade: WebSocket\r\n"); + req.append("Connection: Upgrade\r\n"); + req.append("Host: ").append(uri.getHost()).append(":").append(uri.getPort()).append("\r\n"); + req.append("Origin: http://www.google.com/\r\n"); + req.append("Sec-WebSocket-Key1: 15{ft :6@87 0 M 5 c901\r\n"); + 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); + + byte reqBytes[] = req.toString().getBytes("UTF-8"); + byte hixieBytes[] = TypeUtil.fromHexString("e739617916c9daf3"); + byte buf[] = new byte[reqBytes.length + hixieBytes.length]; + System.arraycopy(reqBytes,0,buf,0,reqBytes.length); + System.arraycopy(hixieBytes,0,buf,reqBytes.length,hixieBytes.length); + + // Send HTTP GET Request (with hixie bytes) + out.write(buf,0,buf.length); + out.flush(); + + // Read HTTP 101 Upgrade / Handshake Response + InputStreamReader reader = new InputStreamReader(in); + BufferedReader br = new BufferedReader(reader); + + boolean foundEnd = false; + String line; + while (!foundEnd) + { + line = br.readLine(); + System.out.printf("RESP: %s%n",line); + if (line.length() == 0) + { + foundEnd = true; + } + } + + // Read expected handshake hixie bytes + byte hixieHandshakeExpected[] = TypeUtil.fromHexString("c7438d956cf611a6af70603e6fa54809"); + byte hixieHandshake[] = new byte[hixieHandshakeExpected.length]; + + int readLen = in.read(hixieHandshake,0,hixieHandshake.length); + Assert.assertThat("Read hixie handshake bytes",readLen,is(hixieHandshake.length)); + } + + public void sendMessage(String... msgs) throws IOException + { + int len = 0; + for (String msg : msgs) + { + len += (msg.length() + 2); + } + + ByteArrayBuffer buf = new ByteArrayBuffer(len); + + for (String msg : msgs) + { + buf.put((byte)0x00); + buf.put(msg.getBytes("UTF-8")); + buf.put((byte)0xFF); + } + + out.write(buf.array()); + out.flush(); + } + + public void disconnect() throws IOException + { + socket.close(); + } +} diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/WebSocketCaptureServlet.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/WebSocketCaptureServlet.java new file mode 100644 index 00000000000..706c4bd7eb4 --- /dev/null +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/WebSocketCaptureServlet.java @@ -0,0 +1,31 @@ +package org.eclipse.jetty.websocket.helper; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.websocket.WebSocket; +import org.eclipse.jetty.websocket.WebSocketServlet; + +@SuppressWarnings("serial") +public class WebSocketCaptureServlet extends WebSocketServlet +{ + public List captures = new ArrayList();; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + resp.sendError(404); + } + + public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) + { + CaptureSocket capture = new CaptureSocket(); + captures.add(capture); + return capture; + } +} \ No newline at end of file From bc48eb1f5b34ab6f53b6af4efeb7cdd9c0f67093 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 14 Dec 2011 11:41:32 -0800 Subject: [PATCH 18/56] 366730 pass the time idle to onIdleExpire --- .../org/eclipse/jetty/client/HttpDestination.java | 4 +++- .../org/eclipse/jetty/client/SelectConnector.java | 4 ++-- .../org/eclipse/jetty/io/AbstractConnection.java | 4 ++-- .../java/org/eclipse/jetty/io/AsyncEndPoint.java | 3 ++- .../java/org/eclipse/jetty/io/Connection.java | 3 ++- .../jetty/io/nio/SelectChannelEndPoint.java | 15 ++++++++++----- .../org/eclipse/jetty/io/nio/SslConnection.java | 9 +++++---- .../jetty/server/handler/ConnectHandler.java | 4 ++-- .../jetty/websocket/WebSocketConnectionD06.java | 2 +- .../jetty/websocket/WebSocketConnectionD08.java | 5 ++--- .../jetty/websocket/WebSocketConnectionD13.java | 5 ++--- .../jetty/websocket/WebSocketMessageD08Test.java | 14 ++++---------- 12 files changed, 37 insertions(+), 35 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java index 3992a5cef5b..18a197ced6a 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java @@ -439,7 +439,9 @@ public class HttpDestination implements Dumpable public void returnIdleConnection(AbstractHttpConnection connection) { - connection.onIdleExpired(); + // TODO work out the real idle time; + long idleForMs=connection!=null&&connection.getEndPoint()!=null?connection.getEndPoint().getMaxIdleTime():-1; + connection.onIdleExpired(idleForMs); boolean startConnection = false; synchronized (this) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java index efb39f39f82..b3c93a7dee8 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java @@ -437,9 +437,9 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector, _endp.setMaxIdleTime(timeMs); } - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { - _endp.onIdleExpired(); + _endp.onIdleExpired(idleForMs); } public void setCheckForIdle(boolean check) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java index a6004a9e102..a9167eba32e 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java @@ -35,11 +35,11 @@ public abstract class AbstractConnection implements Connection return _endp; } - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { try { - LOG.debug("onIdleExpired {} {}",this,_endp); + LOG.debug("onIdleExpired {}ms {} {}",idleForMs,this,_endp); if (_endp.isInputShutdown() || _endp.isOutputShutdown()) _endp.close(); else diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java index 630fe1133ab..992ad7a195a 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java @@ -35,8 +35,9 @@ public interface AsyncEndPoint extends ConnectedEndPoint /** Callback when idle. *

An endpoint is idle if there has been no IO activity for * {@link #getMaxIdleTime()} and {@link #isCheckForIdle()} is true. + * @param idleForMs TODO */ - public void onIdleExpired(); + public void onIdleExpired(long idleForMs); /* ------------------------------------------------------------ */ /** Set if the endpoint should be checked for idleness diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java index 6519905dae6..19cf3bee60e 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java @@ -54,6 +54,7 @@ public interface Connection /** * Called when the connection idle timeout expires + * @param idleForMs TODO */ - void onIdleExpired(); + void onIdleExpired(long idleForMs); } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index cc698d5e4e7..39cd2205dc3 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -280,17 +280,22 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo public void checkIdleTimestamp(long now) { long idleTimestamp=_idleTimestamp; - if (idleTimestamp!=0 && _maxIdleTime>0 && now>(idleTimestamp+_maxIdleTime)) + + if (idleTimestamp!=0 && _maxIdleTime>0) { - onIdleExpired(); - _idleTimestamp=now; + long idleForMs=now-idleTimestamp; + if (idleForMs>_maxIdleTime) + { + onIdleExpired(idleForMs); + _idleTimestamp=now; + } } } /* ------------------------------------------------------------ */ - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { - _connection.onIdleExpired(); + _connection.onIdleExpired(idleForMs); } /* ------------------------------------------------------------ */ diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index 82d6fbeceb7..d8cee6277f5 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -237,16 +237,17 @@ public class SslConnection extends AbstractConnection implements AsyncConnection /* ------------------------------------------------------------ */ @Override - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { try { + LOG.debug("onIdleExpired {}ms on {}",idleForMs,this); _sslEndPoint.shutdownOutput(); } catch (IOException e) { LOG.warn(e); - super.onIdleExpired(); + super.onIdleExpired(idleForMs); } } @@ -700,9 +701,9 @@ public class SslConnection extends AbstractConnection implements AsyncConnection _aEndp.scheduleWrite(); } - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { - _aEndp.onIdleExpired(); + _aEndp.onIdleExpired(idleForMs); } public void setCheckForIdle(boolean check) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java index b1fb779f5b0..9ddd15bb252 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java @@ -667,7 +667,7 @@ public class ConnectHandler extends HandlerWrapper _endPoint.shutdownOutput(); } - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { try { @@ -834,7 +834,7 @@ public class ConnectHandler extends HandlerWrapper _endPoint.shutdownOutput(); } - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { try { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java index 4ee7947c9b4..b9af801eb59 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java @@ -199,7 +199,7 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc /* ------------------------------------------------------------ */ @Override - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { closeOut(WebSocketConnectionD06.CLOSE_NORMAL,"Idle"); } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java index 9839a554a3e..69e6ed3e0f2 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java @@ -246,10 +246,9 @@ public class WebSocketConnectionD08 extends AbstractConnection implements WebSoc /* ------------------------------------------------------------ */ @Override - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { - long idle = System.currentTimeMillis()-((SelectChannelEndPoint)_endp).getIdleTimestamp(); - closeOut(WebSocketConnectionD08.CLOSE_NORMAL,"Idle for "+idle+"ms > "+_endp.getMaxIdleTime()+"ms"); + closeOut(WebSocketConnectionD08.CLOSE_NORMAL,"Idle for "+idleForMs+"ms > "+_endp.getMaxIdleTime()+"ms"); } /* ------------------------------------------------------------ */ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java index 7525ff14462..8dde654f892 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java @@ -274,10 +274,9 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc /* ------------------------------------------------------------ */ @Override - public void onIdleExpired() + public void onIdleExpired(long idleForMs) { - long idle = System.currentTimeMillis()-((SelectChannelEndPoint)_endp).getIdleTimestamp(); - closeOut(WebSocketConnectionD13.CLOSE_NORMAL,"Idle for "+idle+"ms > "+_endp.getMaxIdleTime()+"ms"); + closeOut(WebSocketConnectionD13.CLOSE_NORMAL,"Idle for "+idleForMs+"ms > "+_endp.getMaxIdleTime()+"ms"); } /* ------------------------------------------------------------ */ diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java index ee321cd032f..f1bd18c012b 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java @@ -569,29 +569,23 @@ public class WebSocketMessageD08Test // Send enough messages to fill receive buffer - long max=0; long start=System.currentTimeMillis(); String mesg="How Now Brown Cow"; for (int i=0;i1000); // was blocked + // if (duration<1500) + System.err.println("max="+duration); + assertTrue(duration>1500); // was blocked } @Test From 300157fb2d4c8b5ea80afca3ec6c13e0ae950956 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 14 Dec 2011 12:01:23 -0800 Subject: [PATCH 19/56] more time needed for ssl test on slow machine --- .../java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java index a9e07a0b60d..fd73e6b43ff 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java @@ -175,7 +175,7 @@ public class WebSocketOverSSLTest for (int i = 0; i < count; ++i) _connection.sendMessage(message); - Assert.assertTrue(clientLatch.await(5, TimeUnit.SECONDS)); + Assert.assertTrue(clientLatch.await(20, TimeUnit.SECONDS)); // While messages may have all arrived, the SSL close alert // may be in the way so give some time for it to be processed. From e515b5b7dccfb1cb24e4fbc288043dd5e4b748dc Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 15 Dec 2011 20:19:04 +1100 Subject: [PATCH 20/56] JETTY-1460 suppress PrintWriter exceptions --- .../jetty/io/UncheckedPrintWriter.java | 63 +++++++++++-------- .../jetty/server/AbstractHttpConnection.java | 22 ++++++- .../java/org/eclipse/jetty/server/Server.java | 15 +++++ .../jetty/server/HttpServerTestBase.java | 1 + .../server/handler/ContextHandlerTest.java | 6 +- 5 files changed, 78 insertions(+), 29 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/UncheckedPrintWriter.java b/jetty-io/src/main/java/org/eclipse/jetty/io/UncheckedPrintWriter.java index f114417e800..cfb05447a29 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/UncheckedPrintWriter.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/UncheckedPrintWriter.java @@ -35,7 +35,8 @@ public class UncheckedPrintWriter extends PrintWriter private static final Logger LOG = Log.getLogger(UncheckedPrintWriter.class); private boolean _autoFlush = false; - private boolean _throwUnchecked=true; + private IOException _ioException; + private boolean _isClosed = false; /* ------------------------------------------------------------ */ /** @@ -102,38 +103,45 @@ public class UncheckedPrintWriter extends PrintWriter this(new BufferedWriter(new OutputStreamWriter(out)),autoFlush); } + /* ------------------------------------------------------------ */ - private void setError(Throwable th) + public boolean checkError() { - setError(); - if (_throwUnchecked) - throw new RuntimeIOException(th); - LOG.debug(th); - } - - /* ------------------------------------------------------------ */ - /** Are unchecked exceptions thrown. - * @return True if {@link RuntimeIOException}s are thrown - */ - public boolean isUncheckedPrintWriter() - { - return _throwUnchecked; - } - - /* ------------------------------------------------------------ */ - /** Set if unchecked exceptions are thrown - * @param uncheckedPrintWriter True if {@link RuntimeIOException}s are to be thrown - */ - public void setUncheckedPrintWriter(boolean uncheckedPrintWriter) - { - _throwUnchecked = uncheckedPrintWriter; + return _ioException!=null || super.checkError(); } + /* ------------------------------------------------------------ */ + private void setError(Throwable th) + { + + super.setError(); + + if (th instanceof IOException) + _ioException=(IOException)th; + else + { + _ioException=new IOException(String.valueOf(th)); + _ioException.initCause(th); + } + + LOG.debug(th); + } + + + @Override + protected void setError() + { + setError(new IOException()); + } + /* ------------------------------------------------------------ */ /** Check to make sure that the stream has not been closed */ private void isOpen() throws IOException - { - if (super.out == null) + { + if (_ioException!=null) + throw new RuntimeIOException(_ioException); + + if (_isClosed) throw new IOException("Stream closed"); } @@ -170,6 +178,7 @@ public class UncheckedPrintWriter extends PrintWriter synchronized (lock) { out.close(); + _isClosed = true; } } catch (IOException ex) @@ -248,7 +257,7 @@ public class UncheckedPrintWriter extends PrintWriter */ @Override public void write(char buf[]) - { + { this.write(buf,0,buf.length); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java index b589d22278b..6869768901f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java @@ -356,7 +356,27 @@ public abstract class AbstractHttpConnection extends AbstractConnection if (_writer==null) { _writer=new OutputWriter(); - _printWriter=new UncheckedPrintWriter(_writer); + if (_server.isUncheckedPrintWriter()) + _printWriter=new UncheckedPrintWriter(_writer); + else + _printWriter = new PrintWriter(_writer) + { + public void close() + { + synchronized (lock) + { + try + { + out.close(); + } + catch (IOException e) + { + setError(); + } + } + } + }; + } _writer.setCharacterEncoding(encoding); return _printWriter; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java index e62fad56c79..98221fc2a65 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java @@ -76,6 +76,7 @@ public class Server extends HandlerWrapper implements Attributes private int _maxCookieVersion=1; private boolean _dumpAfterStart=false; private boolean _dumpBeforeStop=false; + private boolean _uncheckedPrintWriter=false; /* ------------------------------------------------------------ */ @@ -614,6 +615,20 @@ public class Server extends HandlerWrapper implements Attributes dumpThis(out); dump(out,indent,TypeUtil.asList(getHandlers()),getBeans(),TypeUtil.asList(_connectors)); } + + + /* ------------------------------------------------------------ */ + public boolean isUncheckedPrintWriter() + { + return _uncheckedPrintWriter; + } + + /* ------------------------------------------------------------ */ + public void setUncheckedPrintWriter(boolean unchecked) + { + _uncheckedPrintWriter=unchecked; + } + /* ------------------------------------------------------------ */ /* A handler that can be gracefully shutdown. diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java index 0e6d953c275..661fcde9a65 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java @@ -741,6 +741,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture IO.copy(is,bout); byte[] b=bout.toByteArray(); + System.err.println("OUTPUT: "+new String(b)); int i=0; while (b[i]!='Z') i++; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java index 6b1dcfa28cb..5612d35c9f3 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java @@ -337,6 +337,7 @@ public class ContextHandlerTest public void testUncheckedPrintWriter() throws Exception { Server server = new Server(); + server.setUncheckedPrintWriter(true); LocalConnector connector = new LocalConnector(); server.setConnectors(new Connector[] { connector }); ContextHandler context = new ContextHandler("/"); @@ -422,7 +423,10 @@ public class ContextHandlerTest writer.write("Goodbye cruel world\n"); writer.close(); response.flushBuffer(); - writer.write("speaking from the dead"); + //writer.write("speaking from the dead"); + writer.write("give the printwriter a chance"); //should create an error + if (writer.checkError()) + writer.write("didn't take the chance, will throw now"); //write after an error } catch(Throwable th) { From 5774c03e09d8e8f853d3ead8c2166da98578dc04 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 15 Dec 2011 11:07:27 -0700 Subject: [PATCH 21/56] Refactoring protected fields back to private with protected methods per discussion with Simone --- .../websocket/WebSocketConnectionD00.java | 27 ++++++++++++++----- .../websocket/WebSocketConnectionD06.java | 22 ++++++++++----- .../websocket/WebSocketConnectionD08.java | 24 ++++++++++++----- .../websocket/WebSocketConnectionD13.java | 24 ++++++++++++----- .../WebSocketServletConnectionD00.java | 9 +++---- .../WebSocketServletConnectionD06.java | 7 ++--- .../WebSocketServletConnectionD08.java | 9 +++---- .../WebSocketServletConnectionD13.java | 10 +++---- 8 files changed, 81 insertions(+), 51 deletions(-) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java index cd7ecec8782..3f550ddd8be 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java @@ -38,13 +38,13 @@ public class WebSocketConnectionD00 extends AbstractConnection implements WebSoc public final static byte LENGTH_FRAME=(byte)0x80; public final static byte SENTINEL_FRAME=(byte)0x00; - final WebSocketParser _parser; - final WebSocketGenerator _generator; - final WebSocket _websocket; - final String _protocol; - String _key1; - String _key2; - ByteArrayBuffer _hixieBytes; + private final WebSocketParser _parser; + private final WebSocketGenerator _generator; + private final WebSocket _websocket; + private final String _protocol; + private String _key1; + private String _key2; + private ByteArrayBuffer _hixieBytes; public WebSocketConnectionD00(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol) throws IOException @@ -374,6 +374,19 @@ public class WebSocketConnectionD00 extends AbstractConnection implements WebSoc { return _protocol; } + + protected void onFrameHandshake() + { + if (_websocket instanceof OnFrame) + { + ((OnFrame)_websocket).onHandshake(this); + } + } + + protected void onWebsocketOpen() + { + _websocket.onOpen(this); + } static class FrameHandlerD00 implements WebSocketParser.FrameHandler { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java index 96c3415dd5a..da34dd17309 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java @@ -70,12 +70,11 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc } } - private final static byte[] MAGIC; private final WebSocketParser _parser; private final WebSocketGenerator _generator; - protected final WebSocket _webSocket; - protected final OnFrame _onFrame; + private final WebSocket _webSocket; + private final OnFrame _onFrame; private final OnBinaryMessage _onBinaryMessage; private final OnTextMessage _onTextMessage; private final OnControl _onControl; @@ -98,7 +97,7 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc } private final WebSocketParser.FrameHandler _frameHandler= new FrameHandlerD06(); - protected final WebSocket.FrameConnection _connection = new FrameConnectionD06(); + private final WebSocket.FrameConnection _connection = new FrameConnectionD06(); /* ------------------------------------------------------------ */ @@ -280,9 +279,20 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc { return Collections.emptyList(); } + + protected void onFrameHandshake() + { + if (_onFrame!=null) + { + _onFrame.onHandshake(_connection); + } + } + + protected void onWebSocketOpen() + { + _webSocket.onOpen(_connection); + } - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ private class FrameConnectionD06 implements WebSocket.FrameConnection { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java index bbdb76a3123..e66cc83f8e2 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java @@ -25,7 +25,6 @@ import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; -import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.util.B64Code; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.Utf8StringBuilder; @@ -74,13 +73,13 @@ public class WebSocketConnectionD08 extends AbstractConnection implements WebSoc } private final static byte[] MAGIC; - protected final List _extensions; + private final List _extensions; private final WebSocketParserD08 _parser; private final WebSocketParser.FrameHandler _inbound; private final WebSocketGeneratorD08 _generator; private final WebSocketGenerator _outbound; - protected final WebSocket _webSocket; - protected final OnFrame _onFrame; + private final WebSocket _webSocket; + private final OnFrame _onFrame; private final OnBinaryMessage _onBinaryMessage; private final OnTextMessage _onTextMessage; private final OnControl _onControl; @@ -107,7 +106,7 @@ public class WebSocketConnectionD08 extends AbstractConnection implements WebSoc } private final WebSocketParser.FrameHandler _frameHandler= new WSFrameHandler(); - protected final WebSocket.FrameConnection _connection = new WSFrameConnection(); + private final WebSocket.FrameConnection _connection = new WSFrameConnection(); /* ------------------------------------------------------------ */ @@ -370,9 +369,20 @@ public class WebSocketConnectionD08 extends AbstractConnection implements WebSoc ((AsyncEndPoint)_endp).scheduleWrite(); } } + + protected void onFrameHandshake() + { + if (_onFrame != null) + { + _onFrame.onHandshake(_connection); + } + } + + protected void onWebSocketOpen() + { + _webSocket.onOpen(_connection); + } - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ private class WSFrameConnection implements WebSocket.FrameConnection { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java index c91c8376a13..cbf5910f6ab 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java @@ -25,7 +25,6 @@ import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; -import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.util.B64Code; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.Utf8Appendable; @@ -103,12 +102,12 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc } private final static byte[] MAGIC; - protected final List _extensions; + private final List _extensions; private final WebSocketParserD13 _parser; private final WebSocketGeneratorD13 _generator; private final WebSocketGenerator _outbound; - protected final WebSocket _webSocket; - protected final OnFrame _onFrame; + private final WebSocket _webSocket; + private final OnFrame _onFrame; private final OnBinaryMessage _onBinaryMessage; private final OnTextMessage _onTextMessage; private final OnControl _onControl; @@ -134,7 +133,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc } } - protected final WebSocket.FrameConnection _connection = new WSFrameConnection(); + private final WebSocket.FrameConnection _connection = new WSFrameConnection(); /* ------------------------------------------------------------ */ @@ -393,9 +392,20 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc ((AsyncEndPoint)_endp).scheduleWrite(); } } + + protected void onFrameHandshake() + { + if (_onFrame != null) + { + _onFrame.onHandshake(_connection); + } + } + + protected void onWebSocketOpen() + { + _webSocket.onOpen(_connection); + } - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ private class WSFrameConnection implements WebSocket.FrameConnection { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java index 3b9514e2696..f5b9ef4bb68 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java @@ -8,7 +8,6 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.QuotedStringTokenizer; -import org.eclipse.jetty.websocket.WebSocket.OnFrame; public class WebSocketServletConnectionD00 extends WebSocketConnectionD00 implements WebSocketServletConnection { @@ -71,11 +70,9 @@ public class WebSocketServletConnectionD00 extends WebSocketConnectionD00 implem } response.sendError(101,"Web Socket Protocol Handshake"); response.flushBuffer(); - if (_websocket instanceof OnFrame) - { - ((OnFrame)_websocket).onHandshake(this); - } - _websocket.onOpen(this); + + onFrameHandshake(); + onWebsocketOpen(); } } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java index 74b71ccea11..b28caa01b43 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java @@ -30,10 +30,7 @@ public class WebSocketServletConnectionD06 extends WebSocketConnectionD06 implem response.sendError(101); - if (_onFrame!=null) - { - _onFrame.onHandshake(_connection); - } - _webSocket.onOpen(_connection); + onFrameHandshake(); + onWebSocketOpen(); } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java index bac9be7f0da..e96f7d4c27b 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java @@ -35,17 +35,14 @@ public class WebSocketServletConnectionD08 extends WebSocketConnectionD08 implem response.addHeader("Sec-WebSocket-Protocol",subprotocol); } - for (Extension ext : _extensions) + for (Extension ext : getExtensions()) { response.addHeader("Sec-WebSocket-Extensions",ext.getParameterizedName()); } response.sendError(101); - if (_onFrame != null) - { - _onFrame.onHandshake(_connection); - } - _webSocket.onOpen(_connection); + onFrameHandshake(); + onWebSocketOpen(); } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java index a55a113b367..b2a7532fa6c 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java @@ -35,18 +35,14 @@ public class WebSocketServletConnectionD13 extends WebSocketConnectionD13 implem response.addHeader("Sec-WebSocket-Protocol",subprotocol); } - for (Extension ext : _extensions) + for (Extension ext : getExtensions()) { response.addHeader("Sec-WebSocket-Extensions",ext.getParameterizedName()); } response.sendError(101); - if (_onFrame != null) - { - _onFrame.onHandshake(_connection); - } - - _webSocket.onOpen(_connection); + onFrameHandshake(); + onWebSocketOpen(); } } From 2b626be18698afbcc38749b1d2437d11d26a46b5 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 15 Dec 2011 16:04:07 -0700 Subject: [PATCH 22/56] Minor fixes for Windows build isues --- .../handler/AbstractConnectHandlerTest.java | 19 +++++++++--- .../servlets/GzipFilterContentLengthTest.java | 29 +++++++++---------- .../jetty/servlets/gzip/GzipTester.java | 26 +++++++++++------ 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/AbstractConnectHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/AbstractConnectHandlerTest.java index 18ad49b3521..54e9bf658a5 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/AbstractConnectHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/AbstractConnectHandlerTest.java @@ -7,6 +7,7 @@ import java.io.BufferedReader; import java.io.EOFException; import java.io.IOException; import java.net.Socket; +import java.net.SocketTimeoutException; import java.util.LinkedHashMap; import java.util.Map; import java.util.regex.Matcher; @@ -91,11 +92,21 @@ public abstract class AbstractConnectHandlerTest StringBuilder body = new StringBuilder(); if (headers.containsKey("content-length")) { + int readLen = 0; int length = Integer.parseInt(headers.get("content-length")); - for (int i = 0; i < length; ++i) + try { - char c = (char)reader.read(); - body.append(c); + for (int i = 0; i < length; ++i) + { + char c = (char)reader.read(); + body.append(c); + readLen++; + } + } + catch (SocketTimeoutException e) + { + System.err.printf("Read %,d bytes (out of an expected %,d bytes)%n",readLen,length); + throw e; } } else if ("chunked".equals(headers.get("transfer-encoding"))) @@ -126,7 +137,7 @@ public abstract class AbstractConnectHandlerTest protected Socket newSocket() throws IOException { Socket socket = new Socket("localhost", proxyConnector.getLocalPort()); - socket.setSoTimeout(5000); + socket.setSoTimeout(10000); return socket; } diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterContentLengthTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterContentLengthTest.java index 7d1304ad110..5478bb71681 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterContentLengthTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterContentLengthTest.java @@ -1,5 +1,6 @@ package org.eclipse.jetty.servlets; +import java.io.File; import java.util.Arrays; import java.util.List; @@ -7,7 +8,6 @@ import javax.servlet.Servlet; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.gzip.GzipResponseWrapper; -import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlets.gzip.GzipTester; import org.eclipse.jetty.servlets.gzip.TestServletLengthStreamTypeWrite; @@ -49,7 +49,6 @@ public class GzipFilterContentLengthTest { return Arrays.asList(new Object[][] { - { DefaultServlet.class }, { TestServletLengthStreamTypeWrite.class }, { TestServletLengthTypeStreamWrite.class }, { TestServletStreamLengthTypeWrite.class }, @@ -76,8 +75,8 @@ public class GzipFilterContentLengthTest private void assertIsGzipCompressed(String filename, int filesize) throws Exception { GzipTester tester = new GzipTester(testingdir); - - tester.prepareServerFile(filename,filesize); + + File testfile = tester.prepareServerFile(testServlet.getSimpleName() + "-" + filename,filesize); FilterHolder holder = tester.setContentServlet(testServlet); holder.setInitParameter("mimeTypes","text/plain"); @@ -85,7 +84,7 @@ public class GzipFilterContentLengthTest try { tester.start(); - tester.assertIsResponseGzipCompressed(filename); + tester.assertIsResponseGzipCompressed(testfile.getName()); } finally { @@ -97,7 +96,7 @@ public class GzipFilterContentLengthTest { GzipTester tester = new GzipTester(testingdir); - tester.prepareServerFile(filename,filesize); + File testfile = tester.prepareServerFile(testServlet.getSimpleName() + "-" + filename,filesize); FilterHolder holder = tester.setContentServlet(testServlet); holder.setInitParameter("mimeTypes","text/plain"); @@ -105,21 +104,21 @@ public class GzipFilterContentLengthTest try { tester.start(); - tester.assertIsResponseNotGzipCompressed(filename,filesize,HttpStatus.OK_200); + tester.assertIsResponseNotGzipCompressed(testfile.getName(),filesize,HttpStatus.OK_200); } finally { tester.stop(); } } - + /** * Tests gzip compression of a small size file */ @Test public void testIsGzipCompressedSmall() throws Exception { - assertIsGzipCompressed("file.txt",SMALL); + assertIsGzipCompressed("file-small.txt",SMALL); } /** @@ -128,7 +127,7 @@ public class GzipFilterContentLengthTest @Test public void testIsGzipCompressedMedium() throws Exception { - assertIsGzipCompressed("file.txt",MEDIUM); + assertIsGzipCompressed("file-med.txt",MEDIUM); } /** @@ -137,7 +136,7 @@ public class GzipFilterContentLengthTest @Test public void testIsGzipCompressedLarge() throws Exception { - assertIsGzipCompressed("file.txt",LARGE); + assertIsGzipCompressed("file-large.txt",LARGE); } /** @@ -149,7 +148,7 @@ public class GzipFilterContentLengthTest @Test public void testIsNotGzipCompressedTiny() throws Exception { - assertIsNotGzipCompressed("file.txt",TINY); + assertIsNotGzipCompressed("file-tiny.txt",TINY); } /** @@ -161,7 +160,7 @@ public class GzipFilterContentLengthTest @Test public void testIsNotGzipCompressedSmall() throws Exception { - assertIsNotGzipCompressed("file.mp3",SMALL); + assertIsNotGzipCompressed("file-small.mp3",SMALL); } /** @@ -173,7 +172,7 @@ public class GzipFilterContentLengthTest @Test public void testIsNotGzipCompressedMedium() throws Exception { - assertIsNotGzipCompressed("file.mp3",MEDIUM); + assertIsNotGzipCompressed("file-medium.mp3",MEDIUM); } /** @@ -185,6 +184,6 @@ public class GzipFilterContentLengthTest @Test public void testIsNotGzipCompressedLarge() throws Exception { - assertIsNotGzipCompressed("file.mp3",LARGE); + assertIsNotGzipCompressed("file-large.mp3",LARGE); } } diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java index 2c72e5eb6ed..72ddbed690a 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java @@ -1,8 +1,11 @@ package org.eclipse.jetty.servlets.gzip; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; -import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -41,7 +44,7 @@ public class GzipTester { this.testdir = testingdir; // Make sure we start with a clean testing directory. - this.testdir.ensureEmpty(); + // DOES NOT WORK IN WINDOWS - this.testdir.ensureEmpty(); } public void assertIsResponseGzipCompressed(String filename) throws Exception @@ -309,24 +312,29 @@ public class GzipTester * @param filesize * the file size to create (Note: this isn't suitable for creating large multi-megabyte files) */ - public void prepareServerFile(String filename, int filesize) throws IOException + public File prepareServerFile(String filename, int filesize) throws IOException { - File testFile = testdir.getFile(filename); + File dir = testdir.getDir(); + File testFile = new File(dir,filename); + // Make sure we have a uniq filename (to work around windows File.delete bug) + int i = 0; + while (testFile.exists()) + { + testFile = new File(dir,(i++) + "-" + filename); + } FileOutputStream fos = null; - BufferedOutputStream out = null; ByteArrayInputStream in = null; try { fos = new FileOutputStream(testFile,false); - out = new BufferedOutputStream(fos); in = new ByteArrayInputStream(generateContent(filesize).getBytes(encoding)); - IO.copy(in,out); + IO.copy(in,fos); + return testFile; } finally { IO.close(in); - IO.close(out); IO.close(fos); } } From a88e2c5ebba7f627a3f9fc61927057855d96a1bb Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 16 Dec 2011 20:53:15 +0100 Subject: [PATCH 23/56] Updated toString() implementations. --- .../jetty/client/AbstractHttpConnection.java | 5 +- .../eclipse/jetty/io/AbstractConnection.java | 8 +-- .../jetty/io/nio/SelectChannelEndPoint.java | 53 +++++++++++++------ .../eclipse/jetty/io/nio/SslConnection.java | 28 +++++----- .../websocket/WebSocketConnectionD08.java | 4 +- .../websocket/WebSocketConnectionD13.java | 6 +-- .../websocket/WebSocketGeneratorD13.java | 15 +++++- .../jetty/websocket/WebSocketParserD13.java | 16 +++--- 8 files changed, 79 insertions(+), 56 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java index 20a5d04aa63..00571cad0b0 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java @@ -355,9 +355,8 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen @Override public String toString() { - return String.format("%s@%x//%s,g=%s,p=%s", - getClass().getSimpleName(), - hashCode(), + return String.format("%s %s g=%s p=%s", + super.toString(), _destination == null ? "?.?.?.?:??" : _destination.getAddress(), _generator, _parser); diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java index a9167eba32e..ef80cccb2ff 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java @@ -62,12 +62,6 @@ public abstract class AbstractConnection implements Connection public String toString() { - return String.format("%s@%x//%s:%d<->%s:%d", - getClass().getSimpleName(), - hashCode(), - _endp.getLocalAddr(), - _endp.getLocalPort(), - _endp.getRemoteAddr(), - _endp.getRemotePort()); + return String.format("%s@%x", getClass().getSimpleName(), hashCode()); } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 39cd2205dc3..58f4cb19c0b 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -280,7 +280,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo public void checkIdleTimestamp(long now) { long idleTimestamp=_idleTimestamp; - + if (idleTimestamp!=0 && _maxIdleTime>0) { long idleForMs=now-idleTimestamp; @@ -709,24 +709,43 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo @Override public String toString() { - synchronized(this) + // Do NOT use synchronized (this) + // because it's very easy to deadlock when debugging is enabled. + // We do a best effort to print the right toString() and that's it. + SelectionKey key = _key; + String keyString = ""; + if (key != null) { - return String.format("SCEP@%x{%s->%s,d=%b,open=%b,ishut=%b,oshut=%b,rb=%b,wb=%b,w=%b,i=%d%s%s%s}", - hashCode(), - _socket.getRemoteSocketAddress(), - _socket.getLocalSocketAddress(), - _dispatched, - isOpen(), - isInputShutdown(), - isOutputShutdown(), - _readBlocked, - _writeBlocked, - _writable, - _interestOps, - _key != null && _key.isValid() ? "" : "!", - _key != null && _key.isValid() && _key.isReadable() ? "r" : "", - _key != null && _key.isValid() && _key.isWritable() ? "w" : ""); + if (key.isValid()) + { + if (key.isReadable()) + keyString += "r"; + if (key.isWritable()) + keyString += "w"; + } + else + { + keyString += "!"; + } } + else + { + keyString += "-"; + } + return String.format("SCEP@%x{l(%s)<->r(%s),d=%b,open=%b,ishut=%b,oshut=%b,rb=%b,wb=%b,w=%b,i=%d%s}-{%s}", + hashCode(), + _socket.getRemoteSocketAddress(), + _socket.getLocalSocketAddress(), + _dispatched, + isOpen(), + isInputShutdown(), + isOutputShutdown(), + _readBlocked, + _writeBlocked, + _writable, + _interestOps, + keyString, + _connection); } /* ------------------------------------------------------------ */ diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index d8cee6277f5..bf59dbe0ab7 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -571,7 +571,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection public String toString() { - return String.format("%s | %s", super.toString(), _sslEndPoint); + return String.format("%s %s", super.toString(), _sslEndPoint); } /* ------------------------------------------------------------ */ @@ -793,20 +793,20 @@ public class SslConnection extends AbstractConnection implements AsyncConnection public String toString() { - int i; - int o; - int u; - synchronized(SslConnection.this) - { - i=_inbound==null?-1:_inbound.length(); - o=_outbound==null?-1:_outbound.length(); - u=_unwrapBuf==null?-1:_unwrapBuf.length(); - } - return String.format("SSL:%s %s i/u/o=%d/%d/%d ishut=%b oshut=%b", - _endp, + // Do NOT use synchronized (SslConnection.this) + // because it's very easy to deadlock when debugging is enabled. + // We do a best effort to print the right toString() and that's it. + Buffer inbound = _inbound; + Buffer outbound = _outbound; + Buffer unwrap = _unwrapBuf; + int i = inbound == null? -1 : inbound.length(); + int o = outbound == null ? -1 : outbound.length(); + int u = unwrap == null ? -1 : unwrap.length(); + return String.format("SSL %s i/o/u=%d/%d/%d ishut=%b oshut=%b {%s}", _engine.getHandshakeStatus(), - i, u, o, - _ishut, _oshut); + i, o, u, + _ishut, _oshut, + _connection); } } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java index 69e6ed3e0f2..5e75d3955c8 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java @@ -18,7 +18,6 @@ import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.util.Collections; import java.util.List; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -28,7 +27,6 @@ import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; -import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.util.B64Code; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.Utf8StringBuilder; @@ -840,6 +838,6 @@ public class WebSocketConnectionD08 extends AbstractConnection implements WebSoc @Override public String toString() { - return "WS/D"+_draft+"-"+_endp; + return String.format("WS/D%d p=%s g=%s", _draft, _parser, _generator); } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java index 8dde654f892..3e755c12f3c 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java @@ -18,7 +18,6 @@ import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.util.Collections; import java.util.List; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -28,7 +27,6 @@ import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; -import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.util.B64Code; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.Utf8Appendable; @@ -916,7 +914,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc return WebSocketConnectionD13.this.toString()+"FH"; } } - + /* ------------------------------------------------------------ */ public void handshake(HttpServletRequest request, HttpServletResponse response, String subprotocol) throws IOException { @@ -958,6 +956,6 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc @Override public String toString() { - return "WS/D"+_draft+"-"+_endp; + return String.format("WS/D%d p=%s g=%s", _draft, _parser, _generator); } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13.java index 0ed3e7c02ac..c6d5f15a15c 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13.java @@ -65,7 +65,7 @@ public class WebSocketGeneratorD13 implements WebSocketGenerator throw new EofException("Closed"); if (opcode==WebSocketConnectionD13.OP_CLOSE) _closed=true; - + boolean mask=_maskGen!=null; if (_buffer==null) @@ -240,4 +240,17 @@ public class WebSocketGeneratorD13 implements WebSocketGenerator } } + @Override + public String toString() + { + // Do NOT use synchronized (this) + // because it's very easy to deadlock when debugging is enabled. + // We do a best effort to print the right toString() and that's it. + Buffer buffer = _buffer; + return String.format("%s@%x closed=%b buffer=%d", + getClass().getSimpleName(), + hashCode(), + _closed, + buffer == null ? -1 : buffer.length()); + } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java index f57c4976f53..0b7028d4818 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java @@ -125,7 +125,7 @@ public class WebSocketParserD13 implements WebSocketParser { if (_buffer==null) _buffer=_buffers.getBuffer(); - + boolean progress=false; int filled=-1; @@ -189,7 +189,7 @@ public class WebSocketParserD13 implements WebSocketParser // Did we get enough? if (available<(_state==State.SKIP?1:_bytesNeeded)) break; - + // if we are here, then we have sufficient bytes to process the current state. // Parse the buffer byte by byte (unless it is STATE_DATA) byte b; @@ -307,7 +307,7 @@ public class WebSocketParserD13 implements WebSocketParser if (_bytesNeeded==0) _state=State.START; break; - + case SEEK_EOF: progress=true; _buffer.skip(available); @@ -349,7 +349,7 @@ public class WebSocketParserD13 implements WebSocketParser break; } } - + return progress?1:filled; } @@ -380,8 +380,10 @@ public class WebSocketParserD13 implements WebSocketParser @Override public String toString() { - Buffer buffer=_buffer; - return WebSocketParserD13.class.getSimpleName()+"@"+ Integer.toHexString(hashCode())+"|"+_state+"|"+(buffer==null?"<>":buffer.toDetailString()); + return String.format("%s@%x state=%s buffer=%s", + getClass().getSimpleName(), + hashCode(), + _state, + _buffer); } - } From ed1ee997b457a0b6ce4f0393d40c37d17bf697d9 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 16 Dec 2011 20:58:18 +0100 Subject: [PATCH 24/56] Fixed missing call to handle() in case of non-dispatched reads. While performing a SSL write triggered by an application thread that is not dispatched by the NIO layer, process() may read and decrypt bytes that will be kept in the _unwrapBuf buffer. However, the application needs to parse these bytes, but parsing is normally performed only from handle() by a thread dispatched by the NIO layer. The fix is to detect if there are unparsed bytes at the end of process(), and if so, call asyncDispatch() to eventually call handle() to parse those bytes. --- .../eclipse/jetty/io/nio/SslConnection.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index bf59dbe0ab7..2ee58ef249a 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -190,9 +190,10 @@ public class SslConnection extends AbstractConnection implements AsyncConnection _connection=next; progress=true; } + // TODO: consider moving here hasProgressed() - it's only used in SSL } - LOG.debug("{} handle {} progress=",_session,this, progress); + LOG.debug("{} handle {} progress={}", _session, this, progress); } } finally @@ -322,13 +323,13 @@ public class SslConnection extends AbstractConnection implements AsyncConnection case NOT_HANDSHAKING: { - // Try wrapping some application data - if (toFlush.hasContent() && _outbound.space()>0 && wrap(toFlush)) - progress=true; - // Try unwrapping some application data if (toFill.space()>0 && _inbound.hasContent() && unwrap(toFill)) progress=true; + + // Try wrapping some application data + if (toFlush.hasContent() && _outbound.space()>0 && wrap(toFlush)) + progress=true; } break; @@ -389,6 +390,9 @@ public class SslConnection extends AbstractConnection implements AsyncConnection some_progress|=progress; } + + if (toFill.hasContent()) + _aEndp.asyncDispatch(); } finally { @@ -628,7 +632,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection public int fill(Buffer buffer) throws IOException { int size=buffer.length(); - process(buffer,null); + process(buffer, null); int filled=buffer.length()-size; @@ -688,7 +692,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection public void flush() throws IOException { - process(null,null); + process(null, null); } public void asyncDispatch() From d52ed502b08fbe87fa79400fb6c26a4103df43fe Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 16 Dec 2011 21:26:37 +0100 Subject: [PATCH 25/56] Sketch of test for idle expiration on SSL. --- .../jetty/client/SslBytesServerTest.java | 56 +++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java index f6b919ed64f..c963b09e9b7 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java @@ -1,8 +1,5 @@ package org.eclipse.jetty.client; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.lessThan; - import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -19,7 +16,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; 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; @@ -48,6 +44,9 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.lessThan; + public class SslBytesServerTest extends SslBytesTest { private final AtomicInteger sslHandles = new AtomicInteger(); @@ -100,6 +99,7 @@ public class SslBytesServerTest extends SslBytesTest }; } }; + connector.setMaxIdleTime(2000); // connector.setPort(5870); connector.setPort(0); @@ -1181,6 +1181,54 @@ public class SslBytesServerTest extends SslBytesTest closeClient(client); } + @Ignore + @Test + public void testServerCloseClientDoesNotClose() throws Exception + { + final SSLSocket client = newClient(); + final OutputStream clientOutput = client.getOutputStream(); + + SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow(); + client.startHandshake(); + Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS)); + + byte[] data = new byte[3 * 1024]; + Arrays.fill(data, (byte)'Y'); + String content = new String(data, "UTF-8"); + automaticProxyFlow = proxy.startAutomaticFlow(); + clientOutput.write(("" + + "POST / HTTP/1.1\r\n" + + "Host: localhost\r\n" + + "Content-Type: text/plain\r\n" + + "Content-Length: " + content.length() + "\r\n" + + "Connection: close\r\n" + + "\r\n" + + content).getBytes("UTF-8")); + clientOutput.flush(); + Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS)); + + BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8")); + String line = reader.readLine(); + Assert.assertNotNull(line); + Assert.assertTrue(line.startsWith("HTTP/1.1 200 ")); + while ((line = reader.readLine()) != null) + { + if (line.trim().length() == 0) + break; + } + + // Check that we did not spin + Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(httpParses.get(), lessThan(50)); + + // TODO: instead of sleeping, we should expect the connection being closed by the idle timeout + // TODO: mechanism; unfortunately this now is not working, and this test fails because the idle + // TODO: timeout will not trigger. + TimeUnit.SECONDS.sleep(100); + + closeClient(client); + } + private void assumeJavaVersionSupportsTLSRenegotiations() { // Due to a security bug, TLS renegotiations were disabled in JDK 1.6.0_19-21 From a5d18d48ad622d7d3ac135435020d2dac116a592 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 16 Dec 2011 14:16:32 -0700 Subject: [PATCH 26/56] Attempting to get a non-ssl version of the timeout bug into a unit test --- .../jetty/client/SslBytesServerTest.java | 6 +- .../org/eclipse/jetty/client/TimeoutTest.java | 172 ++++++++++++++++++ 2 files changed, 175 insertions(+), 3 deletions(-) create mode 100644 jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java index c963b09e9b7..3c65f822e87 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java @@ -1,5 +1,7 @@ package org.eclipse.jetty.client; +import static org.hamcrest.Matchers.*; + import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -16,6 +18,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; 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; @@ -44,9 +47,6 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.lessThan; - public class SslBytesServerTest extends SslBytesTest { private final AtomicInteger sslHandles = new AtomicInteger(); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java new file mode 100644 index 00000000000..64da4de517c --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java @@ -0,0 +1,172 @@ +package org.eclipse.jetty.client; + +import static org.hamcrest.Matchers.*; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.Socket; +import java.nio.channels.SocketChannel; +import java.util.Arrays; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.http.HttpParser; +import org.eclipse.jetty.io.AsyncEndPoint; +import org.eclipse.jetty.io.Buffers; +import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.io.nio.AsyncConnection; +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.handler.AbstractHandler; +import org.eclipse.jetty.server.nio.SelectChannelConnector; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +public class TimeoutTest +{ + private static final Logger logger = Log.getLogger(TimeoutTest.class); + private final AtomicInteger httpParses = new AtomicInteger(); + private ExecutorService threadPool; + private Server server; + private int serverPort; + + @Before + public void init() throws Exception + { + threadPool = Executors.newCachedThreadPool(); + server = new Server(); + + SelectChannelConnector connector = new SelectChannelConnector() + { + @Override + protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endPoint) + { + return new org.eclipse.jetty.server.AsyncHttpConnection(this, endPoint, getServer()) + { + @Override + protected HttpParser newHttpParser(Buffers requestBuffers, EndPoint endPoint, HttpParser.EventHandler requestHandler) + { + return new HttpParser(requestBuffers, endPoint, requestHandler) + { + @Override + public int parseNext() throws IOException + { + System.out.print("."); + httpParses.incrementAndGet(); + return super.parseNext(); + } + }; + } + }; + } + }; + connector.setMaxIdleTime(2000); + +// connector.setPort(5870); + connector.setPort(0); + + server.addConnector(connector); + server.setHandler(new AbstractHandler() + { + public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException + { + request.setHandled(true); + String contentLength = request.getHeader("Content-Length"); + if (contentLength != null) + { + int length = Integer.parseInt(contentLength); + ServletInputStream input = request.getInputStream(); + for (int i = 0; i < length; ++i) + input.read(); + } + } + }); + server.start(); + serverPort = connector.getLocalPort(); + + logger.debug(" => :{}", serverPort); + } + + @After + public void destroy() throws Exception + { + if (server != null) + server.stop(); + if (threadPool != null) + threadPool.shutdownNow(); + } + + private Socket newClient() throws IOException, InterruptedException + { + Socket client = new Socket("localhost", serverPort); + return client; + } + + @Test + @Ignore + public void testServerCloseClientDoesNotClose() throws Exception + { + final Socket client = newClient(); + final OutputStream clientOutput = client.getOutputStream(); + + byte[] data = new byte[3 * 1024]; + Arrays.fill(data, (byte)'Y'); + String content = new String(data, "UTF-8"); + clientOutput.write(("" + + "POST / HTTP/1.1\r\n" + + "Host: localhost\r\n" + + "Content-Type: text/plain\r\n" + + "Content-Length: " + content.length() + "\r\n" + + "Connection: close\r\n" + + "\r\n" + + content).getBytes("UTF-8")); + clientOutput.flush(); + + System.out.println("Client output flushed"); + + BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8")); + String line = reader.readLine(); + Assert.assertNotNull(line); + Assert.assertThat(line,startsWith("HTTP/1.1 200 ")); + while ((line = reader.readLine()) != null) + { + if (line.trim().length() == 0) + { + break; + } + } + + System.out.println("Got response header"); + + // Check that we did not spin + int httpParseCount = httpParses.get(); + System.out.printf("Got %d http parses%n", httpParseCount); + Assert.assertThat(httpParseCount, lessThan(50)); + + // TODO: instead of sleeping, we should expect the connection being closed by the idle timeout + // TODO: mechanism; unfortunately this now is not working, and this test fails because the idle + // TODO: timeout will not trigger. + TimeUnit.SECONDS.sleep(100); + + closeClient(client); + } + + private void closeClient(Socket client) throws IOException + { + client.close(); + } +} From 44de94f1852aa35cf98b24dc625ab6a608c13e95 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 16 Dec 2011 14:45:38 -0700 Subject: [PATCH 27/56] Attempting to write a better timeout test --- .../org/eclipse/jetty/client/TimeoutTest.java | 128 ++++++++++++------ 1 file changed, 84 insertions(+), 44 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java index 64da4de517c..230cc1b62ca 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java @@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.*; import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.Socket; @@ -28,6 +29,7 @@ import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.nio.SelectChannelConnector; +import org.eclipse.jetty.toolchain.test.IO; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.junit.After; @@ -43,7 +45,7 @@ public class TimeoutTest private ExecutorService threadPool; private Server server; private int serverPort; - + @Before public void init() throws Exception { @@ -53,14 +55,14 @@ public class TimeoutTest SelectChannelConnector connector = new SelectChannelConnector() { @Override - protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endPoint) + protected AsyncConnection newConnection(SocketChannel channel, final AsyncEndPoint endPoint) { - return new org.eclipse.jetty.server.AsyncHttpConnection(this, endPoint, getServer()) + return new org.eclipse.jetty.server.AsyncHttpConnection(this,endPoint,getServer()) { @Override protected HttpParser newHttpParser(Buffers requestBuffers, EndPoint endPoint, HttpParser.EventHandler requestHandler) { - return new HttpParser(requestBuffers, endPoint, requestHandler) + return new HttpParser(requestBuffers,endPoint,requestHandler) { @Override public int parseNext() throws IOException @@ -76,13 +78,14 @@ public class TimeoutTest }; connector.setMaxIdleTime(2000); -// connector.setPort(5870); + // connector.setPort(5870); connector.setPort(0); server.addConnector(connector); server.setHandler(new AbstractHandler() { - public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException + public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, + ServletException { request.setHandled(true); String contentLength = request.getHeader("Content-Length"); @@ -98,7 +101,7 @@ public class TimeoutTest server.start(); serverPort = connector.getLocalPort(); - logger.debug(" => :{}", serverPort); + logger.debug(" => :{}",serverPort); } @After @@ -112,59 +115,96 @@ public class TimeoutTest private Socket newClient() throws IOException, InterruptedException { - Socket client = new Socket("localhost", serverPort); + Socket client = new Socket("localhost",serverPort); return client; } - - @Test + + /** + * Test that performs a seemingly normal http POST request, but with + * a client that issues "connection: close", waits 100 seconds to + * do anything with the connection (at all), and then attempts to + * write a second POST request. + *

+ * The connection should be closed by the server, and/or be closed + * due to a timeout on the socket. + */ @Ignore + @Test public void testServerCloseClientDoesNotClose() throws Exception { + // Log.getLogger("").setDebugEnabled(true); final Socket client = newClient(); final OutputStream clientOutput = client.getOutputStream(); byte[] data = new byte[3 * 1024]; - Arrays.fill(data, (byte)'Y'); - String content = new String(data, "UTF-8"); - clientOutput.write(("" + - "POST / HTTP/1.1\r\n" + - "Host: localhost\r\n" + - "Content-Type: text/plain\r\n" + - "Content-Length: " + content.length() + "\r\n" + - "Connection: close\r\n" + - "\r\n" + - content).getBytes("UTF-8")); + Arrays.fill(data,(byte)'Y'); + String content = new String(data,"UTF-8"); + + // The request section + StringBuilder req = new StringBuilder(); + req.append("POST / HTTP/1.1\r\n"); + req.append("Host: localhost\r\n"); + req.append("Content-Type: text/plain\r\n"); + req.append("Content-Length: ").append(content.length()).append("\r\n"); + req.append("Connection: close\r\n"); + req.append("\r\n"); + // and now, the POST content section. + req.append(content); + + // Send request to server + clientOutput.write(req.toString().getBytes("UTF-8")); clientOutput.flush(); - - System.out.println("Client output flushed"); - BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8")); - String line = reader.readLine(); - Assert.assertNotNull(line); - Assert.assertThat(line,startsWith("HTTP/1.1 200 ")); - while ((line = reader.readLine()) != null) + System.out.println("Client request #1 flushed"); + + InputStream in = null; + InputStreamReader isr = null; + BufferedReader reader = null; + try { - if (line.trim().length() == 0) + in = client.getInputStream(); + isr = new InputStreamReader(in); + reader = new BufferedReader(isr); + + // Read the response header + String line = reader.readLine(); + Assert.assertNotNull(line); + Assert.assertThat(line,startsWith("HTTP/1.1 200 ")); + while ((line = reader.readLine()) != null) { - break; + if (line.trim().length() == 0) + { + break; + } } + + System.out.println("Got response header"); + + // Check that we did not spin + int httpParseCount = httpParses.get(); + System.out.printf("Got %d http parses%n",httpParseCount); + Assert.assertThat(httpParseCount,lessThan(50)); + + // TODO: instead of sleeping, we should expect the connection being closed by the idle timeout + // TODO: mechanism; unfortunately this now is not working, and this test fails because the idle + // TODO: timeout will not trigger. + TimeUnit.SECONDS.sleep(100); + + // Try to write another request (to prove that stream is closed) + clientOutput.write(req.toString().getBytes("UTF-8")); + clientOutput.flush(); + + Assert.fail("Should not have been able to send a second POST request (connection: close)"); + } + finally + { + IO.close(reader); + IO.close(isr); + IO.close(in); + closeClient(client); } - - System.out.println("Got response header"); - - // Check that we did not spin - int httpParseCount = httpParses.get(); - System.out.printf("Got %d http parses%n", httpParseCount); - Assert.assertThat(httpParseCount, lessThan(50)); - - // TODO: instead of sleeping, we should expect the connection being closed by the idle timeout - // TODO: mechanism; unfortunately this now is not working, and this test fails because the idle - // TODO: timeout will not trigger. - TimeUnit.SECONDS.sleep(100); - - closeClient(client); } - + private void closeClient(Socket client) throws IOException { client.close(); From f767d8d91056b15a0903d4529d8851288d3009ce Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 19 Dec 2011 15:15:00 +1100 Subject: [PATCH 28/56] 367048 improved handleRequest guard for suspended requests --- .../jetty/server/AsyncContinuation.java | 19 +++++++++++++++++++ .../jetty/server/AsyncHttpConnection.java | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java index 25e94d976ce..f9846745e69 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java @@ -203,6 +203,25 @@ public class AsyncContinuation implements AsyncContext, Continuation } } } + + /* ------------------------------------------------------------ */ + public boolean isDispatchable() + { + synchronized(this) + { + switch(_state) + { + case __REDISPATCH: + case __REDISPATCHED: + case __REDISPATCHING: + case __COMPLETING: + return true; + + default: + return false; + } + } + } /* ------------------------------------------------------------ */ @Override diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java index 9d79c6cd78f..7546302e697 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java @@ -62,8 +62,11 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async try { // Handle resumed request - if (_request._async.isAsync() && !_request._async.isComplete()) - handleRequest(); + if (_request._async.isAsync()) + { + if ( _request._async.isDispatchable()) + handleRequest(); + } // else Parse more input else if (!_parser.isComplete() && _parser.parseAvailable()) progress=true; From b027779830777080ab91fea7b325024b0b7a2aa4 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 19 Dec 2011 16:53:14 +1100 Subject: [PATCH 29/56] 364638 check for idle after shutdown output --- .../org/eclipse/jetty/client/TimeoutTest.java | 230 ++++++++++++++++-- .../org/eclipse/jetty/http/HttpParser.java | 9 +- .../jetty/io/nio/SelectChannelEndPoint.java | 11 +- 3 files changed, 228 insertions(+), 22 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java index 230cc1b62ca..1d9000af00e 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java @@ -8,12 +8,14 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.Socket; +import java.net.SocketException; import java.nio.channels.SocketChannel; import java.util.Arrays; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; @@ -42,9 +44,11 @@ public class TimeoutTest { private static final Logger logger = Log.getLogger(TimeoutTest.class); private final AtomicInteger httpParses = new AtomicInteger(); + private final AtomicInteger httpRequests = new AtomicInteger(); private ExecutorService threadPool; private Server server; private int serverPort; + private final AtomicReference serverEndPoint = new AtomicReference(); @Before public void init() throws Exception @@ -57,6 +61,7 @@ public class TimeoutTest @Override protected AsyncConnection newConnection(SocketChannel channel, final AsyncEndPoint endPoint) { + serverEndPoint.set(endPoint); return new org.eclipse.jetty.server.AsyncHttpConnection(this,endPoint,getServer()) { @Override @@ -67,7 +72,6 @@ public class TimeoutTest @Override public int parseNext() throws IOException { - System.out.print("."); httpParses.incrementAndGet(); return super.parseNext(); } @@ -87,6 +91,7 @@ public class TimeoutTest public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException { + httpRequests.incrementAndGet(); request.setHandled(true); String contentLength = request.getHeader("Content-Length"); if (contentLength != null) @@ -101,6 +106,7 @@ public class TimeoutTest server.start(); serverPort = connector.getLocalPort(); + httpRequests.set(0); logger.debug(" => :{}",serverPort); } @@ -119,16 +125,197 @@ public class TimeoutTest return client; } + /** + * Test that performs a normal http POST request, with connection:close. + * Check that shutdownOutput is sufficient to close the server connection. + */ + @Test + public void testServerCloseClientDoesClose() throws Exception + { + // Log.getLogger("").setDebugEnabled(true); + final Socket client = newClient(); + final OutputStream clientOutput = client.getOutputStream(); + + byte[] data = new byte[3 * 1024]; + Arrays.fill(data,(byte)'Y'); + String content = new String(data,"UTF-8"); + + // The request section + StringBuilder req = new StringBuilder(); + req.append("POST / HTTP/1.1\r\n"); + req.append("Host: localhost\r\n"); + req.append("Content-Type: text/plain\r\n"); + req.append("Content-Length: ").append(content.length()).append("\r\n"); + req.append("Connection: close\r\n"); + req.append("\r\n"); + // and now, the POST content section. + req.append(content); + + // Send request to server + clientOutput.write(req.toString().getBytes("UTF-8")); + clientOutput.flush(); + + InputStream in = null; + InputStreamReader isr = null; + BufferedReader reader = null; + try + { + in = client.getInputStream(); + isr = new InputStreamReader(in); + reader = new BufferedReader(isr); + + // Read the response header + String line = reader.readLine(); + Assert.assertNotNull(line); + Assert.assertThat(line,startsWith("HTTP/1.1 200 ")); + while ((line = reader.readLine()) != null) + { + if (line.trim().length() == 0) + { + break; + } + } + Assert.assertEquals("one request handled",1,httpRequests.get()); + + Assert.assertEquals("EOF received",-1,client.getInputStream().read()); + + // shutdown the output + client.shutdownOutput(); + + // Check that we did not spin + int httpParseCount = httpParses.get(); + Assert.assertThat(httpParseCount,lessThan(50)); + + // Try to write another request (to prove that stream is closed) + try + { + clientOutput.write(req.toString().getBytes("UTF-8")); + clientOutput.flush(); + + Assert.fail("Should not have been able to send a second POST request (connection: close)"); + } + catch(SocketException e) + { + } + + Assert.assertEquals("one request handled",1,httpRequests.get()); + } + finally + { + IO.close(reader); + IO.close(isr); + IO.close(in); + closeClient(client); + } + } + /** * Test that performs a seemingly normal http POST request, but with - * a client that issues "connection: close", waits 100 seconds to - * do anything with the connection (at all), and then attempts to + * a client that issues "connection: close", and then attempts to * write a second POST request. *

- * The connection should be closed by the server, and/or be closed - * due to a timeout on the socket. + * The connection should be closed by the server + */ + @Test + public void testServerCloseClientMoreDataSent() throws Exception + { + // Log.getLogger("").setDebugEnabled(true); + final Socket client = newClient(); + final OutputStream clientOutput = client.getOutputStream(); + + byte[] data = new byte[3 * 1024]; + Arrays.fill(data,(byte)'Y'); + String content = new String(data,"UTF-8"); + + // The request section + StringBuilder req = new StringBuilder(); + req.append("POST / HTTP/1.1\r\n"); + req.append("Host: localhost\r\n"); + req.append("Content-Type: text/plain\r\n"); + req.append("Content-Length: ").append(content.length()).append("\r\n"); + req.append("Connection: close\r\n"); + req.append("\r\n"); + // and now, the POST content section. + req.append(content); + + // Send request to server + clientOutput.write(req.toString().getBytes("UTF-8")); + clientOutput.flush(); + + InputStream in = null; + InputStreamReader isr = null; + BufferedReader reader = null; + try + { + in = client.getInputStream(); + isr = new InputStreamReader(in); + reader = new BufferedReader(isr); + + // Read the response header + String line = reader.readLine(); + Assert.assertNotNull(line); + Assert.assertThat(line,startsWith("HTTP/1.1 200 ")); + while ((line = reader.readLine()) != null) + { + if (line.trim().length() == 0) + { + break; + } + } + + Assert.assertEquals("EOF received",-1,client.getInputStream().read()); + Assert.assertEquals("one request handled",1,httpRequests.get()); + + // Don't shutdown the output + // client.shutdownOutput(); + + // server side seeking EOF + Assert.assertTrue("is open",serverEndPoint.get().isOpen()); + Assert.assertTrue("close sent",serverEndPoint.get().isOutputShutdown()); + Assert.assertFalse("close not received",serverEndPoint.get().isInputShutdown()); + + + // Check that we did not spin + TimeUnit.SECONDS.sleep(1); + int httpParseCount = httpParses.get(); + Assert.assertThat(httpParseCount,lessThan(50)); + + + // Write another request (which is ignored as the stream is closing), which causes real close. + clientOutput.write(req.toString().getBytes("UTF-8")); + clientOutput.flush(); + + // Check that we did not spin + TimeUnit.SECONDS.sleep(1); + httpParseCount = httpParses.get(); + Assert.assertThat(httpParseCount,lessThan(50)); + + + // server side is closed + Assert.assertFalse("is open",serverEndPoint.get().isOpen()); + Assert.assertTrue("close sent",serverEndPoint.get().isOutputShutdown()); + Assert.assertTrue("close not received",serverEndPoint.get().isInputShutdown()); + + Assert.assertEquals("one request handled",1,httpRequests.get()); + + } + finally + { + IO.close(reader); + IO.close(isr); + IO.close(in); + closeClient(client); + } + } + + + /** + * Test that performs a seemingly normal http POST request, but with + * a client that issues "connection: close", and then does not close + * the connection after reading the response. + *

+ * The connection should be closed by the server after a timeout. */ - @Ignore @Test public void testServerCloseClientDoesNotClose() throws Exception { @@ -155,8 +342,6 @@ public class TimeoutTest clientOutput.write(req.toString().getBytes("UTF-8")); clientOutput.flush(); - System.out.println("Client request #1 flushed"); - InputStream in = null; InputStreamReader isr = null; BufferedReader reader = null; @@ -178,23 +363,30 @@ public class TimeoutTest } } - System.out.println("Got response header"); + Assert.assertEquals("EOF received",-1,client.getInputStream().read()); + Assert.assertEquals("one request handled",1,httpRequests.get()); + + // Don't shutdown the output + // client.shutdownOutput(); + + // server side seeking EOF + Assert.assertTrue("is open",serverEndPoint.get().isOpen()); + Assert.assertTrue("close sent",serverEndPoint.get().isOutputShutdown()); + Assert.assertFalse("close not received",serverEndPoint.get().isInputShutdown()); + - // Check that we did not spin + // Wait for the server idle timeout + TimeUnit.SECONDS.sleep(3); int httpParseCount = httpParses.get(); - System.out.printf("Got %d http parses%n",httpParseCount); Assert.assertThat(httpParseCount,lessThan(50)); - // TODO: instead of sleeping, we should expect the connection being closed by the idle timeout - // TODO: mechanism; unfortunately this now is not working, and this test fails because the idle - // TODO: timeout will not trigger. - TimeUnit.SECONDS.sleep(100); + // server side is closed + Assert.assertFalse("is open",serverEndPoint.get().isOpen()); + Assert.assertTrue("close sent",serverEndPoint.get().isOutputShutdown()); + Assert.assertTrue("close not received",serverEndPoint.get().isInputShutdown()); - // Try to write another request (to prove that stream is closed) - clientOutput.write(req.toString().getBytes("UTF-8")); - clientOutput.flush(); + Assert.assertEquals("one request handled",1,httpRequests.get()); - Assert.fail("Should not have been able to send a second POST request (connection: close)"); } finally { diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 950d439036c..7a40ffecfd9 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -969,9 +969,14 @@ public class HttpParser implements Parser case STATE_SEEKING_EOF: { - // Skip all data + System.err.println("Seeking EOF read "+_buffer); + ch=_buffer.get(); + if (Character.isWhitespace(ch)) + break; + + // rubbish data sent, so let's close the connection _buffer.clear(); - break; + _endp.close(); } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 58f4cb19c0b..1f10532588f 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -257,6 +257,15 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo getSelectSet().scheduleTimeout(task,timeoutMs); } + + /* ------------------------------------------------------------ */ + @Override + public boolean isOutputShutdown() + { + setCheckForIdle(true); + return super.isOutputShutdown(); + } + /* ------------------------------------------------------------ */ public void setCheckForIdle(boolean check) { @@ -280,7 +289,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo public void checkIdleTimestamp(long now) { long idleTimestamp=_idleTimestamp; - + if (idleTimestamp!=0 && _maxIdleTime>0) { long idleForMs=now-idleTimestamp; From f7103d88f94274802bb922f386ff8dd449278b65 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 19 Dec 2011 21:56:42 +1100 Subject: [PATCH 30/56] 364638 reverted write after shutdown handling --- .../org/eclipse/jetty/client/TimeoutTest.java | 1 + .../org/eclipse/jetty/http/HttpParser.java | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java index 1d9000af00e..abe37a7f66a 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java @@ -217,6 +217,7 @@ public class TimeoutTest * The connection should be closed by the server */ @Test + @Ignore public void testServerCloseClientMoreDataSent() throws Exception { // Log.getLogger("").setDebugEnabled(true); diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 7a40ffecfd9..046430a0b38 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -969,14 +969,23 @@ public class HttpParser implements Parser case STATE_SEEKING_EOF: { - System.err.println("Seeking EOF read "+_buffer); - ch=_buffer.get(); - if (Character.isWhitespace(ch)) - break; - - // rubbish data sent, so let's close the connection _buffer.clear(); - _endp.close(); + break; + + /* + System.err.println("Seeking EOF read "+_buffer); + if (_buffer!=null) + { + ch=_buffer.get(); + if (Character.isWhitespace(ch)) + break; + + // rubbish data sent, so let's close the connection + _buffer.clear(); + _endp.close(); + } + break; + */ } } From 6d907fa61dce73d25614e326104374435ffc36f6 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 19 Dec 2011 10:03:01 -0700 Subject: [PATCH 31/56] Bug 367099 - Upgrade jetty-websocket for RFC 6455 + Renaming *D13 classes to *RFC6455 per dicussion in jetty-dev mailing list --- .../websocket/DeflateFrameExtension.java | 2 +- .../jetty/websocket/WebSocketClient.java | 8 +- .../websocket/WebSocketClientFactory.java | 10 +- ...3.java => WebSocketConnectionRFC6455.java} | 91 ++++++++++--------- .../jetty/websocket/WebSocketFactory.java | 19 ++-- ...13.java => WebSocketGeneratorRFC6455.java} | 12 +-- .../jetty/websocket/WebSocketParserD13.java | 16 ++-- ...=> WebSocketServletConnectionRFC6455.java} | 6 +- .../eclipse/jetty/websocket/TestClient.java | 12 ++- .../eclipse/jetty/websocket/TestServer.java | 4 +- .../jetty/websocket/WebSocketClientTest.java | 16 ++-- ...ava => WebSocketGeneratorRFC6455Test.java} | 16 ++-- .../jetty/websocket/WebSocketLoadD13Test.java | 6 +- ....java => WebSocketMessageRFC6455Test.java} | 88 +++++++++--------- ...t.java => WebSocketParserRFC6455Test.java} | 6 +- 15 files changed, 160 insertions(+), 152 deletions(-) rename jetty-websocket/src/main/java/org/eclipse/jetty/websocket/{WebSocketConnectionD13.java => WebSocketConnectionRFC6455.java} (88%) rename jetty-websocket/src/main/java/org/eclipse/jetty/websocket/{WebSocketGeneratorD13.java => WebSocketGeneratorRFC6455.java} (94%) rename jetty-websocket/src/main/java/org/eclipse/jetty/websocket/{WebSocketServletConnectionD13.java => WebSocketServletConnectionRFC6455.java} (76%) rename jetty-websocket/src/test/java/org/eclipse/jetty/websocket/{WebSocketGeneratorD13Test.java => WebSocketGeneratorRFC6455Test.java} (92%) rename jetty-websocket/src/test/java/org/eclipse/jetty/websocket/{WebSocketMessageD13Test.java => WebSocketMessageRFC6455Test.java} (94%) rename jetty-websocket/src/test/java/org/eclipse/jetty/websocket/{WebSocketParserD13Test.java => WebSocketParserRFC6455Test.java} (98%) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java index 54e4f6dc141..096e8f58702 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java @@ -87,7 +87,7 @@ public class DeflateFrameExtension extends AbstractExtension catch(DataFormatException e) { LOG.warn(e); - getConnection().close(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,e.toString()); + getConnection().close(WebSocketConnectionRFC6455.CLOSE_BAD_PAYLOAD,e.toString()); } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java index ef9520ff325..df50e138ed5 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java @@ -420,9 +420,9 @@ public class WebSocketClient if (channel!=null) { if (ex instanceof ProtocolException) - closeChannel(channel,WebSocketConnectionD13.CLOSE_PROTOCOL,ex.getMessage()); + closeChannel(channel,WebSocketConnectionRFC6455.CLOSE_PROTOCOL,ex.getMessage()); else - closeChannel(channel,WebSocketConnectionD13.CLOSE_NO_CLOSE,ex.getMessage()); + closeChannel(channel,WebSocketConnectionRFC6455.CLOSE_NO_CLOSE,ex.getMessage()); } } finally @@ -487,7 +487,7 @@ public class WebSocketClient if (channel!=null) { - closeChannel(channel,WebSocketConnectionD13.CLOSE_NO_CLOSE,"cancelled"); + closeChannel(channel,WebSocketConnectionRFC6455.CLOSE_NO_CLOSE,"cancelled"); return true; } return false; @@ -547,7 +547,7 @@ public class WebSocketClient } if (channel!=null) - closeChannel(channel,WebSocketConnectionD13.CLOSE_NO_CLOSE,"timeout"); + closeChannel(channel,WebSocketConnectionRFC6455.CLOSE_NO_CLOSE,"timeout"); if (exception!=null) throw new ExecutionException(exception); if (connection!=null) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java index f741988148d..2d5a8579feb 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java @@ -379,7 +379,7 @@ public class WebSocketClientFactory extends AggregateLifeCycle if (origin != null) request.append("Origin: ").append(origin).append("\r\n"); - request.append("Sec-WebSocket-Version: ").append(WebSocketConnectionD13.VERSION).append("\r\n"); + request.append("Sec-WebSocket-Version: ").append(WebSocketConnectionRFC6455.VERSION).append("\r\n"); if (_future.getProtocol() != null) request.append("Sec-WebSocket-Protocol: ").append(_future.getProtocol()).append("\r\n"); @@ -436,7 +436,7 @@ public class WebSocketClientFactory extends AggregateLifeCycle { _error = "No Sec-WebSocket-Accept"; } - else if (!WebSocketConnectionD13.hashKey(_key).equals(_accept)) + else if (!WebSocketConnectionRFC6455.hashKey(_key).equals(_accept)) { _error = "Bad Sec-WebSocket-Accept"; } @@ -444,14 +444,14 @@ public class WebSocketClientFactory extends AggregateLifeCycle { Buffer header = _parser.getHeaderBuffer(); MaskGen maskGen = _future.getMaskGen(); - WebSocketConnectionD13 connection = - new WebSocketConnectionD13(_future.getWebSocket(), + WebSocketConnectionRFC6455 connection = + new WebSocketConnectionRFC6455(_future.getWebSocket(), _endp, _buffers, System.currentTimeMillis(), _future.getMaxIdleTime(), _future.getProtocol(), null, - WebSocketConnectionD13.VERSION, + WebSocketConnectionRFC6455.VERSION, maskGen); if (header.hasContent()) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java similarity index 88% rename from jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java rename to jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java index de4d98646a4..a0e25631035 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java @@ -60,9 +60,9 @@ import org.eclipse.jetty.websocket.WebSocket.OnTextMessage; * +---------------------------------------------------------------+ * */ -public class WebSocketConnectionD13 extends AbstractConnection implements WebSocketConnection +public class WebSocketConnectionRFC6455 extends AbstractConnection implements WebSocketConnection { - private static final Logger LOG = Log.getLogger(WebSocketConnectionD13.class); + private static final Logger LOG = Log.getLogger(WebSocketConnectionRFC6455.class); final static byte OP_CONTINUATION = 0x00; final static byte OP_TEXT = 0x01; @@ -89,6 +89,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc final static int FLAG_FIN=0x8; + // Per RFC 6455, section 1.3 - Opening Handshake - this version is "13" final static int VERSION=13; static boolean isLastFrame(byte flags) @@ -104,7 +105,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc private final static byte[] MAGIC; private final List _extensions; private final WebSocketParserD13 _parser; - private final WebSocketGeneratorD13 _generator; + private final WebSocketGeneratorRFC6455 _generator; private final WebSocketGenerator _outbound; private final WebSocket _webSocket; private final OnFrame _onFrame; @@ -137,14 +138,14 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc /* ------------------------------------------------------------ */ - public WebSocketConnectionD13(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, List extensions,int draft) + public WebSocketConnectionRFC6455(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, List extensions,int draft) throws IOException { this(websocket,endpoint,buffers,timestamp,maxIdleTime,protocol,extensions,draft,null); } /* ------------------------------------------------------------ */ - public WebSocketConnectionD13(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, List extensions,int draft, MaskGen maskgen) + public WebSocketConnectionRFC6455(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, List extensions,int draft, MaskGen maskgen) throws IOException { super(endpoint,timestamp); @@ -159,7 +160,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc _onTextMessage=_webSocket instanceof OnTextMessage ? (OnTextMessage)_webSocket : null; _onBinaryMessage=_webSocket instanceof OnBinaryMessage ? (OnBinaryMessage)_webSocket : null; _onControl=_webSocket instanceof OnControl ? (OnControl)_webSocket : null; - _generator = new WebSocketGeneratorD13(buffers, _endp,maskgen); + _generator = new WebSocketGeneratorRFC6455(buffers, _endp,maskgen); _extensions=extensions; WebSocketParser.FrameHandler frameHandler = new WSFrameHandler(); @@ -272,7 +273,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc @Override public void onIdleExpired(long idleForMs) { - closeOut(WebSocketConnectionD13.CLOSE_NORMAL,"Idle for "+idleForMs+"ms > "+_endp.getMaxIdleTime()+"ms"); + closeOut(WebSocketConnectionRFC6455.CLOSE_NORMAL,"Idle for "+idleForMs+"ms > "+_endp.getMaxIdleTime()+"ms"); } /* ------------------------------------------------------------ */ @@ -289,10 +290,10 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc { closed=_closeCode==0; if (closed) - _closeCode=WebSocketConnectionD13.CLOSE_NO_CLOSE; + _closeCode=WebSocketConnectionRFC6455.CLOSE_NO_CLOSE; } if (closed) - _webSocket.onClose(WebSocketConnectionD13.CLOSE_NO_CLOSE,"closed"); + _webSocket.onClose(WebSocketConnectionRFC6455.CLOSE_NO_CLOSE,"closed"); } /* ------------------------------------------------------------ */ @@ -359,15 +360,15 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc // Close code 1005/1006 are never to be sent as a status over // a Close control frame. Code<-1 also means no node. - if (code<0 || (code == WebSocketConnectionD13.CLOSE_NO_CODE) || code==WebSocketConnectionD13.CLOSE_NO_CLOSE) + if (code<0 || (code == WebSocketConnectionRFC6455.CLOSE_NO_CODE) || code==WebSocketConnectionRFC6455.CLOSE_NO_CLOSE) code=-1; else if (code==0) - code=WebSocketConnectionD13.CLOSE_NORMAL; + code=WebSocketConnectionRFC6455.CLOSE_NORMAL; byte[] bytes = ("xx"+(message==null?"":message)).getBytes(StringUtil.__ISO_8859_1); bytes[0]=(byte)(code/0x100); bytes[1]=(byte)(code%0x100); - _outbound.addFrame((byte)FLAG_FIN,WebSocketConnectionD13.OP_CLOSE,bytes,0,code>0?bytes.length:0); + _outbound.addFrame((byte)FLAG_FIN,WebSocketConnectionRFC6455.OP_CLOSE,bytes,0,code>0?bytes.length:0); _outbound.flush(); } } @@ -417,7 +418,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc if (_closedOut) throw new IOException("closedOut "+_closeCode+":"+_closeMessage); byte[] data = content.getBytes(StringUtil.__UTF8); - _outbound.addFrame((byte)FLAG_FIN,WebSocketConnectionD13.OP_TEXT,data,0,data.length); + _outbound.addFrame((byte)FLAG_FIN,WebSocketConnectionRFC6455.OP_TEXT,data,0,data.length); checkWriteable(); } @@ -426,7 +427,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc { if (_closedOut) throw new IOException("closedOut "+_closeCode+":"+_closeMessage); - _outbound.addFrame((byte)FLAG_FIN,WebSocketConnectionD13.OP_BINARY,content,offset,length); + _outbound.addFrame((byte)FLAG_FIN,WebSocketConnectionRFC6455.OP_BINARY,content,offset,length); checkWriteable(); } @@ -467,7 +468,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc if (_disconnecting) return; _disconnecting=true; - WebSocketConnectionD13.this.closeOut(code,message); + WebSocketConnectionRFC6455.this.closeOut(code,message); } /* ------------------------------------------------------------ */ @@ -631,7 +632,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc { boolean lastFrame = isLastFrame(flags); - synchronized(WebSocketConnectionD13.this) + synchronized(WebSocketConnectionRFC6455.this) { // Ignore incoming after a close if (_closedIn) @@ -643,14 +644,14 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc if (isControlFrame(opcode) && buffer.length()>MAX_CONTROL_FRAME_PAYLOAD) { - errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Control frame too large: " + buffer.length() + " > " + MAX_CONTROL_FRAME_PAYLOAD); + errorClose(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Control frame too large: " + buffer.length() + " > " + MAX_CONTROL_FRAME_PAYLOAD); return; } // TODO: check extensions for RSV bit(s) meanings if ((flags&0x7)!=0) { - errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"RSV bits set 0x"+Integer.toHexString(flags)); + errorClose(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"RSV bits set 0x"+Integer.toHexString(flags)); return; } @@ -675,16 +676,16 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc switch(opcode) { - case WebSocketConnectionD13.OP_CONTINUATION: + case WebSocketConnectionRFC6455.OP_CONTINUATION: { if (_opcode==-1) { - errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Bad Continuation"); + errorClose(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Bad Continuation"); return; } // If text, append to the message buffer - if (_onTextMessage!=null && _opcode==WebSocketConnectionD13.OP_TEXT) + if (_onTextMessage!=null && _opcode==WebSocketConnectionRFC6455.OP_TEXT) { if (_utf8.append(buffer.array(),buffer.getIndex(),buffer.length(),_connection.getMaxTextMessageSize())) { @@ -724,39 +725,39 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc } break; } - case WebSocketConnectionD13.OP_PING: + case WebSocketConnectionRFC6455.OP_PING: { LOG.debug("PING {}",this); if (!_closedOut) { - _connection.sendControl(WebSocketConnectionD13.OP_PONG,buffer.array(),buffer.getIndex(),buffer.length()); + _connection.sendControl(WebSocketConnectionRFC6455.OP_PONG,buffer.array(),buffer.getIndex(),buffer.length()); } break; } - case WebSocketConnectionD13.OP_PONG: + case WebSocketConnectionRFC6455.OP_PONG: { LOG.debug("PONG {}",this); break; } - case WebSocketConnectionD13.OP_CLOSE: + case WebSocketConnectionRFC6455.OP_CLOSE: { - int code=WebSocketConnectionD13.CLOSE_NO_CODE; + int code=WebSocketConnectionRFC6455.CLOSE_NO_CODE; String message=null; if (buffer.length()>=2) { code=(0xff&buffer.array()[buffer.getIndex()])*0x100+(0xff&buffer.array()[buffer.getIndex()+1]); // Validate close status codes. - if (code < WebSocketConnectionD13.CLOSE_NORMAL || - code == WebSocketConnectionD13.CLOSE_UNDEFINED || - code == WebSocketConnectionD13.CLOSE_NO_CLOSE || - code == WebSocketConnectionD13.CLOSE_NO_CODE || + if (code < WebSocketConnectionRFC6455.CLOSE_NORMAL || + code == WebSocketConnectionRFC6455.CLOSE_UNDEFINED || + code == WebSocketConnectionRFC6455.CLOSE_NO_CLOSE || + code == WebSocketConnectionRFC6455.CLOSE_NO_CODE || ( code > 1010 && code <= 2999 ) || code >= 5000 ) { - errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Invalid close code " + code); + errorClose(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Invalid close code " + code); return; } @@ -772,18 +773,18 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc else if(buffer.length() == 1) { // Invalid length. use status code 1002 (Protocol error) - errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Invalid payload length of 1"); + errorClose(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Invalid payload length of 1"); return; } closeIn(code,message); break; } - case WebSocketConnectionD13.OP_TEXT: + case WebSocketConnectionRFC6455.OP_TEXT: { if (_opcode!=-1) { - errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode)); + errorClose(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode)); return; } @@ -797,7 +798,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc else { LOG.warn("Frame discarded. Text aggregation disabled for {}",_endp); - errorClose(WebSocketConnectionD13.CLOSE_POLICY_VIOLATION,"Text frame aggregation disabled"); + errorClose(WebSocketConnectionRFC6455.CLOSE_POLICY_VIOLATION,"Text frame aggregation disabled"); } } // append bytes to message buffer (if they fit) @@ -811,7 +812,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc } else { - _opcode=WebSocketConnectionD13.OP_TEXT; + _opcode=WebSocketConnectionRFC6455.OP_TEXT; } } else @@ -820,11 +821,11 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc break; } - case WebSocketConnectionD13.OP_BINARY: + case WebSocketConnectionRFC6455.OP_BINARY: { if (_opcode!=-1) { - errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode)); + errorClose(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode)); return; } @@ -845,14 +846,14 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc else { LOG.warn("Frame discarded. Binary aggregation disabed for {}",_endp); - errorClose(WebSocketConnectionD13.CLOSE_POLICY_VIOLATION,"Binary frame aggregation disabled"); + errorClose(WebSocketConnectionRFC6455.CLOSE_POLICY_VIOLATION,"Binary frame aggregation disabled"); } } break; } default: - errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Bad opcode 0x"+Integer.toHexString(opcode)); + errorClose(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Bad opcode 0x"+Integer.toHexString(opcode)); break; } } @@ -860,13 +861,13 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc { LOG.warn("{} for {}",notUtf8,_endp); LOG.debug(notUtf8); - errorClose(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,"Invalid UTF-8"); + errorClose(WebSocketConnectionRFC6455.CLOSE_BAD_PAYLOAD,"Invalid UTF-8"); } catch(Throwable probablyNotUtf8) { LOG.warn("{} for {}",probablyNotUtf8,_endp); LOG.debug(probablyNotUtf8); - errorClose(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,"Invalid Payload: "+probablyNotUtf8); + errorClose(WebSocketConnectionRFC6455.CLOSE_BAD_PAYLOAD,"Invalid Payload: "+probablyNotUtf8); } } @@ -892,7 +893,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc if (max>0 && (bufferLen+length)>max) { LOG.warn("Binary message too large > {}B for {}",_connection.getMaxBinaryMessageSize(),_endp); - _connection.close(WebSocketConnectionD13.CLOSE_MESSAGE_TOO_LARGE,"Message size > "+_connection.getMaxBinaryMessageSize()); + _connection.close(WebSocketConnectionRFC6455.CLOSE_MESSAGE_TOO_LARGE,"Message size > "+_connection.getMaxBinaryMessageSize()); _opcode=-1; if (_aggregate!=null) _aggregate.clear(); @@ -904,7 +905,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc private void textMessageTooLarge() { LOG.warn("Text message too large > {} chars for {}",_connection.getMaxTextMessageSize(),_endp); - _connection.close(WebSocketConnectionD13.CLOSE_MESSAGE_TOO_LARGE,"Text message size > "+_connection.getMaxTextMessageSize()+" chars"); + _connection.close(WebSocketConnectionRFC6455.CLOSE_MESSAGE_TOO_LARGE,"Text message size > "+_connection.getMaxTextMessageSize()+" chars"); _opcode=-1; _utf8.reset(); @@ -920,7 +921,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc @Override public String toString() { - return WebSocketConnectionD13.this.toString()+"FH"; + return WebSocketConnectionRFC6455.this.toString()+"FH"; } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java index 7b5b34180cc..1e09a9ab520 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java @@ -20,6 +20,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -192,8 +193,10 @@ public class WebSocketFactory throw new IllegalStateException("!HTTP/1.1"); int draft = request.getIntHeader("Sec-WebSocket-Version"); - if (draft < 0) + if (draft < 0) { + // Old pre-RFC version specifications (header not present in RFC-6455) draft = request.getIntHeader("Sec-WebSocket-Draft"); + } AbstractHttpConnection http = AbstractHttpConnection.getCurrentConnection(); if (http instanceof BlockingHttpConnection) throw new IllegalStateException("Websockets not supported on blocking connectors"); @@ -215,8 +218,8 @@ public class WebSocketFactory final List extensions; switch (draft) { - case -1: - case 0: + case -1: // unspecified draft/version + case 0: // Old school draft/version extensions=Collections.emptyList(); connection = new WebSocketServletConnectionD00(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol); break; @@ -234,13 +237,15 @@ public class WebSocketFactory extensions= initExtensions(extensions_requested,8-WebSocketConnectionD08.OP_EXT_DATA, 16-WebSocketConnectionD08.OP_EXT_CTRL,3); connection = new WebSocketServletConnectionD08(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft); break; - case 13: - extensions= initExtensions(extensions_requested,8-WebSocketConnectionD13.OP_EXT_DATA, 16-WebSocketConnectionD13.OP_EXT_CTRL,3); - connection = new WebSocketServletConnectionD13(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft); + case WebSocketConnectionRFC6455.VERSION: // RFC 6455 Version + extensions= initExtensions(extensions_requested,8-WebSocketConnectionRFC6455.OP_EXT_DATA, 16-WebSocketConnectionRFC6455.OP_EXT_CTRL,3); + connection = new WebSocketServletConnectionRFC6455(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft); break; default: LOG.warn("Unsupported Websocket version: "+draft); - response.setHeader("Sec-WebSocket-Version","0,6,8,13"); + // Per RFC 6455 - 4.4 - Supporting Multiple Versions of WebSocket Protocol + // Using the examples as outlined + response.setHeader("Sec-WebSocket-Version","13, 8, 6, 0"); throw new HttpException(400, "Unsupported draft specification: " + draft); } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455.java similarity index 94% rename from jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13.java rename to jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455.java index c6d5f15a15c..4bec5116529 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455.java @@ -27,7 +27,7 @@ import org.eclipse.jetty.io.EofException; * threads will call the addMessage methods while other * threads are flushing the generator. */ -public class WebSocketGeneratorD13 implements WebSocketGenerator +public class WebSocketGeneratorRFC6455 implements WebSocketGenerator { final private WebSocketBuffers _buffers; final private EndPoint _endp; @@ -38,14 +38,14 @@ public class WebSocketGeneratorD13 implements WebSocketGenerator private final MaskGen _maskGen; private boolean _closed; - public WebSocketGeneratorD13(WebSocketBuffers buffers, EndPoint endp) + public WebSocketGeneratorRFC6455(WebSocketBuffers buffers, EndPoint endp) { _buffers=buffers; _endp=endp; _maskGen=null; } - public WebSocketGeneratorD13(WebSocketBuffers buffers, EndPoint endp, MaskGen maskGen) + public WebSocketGeneratorRFC6455(WebSocketBuffers buffers, EndPoint endp, MaskGen maskGen) { _buffers=buffers; _endp=endp; @@ -63,7 +63,7 @@ public class WebSocketGeneratorD13 implements WebSocketGenerator if (_closed) throw new EofException("Closed"); - if (opcode==WebSocketConnectionD13.OP_CLOSE) + if (opcode==WebSocketConnectionRFC6455.OP_CLOSE) _closed=true; boolean mask=_maskGen!=null; @@ -71,13 +71,13 @@ public class WebSocketGeneratorD13 implements WebSocketGenerator if (_buffer==null) _buffer=mask?_buffers.getBuffer():_buffers.getDirectBuffer(); - boolean last=WebSocketConnectionD13.isLastFrame(flags); + boolean last=WebSocketConnectionRFC6455.isLastFrame(flags); int space=mask?14:10; do { - opcode = _opsent?WebSocketConnectionD13.OP_CONTINUATION:opcode; + opcode = _opsent?WebSocketConnectionRFC6455.OP_CONTINUATION:opcode; opcode=(byte)(((0xf&flags)<<4)+(0xf&opcode)); _opsent=true; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java index 0b7028d4818..b98e7dc4d06 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java @@ -161,9 +161,9 @@ public class WebSocketParserD13 implements WebSocketParser // System.err.printf("%s %s %s >>\n",TypeUtil.toHexString(_flags),TypeUtil.toHexString(_opcode),data.length()); _bytesNeeded-=data.length(); progress=true; - _handler.onFrame((byte)(_flags&(0xff^WebSocketConnectionD13.FLAG_FIN)), _opcode, data); + _handler.onFrame((byte)(_flags&(0xff^WebSocketConnectionRFC6455.FLAG_FIN)), _opcode, data); - _opcode=WebSocketConnectionD13.OP_CONTINUATION; + _opcode=WebSocketConnectionRFC6455.OP_CONTINUATION; } if (_buffer.space() == 0) @@ -199,7 +199,7 @@ public class WebSocketParserD13 implements WebSocketParser { case START: _skip=false; - _state=_opcode==WebSocketConnectionD13.OP_CLOSE?State.SEEK_EOF:State.OPCODE; + _state=_opcode==WebSocketConnectionRFC6455.OP_CLOSE?State.SEEK_EOF:State.OPCODE; _bytesNeeded=_state.getNeeds(); continue; @@ -209,10 +209,10 @@ public class WebSocketParserD13 implements WebSocketParser _opcode=(byte)(b&0xf); _flags=(byte)(0xf&(b>>4)); - if (WebSocketConnectionD13.isControlFrame(_opcode)&&!WebSocketConnectionD13.isLastFrame(_flags)) + if (WebSocketConnectionRFC6455.isControlFrame(_opcode)&&!WebSocketConnectionRFC6455.isLastFrame(_flags)) { LOG.warn("Fragmented Control from "+_endp); - _handler.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"Fragmented control"); + _handler.close(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Fragmented control"); progress=true; _skip=true; } @@ -254,7 +254,7 @@ public class WebSocketParserD13 implements WebSocketParser if (_length>_buffer.capacity() && !_fragmentFrames) { progress=true; - _handler.close(WebSocketConnectionD13.CLOSE_POLICY_VIOLATION,"frame size "+_length+">"+_buffer.capacity()); + _handler.close(WebSocketConnectionRFC6455.CLOSE_POLICY_VIOLATION,"frame size "+_length+">"+_buffer.capacity()); _skip=true; } @@ -273,7 +273,7 @@ public class WebSocketParserD13 implements WebSocketParser if (_length>=_buffer.capacity() && !_fragmentFrames) { progress=true; - _handler.close(WebSocketConnectionD13.CLOSE_POLICY_VIOLATION,"frame size "+_length+">"+_buffer.capacity()); + _handler.close(WebSocketConnectionRFC6455.CLOSE_POLICY_VIOLATION,"frame size "+_length+">"+_buffer.capacity()); _skip=true; } @@ -323,7 +323,7 @@ public class WebSocketParserD13 implements WebSocketParser _buffer.skip(_bytesNeeded); _state=State.START; progress=true; - _handler.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"Not masked"); + _handler.close(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Not masked"); } else { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionRFC6455.java similarity index 76% rename from jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java rename to jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionRFC6455.java index e1f7464fdd2..9d400413bd9 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionRFC6455.java @@ -7,15 +7,15 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.io.EndPoint; -public class WebSocketServletConnectionD13 extends WebSocketConnectionD13 implements WebSocketServletConnection +public class WebSocketServletConnectionRFC6455 extends WebSocketConnectionRFC6455 implements WebSocketServletConnection { - public WebSocketServletConnectionD13(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, + public WebSocketServletConnectionRFC6455(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, List extensions, int draft, MaskGen maskgen) throws IOException { super(websocket,endpoint,buffers,timestamp,maxIdleTime,protocol,extensions,draft,maskgen); } - public WebSocketServletConnectionD13(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, + public WebSocketServletConnectionRFC6455(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, int maxIdleTime, String protocol, List extensions, int draft) throws IOException { super(websocket,endpoint,buffers,timestamp,maxIdleTime,protocol,extensions,draft); diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java index 8a29da81323..91345e4692a 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java @@ -140,7 +140,7 @@ public class TestClient implements WebSocket.OnFrame { __framesSent++; byte flags= (byte)(off+len==data.length?0x8:0); - byte op=(byte)(off==0?opcode:WebSocketConnectionD13.OP_CONTINUATION); + byte op=(byte)(off==0?opcode:WebSocketConnectionRFC6455.OP_CONTINUATION); if (_verbose) System.err.printf("%s#sendFrame %s|%s %s\n",this.getClass().getSimpleName(),TypeUtil.toHexString(flags),TypeUtil.toHexString(op),TypeUtil.toHexString(data,off,len)); @@ -158,7 +158,9 @@ public class TestClient implements WebSocket.OnFrame public void disconnect() throws Exception { if (_connection!=null) - _connection.disconnect(); + { + _connection.close(); + } } @@ -245,11 +247,11 @@ public class TestClient implements WebSocket.OnFrame { long next = System.currentTimeMillis()+delay; - byte opcode=binary?WebSocketConnectionD13.OP_BINARY:WebSocketConnectionD13.OP_TEXT; + byte opcode=binary?WebSocketConnectionRFC6455.OP_BINARY:WebSocketConnectionRFC6455.OP_TEXT; byte data[]=null; - if (opcode==WebSocketConnectionD13.OP_TEXT) + if (opcode==WebSocketConnectionRFC6455.OP_TEXT) { StringBuilder b = new StringBuilder(); while (b.length()0); @@ -330,7 +330,7 @@ public class WebSocketClientTest error=e.getCause(); } Assert.assertFalse(open.get()); - Assert.assertEquals(WebSocketConnectionD13.CLOSE_PROTOCOL,close.get()); + Assert.assertEquals(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,close.get()); Assert.assertTrue(error instanceof IOException); Assert.assertTrue(error.getMessage().indexOf("Bad Sec-WebSocket-Accept")>=0); } @@ -368,7 +368,7 @@ public class WebSocketClientTest socket.close(); _latch.await(10,TimeUnit.SECONDS); - Assert.assertEquals(WebSocketConnectionD13.CLOSE_NO_CLOSE,close.get()); + Assert.assertEquals(WebSocketConnectionRFC6455.CLOSE_NO_CLOSE,close.get()); } @@ -406,7 +406,7 @@ public class WebSocketClientTest long start=System.currentTimeMillis(); _latch.await(10,TimeUnit.SECONDS); Assert.assertTrue(System.currentTimeMillis()-start<5000); - Assert.assertEquals(WebSocketConnectionD13.CLOSE_NORMAL,close.get()); + Assert.assertEquals(WebSocketConnectionRFC6455.CLOSE_NORMAL,close.get()); } @@ -748,7 +748,7 @@ public class WebSocketClientTest } connection.getOutputStream().write(( "HTTP/1.1 101 Upgrade\r\n" + - "Sec-WebSocket-Accept: "+ WebSocketConnectionD13.hashKey(key) +"\r\n" + + "Sec-WebSocket-Accept: "+ WebSocketConnectionRFC6455.hashKey(key) +"\r\n" + "\r\n").getBytes()); } } diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455Test.java similarity index 92% rename from jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13Test.java rename to jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455Test.java index 696a70abc48..d87707ef61e 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD13Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455Test.java @@ -13,7 +13,7 @@ import org.junit.Test; /** * @version $Revision$ $Date$ */ -public class WebSocketGeneratorD13Test +public class WebSocketGeneratorRFC6455Test { private ByteArrayBuffer _out; private WebSocketGenerator _generator; @@ -44,7 +44,7 @@ public class WebSocketGeneratorD13Test @Test public void testOneString() throws Exception { - _generator = new WebSocketGeneratorD13(_buffers, _endPoint,null); + _generator = new WebSocketGeneratorRFC6455(_buffers, _endPoint,null); byte[] data = "Hell\uFF4F W\uFF4Frld".getBytes(StringUtil.__UTF8); _generator.addFrame((byte)0x8,(byte)0x04,data,0,data.length); @@ -71,7 +71,7 @@ public class WebSocketGeneratorD13Test @Test public void testOneBuffer() throws Exception { - _generator = new WebSocketGeneratorD13(_buffers, _endPoint,null); + _generator = new WebSocketGeneratorRFC6455(_buffers, _endPoint,null); String string = "Hell\uFF4F W\uFF4Frld"; byte[] bytes=string.getBytes(StringUtil.__UTF8); @@ -99,7 +99,7 @@ public class WebSocketGeneratorD13Test @Test public void testOneLongBuffer() throws Exception { - _generator = new WebSocketGeneratorD13(_buffers, _endPoint,null); + _generator = new WebSocketGeneratorRFC6455(_buffers, _endPoint,null); byte[] b=new byte[150]; for (int i=0;i "+message); diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD13Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageRFC6455Test.java similarity index 94% rename from jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD13Test.java rename to jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageRFC6455Test.java index 4fb5fe2096b..759f8600425 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD13Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageRFC6455Test.java @@ -35,7 +35,7 @@ import org.junit.Test; /** * @version $Revision$ $Date$ */ -public class WebSocketMessageD13Test +public class WebSocketMessageRFC6455Test { private static Server __server; private static Connector __connector; @@ -82,7 +82,7 @@ public class WebSocketMessageD13Test @Test public void testHash() { - assertEquals("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=",WebSocketConnectionD13.hashKey("dGhlIHNhbXBsZSBub25jZQ==")); + assertEquals("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=",WebSocketConnectionRFC6455.hashKey("dGhlIHNhbXBsZSBub25jZQ==")); } @Test @@ -98,7 +98,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: chat, superchat\r\n"+ - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -123,7 +123,7 @@ public class WebSocketMessageD13Test String data=message.toString(); __serverWebSocket.connection.sendMessage(data); - assertEquals(WebSocketConnectionD13.OP_TEXT,input.read()); + assertEquals(WebSocketConnectionRFC6455.OP_TEXT,input.read()); assertEquals(0x7e,input.read()); assertEquals(0x1f,input.read()); assertEquals(0xf6,input.read()); @@ -146,7 +146,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: onConnect\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -181,7 +181,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: onConnect\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "Sec-WebSocket-Extensions: identity;param=0\r\n"+ "Sec-WebSocket-Extensions: identity;param=1, identity ; param = '2' ; other = ' some = value ' \r\n"+ "\r\n").getBytes("ISO-8859-1")); @@ -224,7 +224,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: onConnect\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "Sec-WebSocket-Extensions: fragment;maxLength=4;minFragments=7\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -278,7 +278,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: echo\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "Sec-WebSocket-Extensions: x-deflate-frame;minLength=64\r\n"+ "Sec-WebSocket-Extensions: fragment;minFragments=2\r\n"+ "\r\n").getBytes("ISO-8859-1")); @@ -329,7 +329,7 @@ public class WebSocketMessageD13Test output.write(buf,0,l+3); output.flush(); - assertEquals(0x40+WebSocketConnectionD13.OP_TEXT,input.read()); + assertEquals(0x40+WebSocketConnectionRFC6455.OP_TEXT,input.read()); assertEquals(0x20+3,input.read()); assertEquals(0x7e,input.read()); assertEquals(0x02,input.read()); @@ -376,7 +376,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: echo\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); output.write(0x84); @@ -415,7 +415,7 @@ public class WebSocketMessageD13Test byte[] bytes="This is a long message of text that we will send again and again".getBytes(StringUtil.__ISO_8859_1); byte[] mesg=new byte[bytes.length+6]; - mesg[0]=(byte)(0x80+WebSocketConnectionD13.OP_TEXT); + mesg[0]=(byte)(0x80+WebSocketConnectionRFC6455.OP_TEXT); mesg[1]=(byte)(0x80+bytes.length); mesg[2]=(byte)0xff; mesg[3]=(byte)0xff; @@ -434,7 +434,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: latch\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -522,7 +522,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: latch\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -610,7 +610,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: echo\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); output.write(0x89); @@ -649,7 +649,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: other\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -681,10 +681,10 @@ public class WebSocketMessageD13Test output.flush(); - assertEquals(0x80|WebSocketConnectionD13.OP_CLOSE,input.read()); + assertEquals(0x80|WebSocketConnectionRFC6455.OP_CLOSE,input.read()); assertEquals(33,input.read()); int code=(0xff&input.read())*0x100+(0xff&input.read()); - assertEquals(WebSocketConnectionD13.CLOSE_MESSAGE_TOO_LARGE,code); + assertEquals(WebSocketConnectionRFC6455.CLOSE_MESSAGE_TOO_LARGE,code); lookFor("Text message size > 10240 chars",input); } @@ -701,7 +701,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: other\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -739,10 +739,10 @@ public class WebSocketMessageD13Test output.write(bytes[i]^0xff); output.flush(); - assertEquals(0x80|WebSocketConnectionD13.OP_CLOSE,input.read()); + assertEquals(0x80|WebSocketConnectionRFC6455.OP_CLOSE,input.read()); assertEquals(30,input.read()); int code=(0xff&input.read())*0x100+(0xff&input.read()); - assertEquals(WebSocketConnectionD13.CLOSE_MESSAGE_TOO_LARGE,code); + assertEquals(WebSocketConnectionRFC6455.CLOSE_MESSAGE_TOO_LARGE,code); lookFor("Text message size > 15 chars",input); } @@ -760,7 +760,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: other\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -790,10 +790,10 @@ public class WebSocketMessageD13Test - assertEquals(0x80|WebSocketConnectionD13.OP_CLOSE,input.read()); + assertEquals(0x80|WebSocketConnectionRFC6455.OP_CLOSE,input.read()); assertEquals(30,input.read()); int code=(0xff&input.read())*0x100+(0xff&input.read()); - assertEquals(WebSocketConnectionD13.CLOSE_MESSAGE_TOO_LARGE,code); + assertEquals(WebSocketConnectionRFC6455.CLOSE_MESSAGE_TOO_LARGE,code); lookFor("Text message size > 15 chars",input); } @@ -810,7 +810,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: aggregate\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -826,7 +826,7 @@ public class WebSocketMessageD13Test assertNotNull(__serverWebSocket.connection); __serverWebSocket.getConnection().setMaxBinaryMessageSize(1024); - output.write(WebSocketConnectionD13.OP_BINARY); + output.write(WebSocketConnectionRFC6455.OP_BINARY); output.write(0x8a); output.write(0xff); output.write(0xff); @@ -847,7 +847,7 @@ public class WebSocketMessageD13Test output.write(bytes[i]^0xff); output.flush(); - assertEquals(0x80+WebSocketConnectionD13.OP_BINARY,input.read()); + assertEquals(0x80+WebSocketConnectionRFC6455.OP_BINARY,input.read()); assertEquals(20,input.read()); lookFor("01234567890123456789",input); } @@ -865,7 +865,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: other\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -904,10 +904,10 @@ public class WebSocketMessageD13Test output.flush(); - assertEquals(0x80|WebSocketConnectionD13.OP_CLOSE,input.read()); + assertEquals(0x80|WebSocketConnectionRFC6455.OP_CLOSE,input.read()); assertEquals(19,input.read()); int code=(0xff&input.read())*0x100+(0xff&input.read()); - assertEquals(WebSocketConnectionD13.CLOSE_MESSAGE_TOO_LARGE,code); + assertEquals(WebSocketConnectionRFC6455.CLOSE_MESSAGE_TOO_LARGE,code); lookFor("Message size > 15",input); } @@ -977,7 +977,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: chat\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -1088,7 +1088,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: chat\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -1159,7 +1159,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: chat\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -1186,10 +1186,10 @@ public class WebSocketMessageD13Test output.write(0x28); output.flush(); - assertEquals(0x80|WebSocketConnectionD13.OP_CLOSE,input.read()); + assertEquals(0x80|WebSocketConnectionRFC6455.OP_CLOSE,input.read()); assertEquals(15,input.read()); int code=(0xff&input.read())*0x100+(0xff&input.read()); - assertEquals(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,code); + assertEquals(WebSocketConnectionRFC6455.CLOSE_BAD_PAYLOAD,code); lookFor("Invalid UTF-8",input); } @@ -1206,7 +1206,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: other\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -1234,10 +1234,10 @@ public class WebSocketMessageD13Test output.write(bytes[i]^0xff); output.flush(); - assertEquals(0x80|WebSocketConnectionD13.OP_CLOSE,input.read()); + assertEquals(0x80|WebSocketConnectionRFC6455.OP_CLOSE,input.read()); assertEquals(19,input.read()); int code=(0xff&input.read())*0x100+(0xff&input.read()); - assertEquals(WebSocketConnectionD13.CLOSE_MESSAGE_TOO_LARGE,code); + assertEquals(WebSocketConnectionRFC6455.CLOSE_MESSAGE_TOO_LARGE,code); lookFor("Message size > 15",input); } @@ -1254,7 +1254,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: onConnect\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -1316,7 +1316,7 @@ public class WebSocketMessageD13Test "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"+ "Sec-WebSocket-Origin: http://example.com\r\n"+ "Sec-WebSocket-Protocol: onConnect\r\n" + - "Sec-WebSocket-Version: "+WebSocketConnectionD13.VERSION+"\r\n"+ + "Sec-WebSocket-Version: "+WebSocketConnectionRFC6455.VERSION+"\r\n"+ "\r\n").getBytes("ISO-8859-1")); output.flush(); @@ -1360,7 +1360,7 @@ public class WebSocketMessageD13Test final AtomicReference received = new AtomicReference(); ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096); - WebSocketGeneratorD13 gen = new WebSocketGeneratorD13(new WebSocketBuffers(8096),endp,null); + WebSocketGeneratorRFC6455 gen = new WebSocketGeneratorRFC6455(new WebSocketBuffers(8096),endp,null); byte[] data = message.getBytes(StringUtil.__UTF8); gen.addFrame((byte)0x8,(byte)0x4,data,0,data.length); @@ -1394,7 +1394,7 @@ public class WebSocketMessageD13Test MaskGen maskGen = new RandomMaskGen(); - WebSocketGeneratorD13 gen = new WebSocketGeneratorD13(new WebSocketBuffers(8096),endp,maskGen); + WebSocketGeneratorRFC6455 gen = new WebSocketGeneratorRFC6455(new WebSocketBuffers(8096),endp,maskGen); byte[] data = message.getBytes(StringUtil.__UTF8); gen.addFrame((byte)0x8,(byte)0x1,data,0,data.length); @@ -1524,9 +1524,9 @@ public class WebSocketMessageD13Test { switch(opcode) { - case WebSocketConnectionD13.OP_CLOSE: - case WebSocketConnectionD13.OP_PING: - case WebSocketConnectionD13.OP_PONG: + case WebSocketConnectionRFC6455.OP_CLOSE: + case WebSocketConnectionRFC6455.OP_PING: + case WebSocketConnectionRFC6455.OP_PONG: break; default: diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD13Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserRFC6455Test.java similarity index 98% rename from jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD13Test.java rename to jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserRFC6455Test.java index 56b573d7ac0..df1469c1848 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD13Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserRFC6455Test.java @@ -20,7 +20,7 @@ import org.junit.Test; /** * @version $Revision$ $Date$ */ -public class WebSocketParserD13Test +public class WebSocketParserRFC6455Test { private ByteArrayEndPoint _endPoint; private MaskedByteArrayBuffer _in; @@ -269,7 +269,7 @@ public class WebSocketParserD13Test int progress =_parser.parseNext(); assertTrue(progress>0); - assertEquals(WebSocketConnectionD13.CLOSE_POLICY_VIOLATION,_handler._code); + assertEquals(WebSocketConnectionRFC6455.CLOSE_POLICY_VIOLATION,_handler._code); for (int i=0;i<2048;i++) @@ -313,7 +313,7 @@ public class WebSocketParserD13Test assertTrue(progress>0); assertEquals(2,_handler._frames); - assertEquals(WebSocketConnectionD13.OP_CONTINUATION,_handler._opcode); + assertEquals(WebSocketConnectionRFC6455.OP_CONTINUATION,_handler._opcode); assertEquals(1,_handler._data.size()); String mesg=_handler._data.remove(0); From 874a6502f4a3b69cfefa7a932dd8a1fad5f0fe6b Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 19 Dec 2011 10:06:58 -0700 Subject: [PATCH 32/56] Adding missing license headers. --- .../jetty/websocket/AbstractExtension.java | 15 ++++++++++++ .../websocket/DeflateFrameExtension.java | 15 ++++++++++++ .../eclipse/jetty/websocket/Extension.java | 15 ++++++++++++ .../eclipse/jetty/websocket/FixedMaskGen.java | 15 ++++++++++++ .../jetty/websocket/FragmentExtension.java | 15 ++++++++++++ .../jetty/websocket/IdentityExtension.java | 15 ++++++++++++ .../org/eclipse/jetty/websocket/MaskGen.java | 15 ++++++++++++ .../jetty/websocket/RandomMaskGen.java | 15 ++++++++++++ .../eclipse/jetty/websocket/WebSocket.java | 15 ++++++++++++ .../jetty/websocket/WebSocketBuffers.java | 15 ++++++++++++ .../jetty/websocket/WebSocketClient.java | 15 ++++++++++++ .../websocket/WebSocketClientFactory.java | 15 ++++++++++++ .../jetty/websocket/WebSocketConnection.java | 15 ++++++++++++ .../websocket/WebSocketConnectionD00.java | 15 ++++++++++++ .../websocket/WebSocketConnectionD06.java | 15 ++++++++++++ .../websocket/WebSocketConnectionD08.java | 15 ++++++++++++ .../websocket/WebSocketConnectionRFC6455.java | 15 ++++++++++++ .../jetty/websocket/WebSocketFactory.java | 15 ++++++++++++ .../jetty/websocket/WebSocketGenerator.java | 15 ++++++++++++ .../websocket/WebSocketGeneratorD00.java | 15 ++++++++++++ .../websocket/WebSocketGeneratorD06.java | 15 ++++++++++++ .../websocket/WebSocketGeneratorD08.java | 15 ++++++++++++ .../websocket/WebSocketGeneratorRFC6455.java | 15 ++++++++++++ .../jetty/websocket/WebSocketHandler.java | 15 ++++++++++++ .../jetty/websocket/WebSocketParser.java | 15 ++++++++++++ .../jetty/websocket/WebSocketParserD00.java | 15 ++++++++++++ .../jetty/websocket/WebSocketParserD06.java | 15 ++++++++++++ .../jetty/websocket/WebSocketParserD08.java | 15 ++++++++++++ .../jetty/websocket/WebSocketParserD13.java | 15 ++++++++++++ .../jetty/websocket/WebSocketServlet.java | 15 ++++++++++++ .../websocket/WebSocketServletConnection.java | 15 ++++++++++++ .../WebSocketServletConnectionD00.java | 15 ++++++++++++ .../WebSocketServletConnectionD06.java | 15 ++++++++++++ .../WebSocketServletConnectionD08.java | 15 ++++++++++++ .../WebSocketServletConnectionRFC6455.java | 15 ++++++++++++ .../eclipse/jetty/websocket/ZeroMaskGen.java | 15 ++++++++++++ .../websocket/SafariWebsocketDraft0Test.java | 15 ++++++++++++ .../eclipse/jetty/websocket/TestClient.java | 17 +++++++++++-- .../eclipse/jetty/websocket/TestServer.java | 15 ++++++++++++ .../jetty/websocket/WebSocketClientTest.java | 15 ++++++++++++ .../jetty/websocket/WebSocketCommTest.java | 15 ++++++++++++ .../websocket/WebSocketGeneratorD00Test.java | 20 ++++++++++++---- .../websocket/WebSocketGeneratorD06Test.java | 20 ++++++++++++---- .../websocket/WebSocketGeneratorD08Test.java | 20 ++++++++++++---- .../WebSocketGeneratorRFC6455Test.java | 19 ++++++++++++--- .../jetty/websocket/WebSocketLoadD08Test.java | 20 ++++++++++++---- .../jetty/websocket/WebSocketLoadD13Test.java | 20 ++++++++++++---- .../websocket/WebSocketMessageD00Test.java | 22 ++++++++++++----- .../websocket/WebSocketMessageD06Test.java | 22 ++++++++++++----- .../websocket/WebSocketMessageD08Test.java | 24 ++++++++++++++----- .../WebSocketMessageRFC6455Test.java | 22 ++++++++++++----- .../jetty/websocket/WebSocketOverSSLTest.java | 15 ++++++++++++ .../websocket/WebSocketParserD00Test.java | 22 ++++++++++++----- .../websocket/WebSocketParserD06Test.java | 22 ++++++++++++----- .../websocket/WebSocketParserD08Test.java | 22 ++++++++++++----- .../websocket/WebSocketParserRFC6455Test.java | 22 ++++++++++++----- .../jetty/websocket/helper/CaptureSocket.java | 15 ++++++++++++ .../jetty/websocket/helper/MessageSender.java | 15 ++++++++++++ .../jetty/websocket/helper/SafariD00.java | 15 ++++++++++++ .../helper/WebSocketCaptureServlet.java | 15 ++++++++++++ 60 files changed, 916 insertions(+), 73 deletions(-) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/AbstractExtension.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/AbstractExtension.java index 57b711c609f..0e2aff4dcc6 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/AbstractExtension.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/AbstractExtension.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java index 096e8f58702..91bbf275f40 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/Extension.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/Extension.java index b3c93ec4600..67a2a521f96 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/Extension.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/Extension.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.util.Map; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/FixedMaskGen.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/FixedMaskGen.java index da59dcdc7b2..24b1a5d21f0 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/FixedMaskGen.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/FixedMaskGen.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/FragmentExtension.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/FragmentExtension.java index 106f718be53..069aa17d7b0 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/FragmentExtension.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/FragmentExtension.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/IdentityExtension.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/IdentityExtension.java index c8036c69d92..2faac0525da 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/IdentityExtension.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/IdentityExtension.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; public class IdentityExtension extends AbstractExtension diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/MaskGen.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/MaskGen.java index bbd339055b0..b5d42724f70 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/MaskGen.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/MaskGen.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; public interface MaskGen diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/RandomMaskGen.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/RandomMaskGen.java index c9340fc4d7e..f5d2527cddb 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/RandomMaskGen.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/RandomMaskGen.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.util.Random; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocket.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocket.java index ebe48263a3e..12935192e0f 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocket.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocket.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketBuffers.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketBuffers.java index fb9f53bf962..d016e67cdb6 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketBuffers.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketBuffers.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java index df50e138ed5..52ed8a4ce80 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java index 2d5a8579feb..35a1f39479c 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClientFactory.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.EOFException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java index 983c186649c..6ff89910629 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java index 3f550ddd8be..6b141dbad30 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java index da34dd17309..f9e699fa570 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java index 5d9b455c78b..dc342ab4e61 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD08.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java index a0e25631035..e996e4b34af 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java index 1e09a9ab520..098a853ec1a 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGenerator.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGenerator.java index e3e01efa480..a2759ddec21 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGenerator.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGenerator.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD00.java index d0f6f06db16..3e683d2803f 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD00.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD00.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD06.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD06.java index c511a5a2db4..88a05f061cc 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD06.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD06.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD08.java index 22c7fd38a3f..4c11c142209 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD08.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorD08.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455.java index 4bec5116529..9b214d95bac 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketHandler.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketHandler.java index eb0eefbc3b1..d90780f5c3d 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketHandler.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketHandler.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParser.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParser.java index 6cfa474df6e..b36c2ba9186 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParser.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParser.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD00.java index f277f754a3d..4b8acb63a25 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD00.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD00.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD06.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD06.java index 6436663454e..4c6d29016aa 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD06.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD06.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD08.java index 073d9ae1dd0..8101e02f9f6 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD08.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD08.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java index b98e7dc4d06..9979a683735 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java index b56e3a89324..ce9edc5c8e7 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ // ======================================================================== // Copyright (c) 2010 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnection.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnection.java index efaec616e00..8e9daaff4d3 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnection.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnection.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java index 9af93d889d5..aa2a65f745e 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD00.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java index 5c6c461bcac..741abe69672 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD06.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java index bce1e3f89e4..ba2f97eb6a3 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionD08.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionRFC6455.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionRFC6455.java index 9d400413bd9..c93b41c2679 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionRFC6455.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServletConnectionRFC6455.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/ZeroMaskGen.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/ZeroMaskGen.java index 7cddcc4f59c..3925aa0dba3 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/ZeroMaskGen.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/ZeroMaskGen.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java index 3d7f2864143..d9a5cb55df5 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import static org.hamcrest.Matchers.*; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java index 91345e4692a..4387b7573d4 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.net.InetSocketAddress; @@ -15,8 +30,6 @@ import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.TypeUtil; /** - * @version $Revision$ $Date$ - * * This is not a general purpose websocket client. * It's only for testing the websocket server and is hardwired to a specific draft version of the protocol. */ diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestServer.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestServer.java index b69aed640d3..249b632e066 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestServer.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestServer.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java index df5215a308d..79d6016978a 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import static org.hamcrest.Matchers.greaterThan; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java index c2017f7c0a9..b0d19692a37 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import static org.hamcrest.Matchers.*; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD00Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD00Test.java index 4b1c1aded35..5d86a874c86 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD00Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD00Test.java @@ -1,6 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.*; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayEndPoint; @@ -8,9 +23,6 @@ import org.eclipse.jetty.util.StringUtil; import org.junit.Before; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketGeneratorD00Test { private ByteArrayBuffer _out; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD06Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD06Test.java index f4cc5603071..e9435f875db 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD06Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD06Test.java @@ -1,6 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.*; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayEndPoint; @@ -8,9 +23,6 @@ import org.eclipse.jetty.util.StringUtil; import org.junit.Before; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketGeneratorD06Test { private ByteArrayBuffer _out; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD08Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD08Test.java index 05dfca5a151..22e173b6417 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD08Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorD08Test.java @@ -1,6 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.*; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayEndPoint; @@ -8,9 +23,6 @@ import org.eclipse.jetty.util.StringUtil; import org.junit.Before; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketGeneratorD08Test { private ByteArrayBuffer _out; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455Test.java index d87707ef61e..6c4e4ff3f63 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorRFC6455Test.java @@ -1,7 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.*; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayEndPoint; @@ -11,7 +25,6 @@ import org.junit.Before; import org.junit.Test; /** - * @version $Revision$ $Date$ */ public class WebSocketGeneratorRFC6455Test { diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD08Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD08Test.java index 9105bbcb6d8..781a8b64926 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD08Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD08Test.java @@ -1,6 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -30,9 +45,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketLoadD08Test { private static Server _server; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD13Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD13Test.java index 5c242a1bb43..9a12059a006 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD13Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketLoadD13Test.java @@ -1,6 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -30,9 +45,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketLoadD13Test { private static Server _server; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java index 53b31f1bf30..0bcd6ce4b7b 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java @@ -1,8 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; @@ -26,9 +39,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketMessageD00Test { private static Server _server; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD06Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD06Test.java index f0e8a4c5ea1..5952f8f4df7 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD06Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD06Test.java @@ -1,8 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.EOFException; import java.io.IOException; @@ -27,9 +40,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketMessageD06Test { private static Server _server; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java index f1bd18c012b..be553c2441b 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD08Test.java @@ -1,8 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.EOFException; import java.io.IOException; @@ -32,9 +45,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketMessageD08Test { private static Server __server; @@ -461,6 +471,7 @@ public class WebSocketMessageD08Test // unblock the latch in 4s new Thread() { + @Override public void run() { try @@ -544,6 +555,7 @@ public class WebSocketMessageD08Test final AtomicLong totalB=new AtomicLong(); new Thread() { + @Override public void run() { try diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageRFC6455Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageRFC6455Test.java index 759f8600425..113fc830122 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageRFC6455Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageRFC6455Test.java @@ -1,8 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.EOFException; import java.io.IOException; @@ -32,9 +45,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketMessageRFC6455Test { private static Server __server; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java index fd73e6b43ff..80b262d6392 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketOverSSLTest.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; import java.io.IOException; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD00Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD00Test.java index efa70d257eb..3f22af55c6c 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD00Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD00Test.java @@ -1,8 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.util.ArrayList; import java.util.List; @@ -16,9 +29,6 @@ import org.eclipse.jetty.util.StringUtil; import org.junit.Before; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketParserD00Test { private ByteArrayBuffer _in; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD06Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD06Test.java index bcd513657a0..bb9c69049c2 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD06Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD06Test.java @@ -1,8 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.util.ArrayList; import java.util.List; @@ -17,9 +30,6 @@ import org.eclipse.jetty.util.Utf8StringBuilder; import org.junit.Before; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketParserD06Test { private MaskedByteArrayBuffer _in; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD08Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD08Test.java index b34c1ff04ba..fa156eac4f8 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD08Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD08Test.java @@ -1,8 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.util.ArrayList; import java.util.List; @@ -17,9 +30,6 @@ import org.eclipse.jetty.util.Utf8StringBuilder; import org.junit.Before; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketParserD08Test { private MaskedByteArrayBuffer _in; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserRFC6455Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserRFC6455Test.java index df1469c1848..34d0f1efdd1 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserRFC6455Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserRFC6455Test.java @@ -1,8 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.util.ArrayList; import java.util.List; @@ -17,9 +30,6 @@ import org.eclipse.jetty.util.Utf8StringBuilder; import org.junit.Before; import org.junit.Test; -/** - * @version $Revision$ $Date$ - */ public class WebSocketParserRFC6455Test { private ByteArrayEndPoint _endPoint; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java index 45842596af3..5df3119d474 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket.helper; import java.util.ArrayList; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java index 1a039ceb192..34ceb54c40c 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket.helper; import java.io.IOException; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java index a1370f092a0..d9731b3649c 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket.helper; import static org.hamcrest.Matchers.*; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/WebSocketCaptureServlet.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/WebSocketCaptureServlet.java index 706c4bd7eb4..b4731283823 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/WebSocketCaptureServlet.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/WebSocketCaptureServlet.java @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 Intalio, Inc. + * ====================================================================== + * 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.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + *******************************************************************************/ package org.eclipse.jetty.websocket.helper; import java.io.IOException; From 95f763fab4d91686355468b365be6fe27cfdfe59 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 19 Dec 2011 12:29:15 -0700 Subject: [PATCH 33/56] Bug 367099 - Upgrade jetty-websocket for RFC 6455 + Adding new RFC declared close codes 1011 (CLOSE_SERVER_ERROR) and 1015 (CLOSE_FAILED_TLS_HANDSHAKE) + Adding support for responding as CLOSE_SERVER_ERROR if an unhandled exception (similar to how HTTP error 500 works) but for exceptions thrown out of implementations of WebSocket. + Adding guard to prevent use of CLOSE_FAILED_TLS_HANDSHAKE on close control frame. + Adding unit test for the CLOSE_SERVER_ERROR case. + Adding unit test for HTTP response 400 on bad Sec-WebSocket-Version request header value. --- .../websocket/WebSocketConnectionRFC6455.java | 29 +-- .../jetty/websocket/WebSocketFactory.java | 2 +- .../jetty/websocket/WebSocketCommTest.java | 35 ++-- .../websocket/WebSocketServletRFCTest.java | 174 ++++++++++++++++++ .../jetty/websocket/helper/MessageSender.java | 14 ++ 5 files changed, 224 insertions(+), 30 deletions(-) create mode 100644 jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java index e996e4b34af..ed911036e9a 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java @@ -101,6 +101,8 @@ public class WebSocketConnectionRFC6455 extends AbstractConnection implements We final static int CLOSE_POLICY_VIOLATION=1008; final static int CLOSE_MESSAGE_TOO_LARGE=1009; final static int CLOSE_REQUIRED_EXTENSION=1010; + final static int CLOSE_SERVER_ERROR=1011; + final static int CLOSE_FAILED_TLS_HANDSHAKE=1015; final static int FLAG_FIN=0x8; @@ -372,13 +374,18 @@ public class WebSocketConnectionRFC6455 extends AbstractConnection implements We { if (!closed_out) { - // Close code 1005/1006 are never to be sent as a status over + // Close code 1005/1006/1015 are never to be sent as a status over // a Close control frame. Code<-1 also means no node. - if (code<0 || (code == WebSocketConnectionRFC6455.CLOSE_NO_CODE) || code==WebSocketConnectionRFC6455.CLOSE_NO_CLOSE) - code=-1; - else if (code==0) - code=WebSocketConnectionRFC6455.CLOSE_NORMAL; + if (code < 0 || (code == WebSocketConnectionRFC6455.CLOSE_NO_CODE) || (code == WebSocketConnectionRFC6455.CLOSE_NO_CLOSE) + || (code == WebSocketConnectionRFC6455.CLOSE_FAILED_TLS_HANDSHAKE)) + { + code = -1; + } + else if (code == 0) + { + code = WebSocketConnectionRFC6455.CLOSE_NORMAL; + } byte[] bytes = ("xx"+(message==null?"":message)).getBytes(StringUtil.__ISO_8859_1); bytes[0]=(byte)(code/0x100); @@ -769,7 +776,7 @@ public class WebSocketConnectionRFC6455 extends AbstractConnection implements We code == WebSocketConnectionRFC6455.CLOSE_UNDEFINED || code == WebSocketConnectionRFC6455.CLOSE_NO_CLOSE || code == WebSocketConnectionRFC6455.CLOSE_NO_CODE || - ( code > 1010 && code <= 2999 ) || + ( code > 1011 && code <= 2999 ) || code >= 5000 ) { errorClose(WebSocketConnectionRFC6455.CLOSE_PROTOCOL,"Invalid close code " + code); @@ -874,15 +881,15 @@ public class WebSocketConnectionRFC6455 extends AbstractConnection implements We } catch(Utf8Appendable.NotUtf8Exception notUtf8) { - LOG.warn("{} for {}",notUtf8,_endp); + LOG.warn("NOTUTF8 - {} for {}",notUtf8,_endp, notUtf8); LOG.debug(notUtf8); errorClose(WebSocketConnectionRFC6455.CLOSE_BAD_PAYLOAD,"Invalid UTF-8"); } - catch(Throwable probablyNotUtf8) + catch(Throwable e) { - LOG.warn("{} for {}",probablyNotUtf8,_endp); - LOG.debug(probablyNotUtf8); - errorClose(WebSocketConnectionRFC6455.CLOSE_BAD_PAYLOAD,"Invalid Payload: "+probablyNotUtf8); + LOG.warn("{} for {}",e,_endp, e); + LOG.debug(e); + errorClose(WebSocketConnectionRFC6455.CLOSE_SERVER_ERROR,"Internal Server Error: "+e); } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java index 098a853ec1a..25f58c1ef06 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java @@ -261,7 +261,7 @@ public class WebSocketFactory // Per RFC 6455 - 4.4 - Supporting Multiple Versions of WebSocket Protocol // Using the examples as outlined response.setHeader("Sec-WebSocket-Version","13, 8, 6, 0"); - throw new HttpException(400, "Unsupported draft specification: " + draft); + throw new HttpException(400, "Unsupported websocket version specification: " + draft); } // Set the defaults diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java index b0d19692a37..0e91ffaa0e9 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketCommTest.java @@ -24,13 +24,12 @@ import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; -import org.eclipse.jetty.util.log.StdErrLog; import org.eclipse.jetty.websocket.helper.CaptureSocket; import org.eclipse.jetty.websocket.helper.MessageSender; import org.eclipse.jetty.websocket.helper.WebSocketCaptureServlet; +import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; /** @@ -43,14 +42,6 @@ public class WebSocketCommTest private WebSocketCaptureServlet servlet; private URI serverUri; - @BeforeClass - public static void initLogging() - { - // Configure Logging - System.setProperty("org.eclipse.jetty.util.log.class",StdErrLog.class.getName()); - System.setProperty("org.eclipse.jetty.LEVEL","DEBUG"); - } - @Before public void startServer() throws Exception { @@ -79,6 +70,19 @@ public class WebSocketCommTest System.out.printf("Server URI: %s%n",serverUri); } + @After + public void stopServer() + { + try + { + server.stop(); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + @Test public void testSendTextMessages() throws Exception { @@ -105,10 +109,11 @@ public class WebSocketCommTest CaptureSocket socket = servlet.captures.get(0); Assert.assertThat("CaptureSocket",socket,notNullValue()); - Assert.assertThat("CaptureSocket.isConnected", socket.isConnected(), is(true)); + Assert.assertThat("CaptureSocket.isConnected",socket.isConnected(),is(true)); // Give servlet 500 millisecond to process messages - threadSleep(500,TimeUnit.MILLISECONDS); + TimeUnit.MILLISECONDS.sleep(500); + // Should have captured 5 messages. Assert.assertThat("CaptureSocket.messages.size",socket.messages.size(),is(5)); } @@ -118,10 +123,4 @@ public class WebSocketCommTest sender.close(); } } - - public static void threadSleep(int dur, TimeUnit unit) throws InterruptedException - { - long ms = TimeUnit.MILLISECONDS.convert(dur,unit); - Thread.sleep(ms); - } } diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java new file mode 100644 index 00000000000..0f90cb18969 --- /dev/null +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java @@ -0,0 +1,174 @@ +package org.eclipse.jetty.websocket; + +import static org.hamcrest.Matchers.*; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URL; +import java.util.concurrent.TimeUnit; + +import javax.servlet.http.HttpServletRequest; + +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.websocket.helper.MessageSender; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Test various RFC 6455 specified requirements placed on + * {@link WebSocketServlet} + *

+ * This test serves a different purpose than than the {@link WebSocketGeneratorRFC6455Test}, + * {@link WebSocketMessageRFC6455Test}, and {@link WebSocketParserRFC6455Test} tests. + */ +public class WebSocketServletRFCTest +{ + private static class RFCSocket implements WebSocket, WebSocket.OnTextMessage + { + private Connection conn; + + public void onOpen(Connection connection) + { + this.conn = connection; + } + + public void onClose(int closeCode, String message) + { + this.conn = null; + } + + public void onMessage(String data) + { + // Test the RFC 6455 close code 1011 that should close + // trigger a WebSocket server terminated close. + if (data.equals("CRASH")) + { + throw new RuntimeException("Something bad happened"); + } + + // echo the message back. + try + { + conn.sendMessage(data); + } + catch (IOException e) + { + e.printStackTrace(System.err); + } + } + + } + + @SuppressWarnings("serial") + private static class RFCServlet extends WebSocketServlet + { + public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) + { + return new RFCSocket(); + } + } + + private static Server server; + private static URI serverUri; + + @BeforeClass + public static void startServer() throws Exception + { + // Configure Server + server = new Server(0); + + ServletContextHandler context = new ServletContextHandler(); + context.setContextPath("/"); + server.setHandler(context); + + // Serve capture servlet + context.addServlet(new ServletHolder(new RFCServlet()),"/"); + + // Start Server + server.start(); + + Connector conn = server.getConnectors()[0]; + String host = conn.getHost(); + if (host == null) + { + host = "localhost"; + } + int port = conn.getLocalPort(); + serverUri = new URI(String.format("ws://%s:%d/",host,port)); + System.out.printf("Server URI: %s%n",serverUri); + } + + @AfterClass + public static void stopServer() + { + try + { + server.stop(); + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + + /** + * Test the requirement of responding with an http 400 when using a Sec-WebSocket-Version that is unsupported. + */ + @Test + public void testResponseOnInvalidVersion() throws Exception + { + // Using straight HttpUrlConnection to accomplish this as jetty's WebSocketClient + // doesn't allow the use of invalid versions. (obviously) + + URL url = new URL("http://" + serverUri.getHost() + ":" + serverUri.getPort() + "/"); + HttpURLConnection conn = (HttpURLConnection)url.openConnection(); + conn.setRequestProperty("Upgrade","WebSocket"); + conn.setRequestProperty("Connection","Upgrade"); + conn.setRequestProperty("Sec-WebSocket-Version","29"); + conn.connect(); + + Assert.assertEquals("Response Code",400,conn.getResponseCode()); + Assert.assertThat("Response Message",conn.getResponseMessage(),containsString("Unsupported websocket version specification")); + Assert.assertThat("Response Header Versions",conn.getHeaderField("Sec-WebSocket-Version"),is("13, 8, 6, 0")); + + conn.disconnect(); + } + + /** + * Test the requirement of responding with server terminated close code 1011 when there is an unhandled (internal + * server error) being produced by the extended WebSocketServlet. + */ + @Test + public void testResponseOnInternalError() throws Exception + { + WebSocketClientFactory clientFactory = new WebSocketClientFactory(); + clientFactory.start(); + + WebSocketClient wsc = clientFactory.newWebSocketClient(); + MessageSender sender = new MessageSender(); + wsc.open(serverUri,sender); + + try + { + sender.awaitConnect(); + + sender.sendMessage("CRASH"); + + // Give servlet 500 millisecond to process messages + TimeUnit.MILLISECONDS.sleep(500); + + Assert.assertThat("WebSocket should be closed", sender.isConnected(), is(false)); + Assert.assertThat("WebSocket close clode", sender.getCloseCode(), is(1011)); + } + finally + { + sender.close(); + } + } +} diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java index 34ceb54c40c..65896aab982 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java @@ -25,6 +25,8 @@ public class MessageSender implements WebSocket { private Connection conn; private CountDownLatch connectLatch = new CountDownLatch(1); + private int closeCode = -1; + private String closeMessage = null; public void onOpen(Connection connection) { @@ -35,6 +37,8 @@ public class MessageSender implements WebSocket public void onClose(int closeCode, String message) { this.conn = null; + this.closeCode = closeCode; + this.closeMessage = message; } public boolean isConnected() @@ -45,6 +49,16 @@ public class MessageSender implements WebSocket } return this.conn.isOpen(); } + + public int getCloseCode() + { + return closeCode; + } + + public String getCloseMessage() + { + return closeMessage; + } public void sendMessage(String format, Object... args) throws IOException { From 93ebd1dbe53bea7c512bdf4aa1f63245a8602630 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 19 Dec 2011 13:06:54 -0700 Subject: [PATCH 34/56] Using straight Socket as HttpURLConnection request header modifications are not reliable enough for testing purposes --- .../websocket/WebSocketServletRFCTest.java | 85 +++++++++++++++---- 1 file changed, 68 insertions(+), 17 deletions(-) diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java index 0f90cb18969..5984009a8cf 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java @@ -2,10 +2,15 @@ package org.eclipse.jetty.websocket; import static org.hamcrest.Matchers.*; +import java.io.BufferedReader; import java.io.IOException; -import java.net.HttpURLConnection; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketAddress; import java.net.URI; -import java.net.URL; import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletRequest; @@ -14,6 +19,7 @@ import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.IO; import org.eclipse.jetty.websocket.helper.MessageSender; import org.junit.AfterClass; import org.junit.Assert; @@ -88,7 +94,7 @@ public class WebSocketServletRFCTest server.setHandler(context); // Serve capture servlet - context.addServlet(new ServletHolder(new RFCServlet()),"/"); + context.addServlet(new ServletHolder(new RFCServlet()),"/*"); // Start Server server.start(); @@ -123,21 +129,66 @@ public class WebSocketServletRFCTest @Test public void testResponseOnInvalidVersion() throws Exception { - // Using straight HttpUrlConnection to accomplish this as jetty's WebSocketClient + // Using straight Socket to accomplish this as jetty's WebSocketClient // doesn't allow the use of invalid versions. (obviously) - URL url = new URL("http://" + serverUri.getHost() + ":" + serverUri.getPort() + "/"); - HttpURLConnection conn = (HttpURLConnection)url.openConnection(); - conn.setRequestProperty("Upgrade","WebSocket"); - conn.setRequestProperty("Connection","Upgrade"); - conn.setRequestProperty("Sec-WebSocket-Version","29"); - conn.connect(); + Socket socket = new Socket(); + SocketAddress endpoint = new InetSocketAddress(serverUri.getHost(),serverUri.getPort()); + socket.connect(endpoint); - Assert.assertEquals("Response Code",400,conn.getResponseCode()); - Assert.assertThat("Response Message",conn.getResponseMessage(),containsString("Unsupported websocket version specification")); - Assert.assertThat("Response Header Versions",conn.getHeaderField("Sec-WebSocket-Version"),is("13, 8, 6, 0")); + StringBuilder req = new StringBuilder(); + req.append("GET / HTTP/1.1\r\n"); + req.append(String.format("Host: %s:%d\r\n",serverUri.getHost(),serverUri.getPort())); + req.append("Upgrade: WebSocket\r\n"); + req.append("Connection: Upgrade\r\n"); + req.append("Sec-WebSocket-Version: 29\r\n"); // bad version + req.append("\r\n"); - conn.disconnect(); + OutputStream out = null; + InputStream in = null; + try + { + out = socket.getOutputStream(); + in = socket.getInputStream(); + + // Write request + out.write(req.toString().getBytes()); + out.flush(); + + // Read response + String respHeader = readResponseHeader(in); + System.out.println("RESPONSE: " + respHeader); + + Assert.assertThat("Response Code",respHeader,startsWith("HTTP/1.1 400 Unsupported websocket version specification")); + Assert.assertThat("Response Header Versions",respHeader,containsString("Sec-WebSocket-Version: 13, 8, 6, 0\r\n")); + } + finally + { + IO.close(in); + IO.close(out); + socket.close(); + } + } + + private String readResponseHeader(InputStream in) throws IOException + { + InputStreamReader isr = new InputStreamReader(in); + BufferedReader reader = new BufferedReader(isr); + StringBuilder header = new StringBuilder(); + // Read the response header + String line = reader.readLine(); + Assert.assertNotNull(line); + Assert.assertThat(line,startsWith("HTTP/1.1 ")); + header.append(line).append("\r\n"); + while ((line = reader.readLine()) != null) + { + if (line.trim().length() == 0) + { + break; + } + header.append(line).append("\r\n"); + } + return header.toString(); } /** @@ -162,9 +213,9 @@ public class WebSocketServletRFCTest // Give servlet 500 millisecond to process messages TimeUnit.MILLISECONDS.sleep(500); - - Assert.assertThat("WebSocket should be closed", sender.isConnected(), is(false)); - Assert.assertThat("WebSocket close clode", sender.getCloseCode(), is(1011)); + + Assert.assertThat("WebSocket should be closed",sender.isConnected(),is(false)); + Assert.assertThat("WebSocket close clode",sender.getCloseCode(),is(1011)); } finally { From 960407492a0743a765ade77a8c6dd08ad29ffe4e Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 19 Dec 2011 13:13:57 -0700 Subject: [PATCH 35/56] Removing System.out debug --- .../org/eclipse/jetty/websocket/WebSocketServletRFCTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java index 5984009a8cf..fcde6e3135e 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java @@ -157,7 +157,7 @@ public class WebSocketServletRFCTest // Read response String respHeader = readResponseHeader(in); - System.out.println("RESPONSE: " + respHeader); + // System.out.println("RESPONSE: " + respHeader); Assert.assertThat("Response Code",respHeader,startsWith("HTTP/1.1 400 Unsupported websocket version specification")); Assert.assertThat("Response Header Versions",respHeader,containsString("Sec-WebSocket-Version: 13, 8, 6, 0\r\n")); From d2a91f40cd4fac974c9c19151caa1794738bc200 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Dec 2011 08:08:02 +1100 Subject: [PATCH 36/56] disable continuation 6 testing --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dcc7fb7a289..d72b94869ac 100644 --- a/pom.xml +++ b/pom.xml @@ -351,7 +351,7 @@ jetty-http-spi jetty-distribution test-continuation - test-continuation-jetty6 + test-jetty-servlet test-jetty-webapp test-jetty-nested From c5c6377e26dff5f99a91fadf1029cc5074cd4ad4 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Dec 2011 09:21:18 +1100 Subject: [PATCH 37/56] some IOTests to show that clients can write after server close??? --- .../java/org/eclipse/jetty/io/IOTest.java | 85 ++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/IOTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/IOTest.java index 8575ab7f229..56400165ab9 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/IOTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/IOTest.java @@ -20,12 +20,16 @@ import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; +import junit.framework.Assert; + +import org.eclipse.jetty.toolchain.test.OS; import org.eclipse.jetty.util.IO; import org.junit.Test; @@ -192,8 +196,87 @@ public class IOTest } catch(Exception e) { - // Dang OSX! System.err.println(e); + assertTrue(OS.IS_OSX); + } + } + + @Test + public void testHalfCloseBadClient() throws Exception + { + ServerSocketChannel connector = ServerSocketChannel.open(); + connector.socket().bind(null); + + Socket client = SocketChannel.open(connector.socket().getLocalSocketAddress()).socket(); + client.setSoTimeout(1000); + client.setSoLinger(false,-1); + Socket server = connector.accept().socket(); + server.setSoTimeout(1000); + server.setSoLinger(false,-1); + + // Write from client to server + client.getOutputStream().write(1); + + // Server reads + assertEquals(1,server.getInputStream().read()); + + // Write from server to client with oshut + server.getOutputStream().write(1); + System.err.println("OSHUT "+server); + server.shutdownOutput(); + + try + { + // Client reads response + assertEquals(1,client.getInputStream().read()); + + // Client reads -1 + assertEquals(-1,client.getInputStream().read()); + assertFalse(client.isInputShutdown()); + + // Client can still write as we are half closed + client.getOutputStream().write(1); + + // Server can still read + assertEquals(1,server.getInputStream().read()); + + // Server now closes + server.close(); + + // Client still reads -1 (not broken pipe !!) + assertEquals(-1,client.getInputStream().read()); + assertFalse(client.isInputShutdown()); + + Thread.sleep(100); + + // Client still reads -1 (not broken pipe !!) + assertEquals(-1,client.getInputStream().read()); + assertFalse(client.isInputShutdown()); + + // Client can still write data even though server is closed??? + client.getOutputStream().write(1); + Thread.sleep(100); + client.getOutputStream().write(1); + + // Client eventually sees Broken Pipe + int i=0; + try + { + for (i=0;i<100000;i++) + client.getOutputStream().write(1); + + Assert.fail(); + } + catch (IOException e) + { + } + client.close(); + + } + catch (Exception e) + { + System.err.println("PLEASE INVESTIGATE:"); + e.printStackTrace(); } } From b7d8bd4f28160120a8edb1316db5940837d52199 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Dec 2011 10:55:56 +1100 Subject: [PATCH 38/56] 364638 HttpParser closes if data received while seeking EOF. Tests fixed to cope --- .../org/eclipse/jetty/client/TimeoutTest.java | 17 +++++++++- .../org/eclipse/jetty/http/HttpParser.java | 31 ++++++++++--------- .../eclipse/jetty/http/HttpParserTest.java | 30 ++++++++++++++++++ .../continuation/test/ContinuationBase.java | 8 +++-- 4 files changed, 69 insertions(+), 17 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java index abe37a7f66a..4aefca55148 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/TimeoutTest.java @@ -217,7 +217,6 @@ public class TimeoutTest * The connection should be closed by the server */ @Test - @Ignore public void testServerCloseClientMoreDataSent() throws Exception { // Log.getLogger("").setDebugEnabled(true); @@ -387,6 +386,22 @@ public class TimeoutTest Assert.assertTrue("close not received",serverEndPoint.get().isInputShutdown()); Assert.assertEquals("one request handled",1,httpRequests.get()); + + + // client will eventually get broken pipe if it keeps writing + try + { + for (int i=0;i<1000;i++) + { + clientOutput.write(req.toString().getBytes("UTF-8")); + clientOutput.flush(); + } + Assert.fail("Client should have seen a broken pipe"); + } + catch(IOException e) + { + // expected broken pipe + } } finally diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 046430a0b38..f7327177407 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -968,24 +968,27 @@ public class HttpParser implements Parser } case STATE_SEEKING_EOF: - { - _buffer.clear(); - break; - - /* - System.err.println("Seeking EOF read "+_buffer); - if (_buffer!=null) + { + // Close if there is more data than CRLF + if (_buffer.length()>2) { - ch=_buffer.get(); - if (Character.isWhitespace(ch)) - break; - - // rubbish data sent, so let's close the connection - _buffer.clear(); + _state=STATE_END; _endp.close(); } + else + { + // or if the data is not white space + while (_buffer.length()>0) + if (!Character.isWhitespace(_buffer.get())) + { + _state=STATE_END; + _endp.close(); + _buffer.clear(); + } + } + + _buffer.clear(); break; - */ } } diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java index 85cf15c202c..e861721de0b 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java @@ -510,6 +510,36 @@ public class HttpParserTest assertTrue(messageCompleted); } + @Test + public void testSeekEOF() throws Exception + { + StringEndPoint io=new StringEndPoint(); + io.setInput( + "HTTP/1.1 200 OK\015\012" + + "Content-Length: 0\015\012" + + "Connection: close\015\012" + + "\015\012" + + "\015\012" // extra CRLF ignored + + "HTTP/1.1 400 OK\015\012"); // extra data causes close + + + ByteArrayBuffer buffer= new ByteArrayBuffer(4096); + SimpleBuffers buffers=new SimpleBuffers(buffer,null); + + Handler handler = new Handler(); + HttpParser parser= new HttpParser(buffers,io, handler); + + parser.parse(); + assertEquals("HTTP/1.1", f0); + assertEquals("200", f1); + assertEquals("OK", f2); + assertEquals(null,_content); + assertTrue(headerCompleted); + assertTrue(messageCompleted); + + + } + private String _content; private String f0; private String f1; diff --git a/test-continuation/src/main/java/org/eclipse/jetty/continuation/test/ContinuationBase.java b/test-continuation/src/main/java/org/eclipse/jetty/continuation/test/ContinuationBase.java index 2049dc1fc07..f7b516ef768 100644 --- a/test-continuation/src/main/java/org/eclipse/jetty/continuation/test/ContinuationBase.java +++ b/test-continuation/src/main/java/org/eclipse/jetty/continuation/test/ContinuationBase.java @@ -233,9 +233,13 @@ public abstract class ContinuationBase extends TestCase request+=" HTTP/1.1\r\n"+ "Host: localhost\r\n"+ "Connection: close\r\n"; - if (content!=null) + if (content==null) + request+="\r\n"; + else + { request+="Content-Length: "+content.length()+"\r\n"; - request+="\r\n" + content; + request+="\r\n" + content; + } int port=_port; String response=null; From 569e9301857ac8ad8715d5cf1204bd120c426486 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Dec 2011 11:13:45 +1100 Subject: [PATCH 39/56] 367048 test harness for guard on suspended requests --- .../jetty/server/AsyncHttpConnection.java | 2 +- .../server/SelectChannelAsyncContextTest.java | 56 ++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java index 7546302e697..8ec0737e5a7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java @@ -64,7 +64,7 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async // Handle resumed request if (_request._async.isAsync()) { - if ( _request._async.isDispatchable()) + if (_request._async.isDispatchable()) handleRequest(); } // else Parse more input diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelAsyncContextTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelAsyncContextTest.java index 35383e345cf..3bd3cf3920e 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelAsyncContextTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelAsyncContextTest.java @@ -1,17 +1,33 @@ package org.eclipse.jetty.server; +import java.io.IOException; import java.net.Socket; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.util.IO; +import org.junit.Test; public class SelectChannelAsyncContextTest extends LocalAsyncContextTest { + volatile SelectChannelEndPoint _endp; @Override protected Connector initConnector() { - return new SelectChannelConnector(); + return new SelectChannelConnector(){ + + @Override + public void customize(EndPoint endpoint, Request request) throws IOException + { + super.customize(endpoint,request); + _endp=(SelectChannelEndPoint)endpoint; + } + + }; } @Override @@ -23,4 +39,42 @@ public class SelectChannelAsyncContextTest extends LocalAsyncContextTest return IO.toString(socket.getInputStream()); } + @Test + public void testSuspendResumeWithAsyncDispatch() throws Exception + { + // Test that suspend/resume works in the face of spurious asyncDispatch call that may be + // produced by the SslConnection + final AtomicBoolean running = new AtomicBoolean(true); + Thread thread = new Thread() + { + public void run() + { + while (running.get()) + { + try + { + TimeUnit.MILLISECONDS.sleep(200); + SelectChannelEndPoint endp=_endp; + if (endp!=null && endp.isOpen()) + endp.asyncDispatch(); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + } + }; + + try + { + thread.start(); + testSuspendResume(); + } + finally + { + running.set(false); + thread.join(); + } + } } From b67961ada3830c83aadb404b4eaa888cd493f6c2 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Dec 2011 12:00:48 +1100 Subject: [PATCH 40/56] JETTY-1463 websocket D0 parser should return progress even if no fill done --- .../jetty/websocket/WebSocketConnectionD00.java | 12 ++++++------ .../websocket/WebSocketConnectionRFC6455.java | 1 - .../jetty/websocket/WebSocketParserD00.java | 15 +++++++++------ .../websocket/SafariWebsocketDraft0Test.java | 9 ++++----- .../jetty/websocket/helper/CaptureSocket.java | 2 +- .../eclipse/jetty/websocket/helper/SafariD00.java | 4 ++-- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java index 6b141dbad30..b634bba1f92 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD00.java @@ -150,11 +150,10 @@ public class WebSocketConnectionD00 extends AbstractConnection implements WebSoc progress = flushed>0 || filled>0; - if (filled<0 || flushed<0) - { - _endp.close(); - break; - } + _endp.flush(); + + if (_endp instanceof AsyncEndPoint && ((AsyncEndPoint)_endp).hasProgressed()) + progress=true; } } catch(IOException e) @@ -162,7 +161,8 @@ public class WebSocketConnectionD00 extends AbstractConnection implements WebSoc LOG.debug(e); try { - _endp.close(); + if (_endp.isOpen()) + _endp.close(); } catch(IOException e2) { diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java index ed911036e9a..47c45a5922b 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionRFC6455.java @@ -235,7 +235,6 @@ public class WebSocketConnectionRFC6455 extends AbstractConnection implements We int filled=_parser.parseNext(); progress = flushed>0 || filled>0; - _endp.flush(); if (_endp instanceof AsyncEndPoint && ((AsyncEndPoint)_endp).hasProgressed()) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD00.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD00.java index 4b8acb63a25..190ccde210b 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD00.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD00.java @@ -33,6 +33,7 @@ import java.io.IOException; import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffers; import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -101,7 +102,7 @@ public class WebSocketParserD00 implements WebSocketParser if (_buffer==null) _buffer=_buffers.getBuffer(); - int total_filled=0; + int progress=0; // Loop until an datagram call back or can't fill anymore while(true) @@ -123,14 +124,14 @@ public class WebSocketParserD00 implements WebSocketParser { int filled=_endp.isOpen()?_endp.fill(_buffer):-1; if (filled<=0) - return total_filled; - total_filled+=filled; + return progress; + progress+=filled; length=_buffer.length(); } catch(IOException e) { LOG.debug(e); - return total_filled>0?total_filled:-1; + return progress>0?progress:-1; } } @@ -162,6 +163,7 @@ public class WebSocketParserD00 implements WebSocketParser { _state=STATE_START; int l=_buffer.getIndex()-_buffer.markIndex()-1; + progress++; _handler.onFrame((byte)0,_opcode,_buffer.sliceFromMark(l)); _buffer.setMarkIndex(-1); if (_buffer.length()==0) @@ -169,7 +171,7 @@ public class WebSocketParserD00 implements WebSocketParser _buffers.returnBuffer(_buffer); _buffer=null; } - return total_filled; + return progress; } continue; @@ -190,6 +192,7 @@ public class WebSocketParserD00 implements WebSocketParser Buffer data=_buffer.sliceFromMark(_length); _buffer.skip(_length); _state=STATE_START; + progress++; _handler.onFrame((byte)0, _opcode, data); if (_buffer.length()==0) @@ -198,7 +201,7 @@ public class WebSocketParserD00 implements WebSocketParser _buffer=null; } - return total_filled; + return progress; } } } diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java index d9a5cb55df5..0afb1dfae64 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/SafariWebsocketDraft0Test.java @@ -45,8 +45,8 @@ public class SafariWebsocketDraft0Test public static void initLogging() { // 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.util.log.class",StdErrLog.class.getName()); + // System.setProperty("org.eclipse.jetty.LEVEL","DEBUG"); } @Before @@ -74,11 +74,10 @@ public class SafariWebsocketDraft0Test } int port = conn.getLocalPort(); serverUri = new URI(String.format("ws://%s:%d/",host,port)); - System.out.printf("Server URI: %s%n",serverUri); + // System.out.printf("Server URI: %s%n",serverUri); } @Test - @Ignore public void testSendTextMessages() throws Exception { SafariD00 safari = new SafariD00(serverUri); @@ -106,7 +105,7 @@ public class SafariWebsocketDraft0Test } finally { - System.out.println("Closing client socket"); + // System.out.println("Closing client socket"); safari.disconnect(); } } diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java index 5df3119d474..19233d4d297 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/CaptureSocket.java @@ -41,7 +41,7 @@ public class CaptureSocket implements WebSocket, WebSocket.OnTextMessage public void onMessage(String data) { - System.out.printf("Received Message \"%s\" [size %d]%n", data, data.length()); + // System.out.printf("Received Message \"%s\" [size %d]%n", data, data.length()); messages.add(data); } diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java index d9731b3649c..244e71cdc2d 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/SafariD00.java @@ -80,7 +80,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); + // System.out.printf("--- Request ---%n%s",req); byte reqBytes[] = req.toString().getBytes("UTF-8"); byte hixieBytes[] = TypeUtil.fromHexString("e739617916c9daf3"); @@ -101,7 +101,7 @@ public class SafariD00 while (!foundEnd) { line = br.readLine(); - System.out.printf("RESP: %s%n",line); + // System.out.printf("RESP: %s%n",line); if (line.length() == 0) { foundEnd = true; From 070a2b5759882d6c8533cfb18c521fda3ea522b8 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Dec 2011 14:54:50 +1100 Subject: [PATCH 41/56] JETTY-1463 websocket D0 parser should return progress even if no fill done --- .../jetty/websocket/WebSocketParserD00Test.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD00Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD00Test.java index 3f22af55c6c..7e38a9b71ff 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD00Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketParserD00Test.java @@ -15,6 +15,7 @@ *******************************************************************************/ package org.eclipse.jetty.websocket; +import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.*; import java.util.ArrayList; @@ -61,7 +62,7 @@ public class WebSocketParserD00Test int filled =_parser.parseNext(); - assertEquals(13,filled); + assertThat(filled,greaterThan(0)); assertEquals("Hello World",_handler._data.get(0)); assertTrue(_parser.isBufferEmpty()); assertTrue(_parser.getBuffer()==null); @@ -79,14 +80,14 @@ public class WebSocketParserD00Test int filled =_parser.parseNext(); - assertEquals(30,filled); + assertThat(filled,greaterThan(0)); assertEquals("Hello World",_handler._data.get(0)); assertFalse(_parser.isBufferEmpty()); assertFalse(_parser.getBuffer()==null); filled =_parser.parseNext(); - assertEquals(0,filled); + assertThat(filled,greaterThan(0)); assertEquals("Hell\uFF4f W\uFF4Frld",_handler._data.get(1)); assertTrue(_parser.isBufferEmpty()); assertTrue(_parser.getBuffer()==null); @@ -101,7 +102,7 @@ public class WebSocketParserD00Test int filled =_parser.parseNext(); - assertEquals(13,filled); + assertThat(filled,greaterThan(0)); assertEquals("Hello World",_handler._data.get(0)); assertTrue(_parser.isBufferEmpty()); assertTrue(_parser.getBuffer()==null); @@ -123,15 +124,14 @@ public class WebSocketParserD00Test _in.put((byte)(data.length&0x7f)); _in.put(data); - int filled =_parser.parseNext(); - assertEquals(13+3+data.length,filled); + assertThat(filled,greaterThan(0)); assertEquals("Hello World",_handler._data.get(0)); assertFalse(_parser.isBufferEmpty()); assertFalse(_parser.getBuffer()==null); filled =_parser.parseNext(); - assertEquals(0,filled); + assertThat(filled,greaterThan(0)); String got=_handler._data.get(1); assertEquals(data.length,got.length()); assertTrue(got.startsWith("012345678901234567890123")); From ecb88f836eaa3ea2f4f6c5cca3e3af725911be75 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 20 Dec 2011 13:25:55 +0100 Subject: [PATCH 42/56] 367175 - SSL 100% CPU spin in case of blocked write and RST. --- .../jetty/client/SslBytesServerTest.java | 205 +++++++++++------- .../eclipse/jetty/client/SslBytesTest.java | 32 ++- .../eclipse/jetty/io/nio/SslConnection.java | 27 ++- 3 files changed, 171 insertions(+), 93 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java index 3c65f822e87..0976b5459c0 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java @@ -1,7 +1,5 @@ package org.eclipse.jetty.client; -import static org.hamcrest.Matchers.*; - import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -18,17 +16,18 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; 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; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.http.HttpParser; import org.eclipse.jetty.io.AsyncEndPoint; +import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffers; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; @@ -47,9 +46,13 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.lessThan; + public class SslBytesServerTest extends SslBytesTest { private final AtomicInteger sslHandles = new AtomicInteger(); + private final AtomicInteger sslFlushes = new AtomicInteger(); private final AtomicInteger httpParses = new AtomicInteger(); private ExecutorService threadPool; private Server server; @@ -75,6 +78,20 @@ public class SslBytesServerTest extends SslBytesTest sslHandles.incrementAndGet(); return super.handle(); } + + @Override + protected SslEndPoint newSslEndPoint() + { + return new SslEndPoint() + { + @Override + public int flush(Buffer buffer) throws IOException + { + sslFlushes.incrementAndGet(); + return super.flush(buffer); + } + }; + } }; } @@ -99,7 +116,7 @@ public class SslBytesServerTest extends SslBytesTest }; } }; - connector.setMaxIdleTime(2000); + connector.setMaxIdleTime(5000); // connector.setPort(5870); connector.setPort(0); @@ -119,9 +136,15 @@ public class SslBytesServerTest extends SslBytesTest if (contentLength != null) { int length = Integer.parseInt(contentLength); - ServletInputStream input = request.getInputStream(); + ServletInputStream input = httpRequest.getInputStream(); + ServletOutputStream output = httpResponse.getOutputStream(); + byte[] buffer = new byte[32 * 1024]; for (int i = 0; i < length; ++i) - input.read(); + { + int read = input.read(buffer); + if ("/echo".equals(target)) + output.write(buffer, 0, read); + } } } }); @@ -199,6 +222,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); closeClient(client); @@ -225,10 +249,8 @@ public class SslBytesServerTest extends SslBytesTest System.arraycopy(bytes, 0, chunk1, 0, chunk1.length); byte[] chunk2 = new byte[bytes.length - chunk1.length]; System.arraycopy(bytes, chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk1); - TimeUnit.MILLISECONDS.sleep(100); - proxy.flushToServer(chunk2); - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); + proxy.flushToServer(100, chunk2); // Server Hello + Certificate + Server Done record = proxy.readFromServer(); @@ -241,10 +263,8 @@ public class SslBytesServerTest extends SslBytesTest System.arraycopy(bytes, 0, chunk1, 0, chunk1.length); chunk2 = new byte[bytes.length - chunk1.length]; System.arraycopy(bytes, chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk1); - TimeUnit.MILLISECONDS.sleep(100); - proxy.flushToServer(chunk2); - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); + proxy.flushToServer(100, chunk2); // Change Cipher Spec record = proxy.readFromClient(); @@ -253,10 +273,8 @@ public class SslBytesServerTest extends SslBytesTest System.arraycopy(bytes, 0, chunk1, 0, chunk1.length); chunk2 = new byte[bytes.length - chunk1.length]; System.arraycopy(bytes, chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk1); - TimeUnit.MILLISECONDS.sleep(100); - proxy.flushToServer(chunk2); - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); + proxy.flushToServer(100, chunk2); // Client Done record = proxy.readFromClient(); @@ -265,10 +283,8 @@ public class SslBytesServerTest extends SslBytesTest System.arraycopy(bytes, 0, chunk1, 0, chunk1.length); chunk2 = new byte[bytes.length - chunk1.length]; System.arraycopy(bytes, chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk1); - TimeUnit.MILLISECONDS.sleep(100); - proxy.flushToServer(chunk2); - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); + proxy.flushToServer(100, chunk2); // Change Cipher Spec record = proxy.readFromServer(); @@ -284,6 +300,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); client.close(); @@ -295,10 +312,8 @@ public class SslBytesServerTest extends SslBytesTest System.arraycopy(bytes, 0, chunk1, 0, chunk1.length); chunk2 = new byte[bytes.length - chunk1.length]; System.arraycopy(bytes, chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk1); - TimeUnit.MILLISECONDS.sleep(100); - proxy.flushToServer(chunk2); - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); + proxy.flushToServer(100, chunk2); // Socket close record = proxy.readFromClient(); Assert.assertNull(String.valueOf(record), record); @@ -358,6 +373,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); closeClient(client); @@ -380,10 +396,7 @@ public class SslBytesServerTest extends SslBytesTest // Client Hello TLSRecord record = proxy.readFromClient(); for (byte b : record.getBytes()) - { - proxy.flushToServer(b); - TimeUnit.MILLISECONDS.sleep(50); - } + proxy.flushToServer(50, b); // Server Hello + Certificate + Server Done record = proxy.readFromServer(); @@ -392,26 +405,17 @@ public class SslBytesServerTest extends SslBytesTest // Client Key Exchange record = proxy.readFromClient(); for (byte b : record.getBytes()) - { - proxy.flushToServer(b); - TimeUnit.MILLISECONDS.sleep(50); - } + proxy.flushToServer(50, b); // Change Cipher Spec record = proxy.readFromClient(); for (byte b : record.getBytes()) - { - proxy.flushToServer(b); - TimeUnit.MILLISECONDS.sleep(50); - } + proxy.flushToServer(50, b); // Client Done record = proxy.readFromClient(); for (byte b : record.getBytes()) - { - proxy.flushToServer(b); - TimeUnit.MILLISECONDS.sleep(50); - } + proxy.flushToServer(50, b); // Change Cipher Spec record = proxy.readFromServer(); @@ -440,10 +444,7 @@ public class SslBytesServerTest extends SslBytesTest // Application data record = proxy.readFromClient(); for (byte b : record.getBytes()) - { - proxy.flushToServer(b); - TimeUnit.MILLISECONDS.sleep(50); - } + proxy.flushToServer(50, b); Assert.assertNull(request.get(5, TimeUnit.SECONDS)); // Application data @@ -463,6 +464,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(750)); + Assert.assertThat(sslFlushes.get(), lessThan(750)); Assert.assertThat(httpParses.get(), lessThan(150)); client.close(); @@ -470,10 +472,7 @@ public class SslBytesServerTest extends SslBytesTest // Close Alert record = proxy.readFromClient(); for (byte b : record.getBytes()) - { - proxy.flushToServer(b); - TimeUnit.MILLISECONDS.sleep(50); - } + proxy.flushToServer(50, b); // Socket close record = proxy.readFromClient(); Assert.assertNull(String.valueOf(record), record); @@ -587,6 +586,7 @@ public class SslBytesServerTest extends SslBytesTest // Application data TLSRecord record = proxy.readFromClient(); + Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType()); proxy.flushToServer(record); Assert.assertNull(request.get(5, TimeUnit.SECONDS)); @@ -594,6 +594,7 @@ public class SslBytesServerTest extends SslBytesTest // Close Alert record = proxy.readFromClient(); + Assert.assertEquals(TLSRecord.Type.ALERT, record.getType()); proxy.flushToServer(record); // Do not close the raw socket yet @@ -614,6 +615,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); // Socket close @@ -652,6 +654,7 @@ public class SslBytesServerTest extends SslBytesTest // Application data TLSRecord record = proxy.readFromClient(); + Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType()); proxy.flushToServer(record); Assert.assertNull(request.get(5, TimeUnit.SECONDS)); @@ -670,6 +673,64 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); + Assert.assertThat(httpParses.get(), lessThan(50)); + + client.close(); + } + + @Test + public void testRequestWithBigContentWriteBlockedAndResetException() throws Exception + { + final SSLSocket client = newClient(); + + SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow(); + client.startHandshake(); + Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS)); + + byte[] data = new byte[128 * 1024]; + Arrays.fill(data, (byte)'X'); + final String content = new String(data, "UTF-8"); + Future request = threadPool.submit(new Callable() + { + public Object call() throws Exception + { + OutputStream clientOutput = client.getOutputStream(); + clientOutput.write(("" + + "GET /echo HTTP/1.1\r\n" + + "Host: localhost\r\n" + + "Content-Length: " + content.length() + "\r\n" + + "\r\n" + + content).getBytes("UTF-8")); + clientOutput.flush(); + return null; + } + }); + + // Nine TLSRecords will be generated for the request + for (int i = 0; i < 9; ++i) + { + // Application data + TLSRecord record = proxy.readFromClient(); + Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType()); + proxy.flushToServer(record, 0); + } + Assert.assertNull(request.get(5, TimeUnit.SECONDS)); + + // We asked the server to echo back the data we sent + // but we do not read it, thus causing a write interest + // on the server. + // However, we then simulate that the client resets the + // connection, and this will cause an exception in the + // server that is trying to write the data + + proxy.resetServer(); + + // Wait a while to detect spinning + TimeUnit.SECONDS.sleep(1); + + Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); client.close(); @@ -713,13 +774,11 @@ public class SslBytesServerTest extends SslBytesTest byte[] bytes = new byte[dataBytes.length + closeBytes.length / 2]; System.arraycopy(dataBytes, 0, bytes, 0, dataBytes.length); System.arraycopy(closeBytes, 0, bytes, dataBytes.length, closeBytes.length / 2); - proxy.flushToServer(bytes); - - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, bytes); bytes = new byte[closeBytes.length - closeBytes.length / 2]; System.arraycopy(closeBytes, closeBytes.length / 2, bytes, 0, bytes.length); - proxy.flushToServer(bytes); + proxy.flushToServer(100, bytes); // Do not close the raw socket yet @@ -739,6 +798,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); // Socket close @@ -785,13 +845,11 @@ public class SslBytesServerTest extends SslBytesTest Assert.assertNull(request.get(5, TimeUnit.SECONDS)); byte[] chunk1 = new byte[2 * record.getBytes().length / 3]; System.arraycopy(record.getBytes(), 0, chunk1, 0, chunk1.length); - proxy.flushToServer(chunk1); - - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); byte[] chunk2 = new byte[record.getBytes().length - chunk1.length]; System.arraycopy(record.getBytes(), chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk2); + proxy.flushToServer(100, chunk2); record = proxy.readFromServer(); Assert.assertEquals(TLSRecord.Type.APPLICATION, record.getType()); @@ -809,6 +867,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); closeClient(client); @@ -855,14 +914,13 @@ public class SslBytesServerTest extends SslBytesTest System.arraycopy(bytes, 0, chunk1, 0, chunk1.length); byte[] chunk2 = new byte[bytes.length - chunk1.length]; System.arraycopy(bytes, chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk1); - TimeUnit.MILLISECONDS.sleep(100); - proxy.flushToServer(chunk2); - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); + proxy.flushToServer(100, chunk2); } // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(150)); Assert.assertNull(request.get(5, TimeUnit.SECONDS)); @@ -883,6 +941,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(150)); closeClient(client); @@ -1013,6 +1072,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); closeClient(client); @@ -1068,10 +1128,8 @@ public class SslBytesServerTest extends SslBytesTest System.arraycopy(bytes, 0, chunk1, 0, chunk1.length); byte[] chunk2 = new byte[bytes.length - chunk1.length]; System.arraycopy(bytes, chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk1); - TimeUnit.MILLISECONDS.sleep(100); - proxy.flushToServer(chunk2); - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); + proxy.flushToServer(100, chunk2); // Renegotiation Handshake record = proxy.readFromServer(); @@ -1108,10 +1166,8 @@ public class SslBytesServerTest extends SslBytesTest System.arraycopy(bytes, 0, chunk1, 0, chunk1.length); chunk2 = new byte[bytes.length - chunk1.length]; System.arraycopy(bytes, chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk1); - TimeUnit.MILLISECONDS.sleep(100); - proxy.flushToServer(chunk2); - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); + proxy.flushToServer(100, chunk2); // Renegotiation Handshake record = proxy.readFromClient(); @@ -1121,8 +1177,7 @@ public class SslBytesServerTest extends SslBytesTest System.arraycopy(bytes, 0, chunk1, 0, chunk1.length); chunk2 = new byte[bytes.length - chunk1.length]; System.arraycopy(bytes, chunk1.length, chunk2, 0, chunk2.length); - proxy.flushToServer(chunk1); - TimeUnit.MILLISECONDS.sleep(100); + proxy.flushToServer(100, chunk1); // Do not write the second chunk now, but merge it with content, see below Assert.assertNull(renegotiation.get(5, TimeUnit.SECONDS)); @@ -1146,7 +1201,7 @@ public class SslBytesServerTest extends SslBytesTest byte[] mergedBytes = new byte[chunk2.length + dataBytes.length]; System.arraycopy(chunk2, 0, mergedBytes, 0, chunk2.length); System.arraycopy(dataBytes, 0, mergedBytes, chunk2.length, dataBytes.length); - proxy.flushToServer(mergedBytes); + proxy.flushToServer(100, mergedBytes); // Write the remaining 2 TLS records for (int i = 0; i < 2; ++i) { @@ -1176,6 +1231,7 @@ public class SslBytesServerTest extends SslBytesTest // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(100)); closeClient(client); @@ -1251,7 +1307,7 @@ public class SslBytesServerTest extends SslBytesTest return client; } - private void closeClient(SSLSocket client) throws IOException + private void closeClient(SSLSocket client) throws Exception { client.close(); @@ -1271,5 +1327,4 @@ public class SslBytesServerTest extends SslBytesTest Assert.assertNull(String.valueOf(record), record); proxy.flushToClient(record); } - } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesTest.java index 4ad5c68c56f..4c8266180c4 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesTest.java @@ -199,7 +199,12 @@ public abstract class SslBytesTest return new TLSRecord(type, bytes); } - public void flushToServer(TLSRecord record) throws IOException + public void flushToServer(TLSRecord record) throws Exception + { + flushToServer(record, 100); + } + + public void flushToServer(TLSRecord record, long sleep) throws Exception { if (record == null) { @@ -212,20 +217,22 @@ public abstract class SslBytesTest } else { - flush(server, record.getBytes()); + flush(sleep, server, record.getBytes()); } } - public void flushToServer(byte... bytes) throws IOException + public void flushToServer(long sleep, byte... bytes) throws Exception { - flush(server, bytes); + flush(sleep, server, bytes); } - private void flush(Socket socket, byte... bytes) throws IOException + private void flush(long sleep, Socket socket, byte... bytes) throws Exception { OutputStream output = socket.getOutputStream(); output.write(bytes); output.flush(); + if (sleep > 0) + TimeUnit.MILLISECONDS.sleep(sleep); } public TLSRecord readFromServer() throws IOException @@ -235,7 +242,7 @@ public abstract class SslBytesTest return record; } - public void flushToClient(TLSRecord record) throws IOException + public void flushToClient(TLSRecord record) throws Exception { if (record == null) { @@ -248,7 +255,7 @@ public abstract class SslBytesTest } else { - flush(client, record.getBytes()); + flush(0, client, record.getBytes()); } } @@ -266,7 +273,7 @@ public abstract class SslBytesTest { while (true) { - flushToServer(readFromClient()); + flushToServer(readFromClient(), 0); } } catch (InterruptedIOException x) @@ -313,6 +320,15 @@ public abstract class SslBytesTest return latch.await(time, unit); } + public void resetServer() throws IOException + { + // Calling setSoLinger(true, 0) causes close() + // to send a RST instead of a FIN, causing an + // exception to be thrown on the other end + server.setSoLinger(true, 0); + server.close(); + } + public class AutomaticFlow { private final CountDownLatch stopLatch; diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index 2ee58ef249a..d859d126e10 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -50,7 +50,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection private final SSLEngine _engine; private final SSLSession _session; private AsyncConnection _connection; - private final SslEndPoint _sslEndPoint = new SslEndPoint(); + private final SslEndPoint _sslEndPoint; private int _allocations; private SslBuffers _buffers; private NIOBuffer _inbound; @@ -93,6 +93,12 @@ public class SslConnection extends AbstractConnection implements AsyncConnection _engine=engine; _session=_engine.getSession(); _aEndp=(AsyncEndPoint)endp; + _sslEndPoint = newSslEndPoint(); + } + + protected SslEndPoint newSslEndPoint() + { + return new SslEndPoint(); } /* ------------------------------------------------------------ */ @@ -308,12 +314,15 @@ public class SslConnection extends AbstractConnection implements AsyncConnection if (_outbound.hasContent() && (flushed=_endp.flush(_outbound))>0) progress = true; } - catch (Exception e) + catch (IOException e) { - LOG.debug(e.toString()); - LOG.ignore(e); + _endp.close(); + throw e; + } + finally + { + LOG.debug("{} {} {} filled={}/{} flushed={}/{}",_session,this,_engine.getHandshakeStatus(),filled,_inbound.length(),flushed,_outbound.length()); } - LOG.debug("{} {} {} filled={}/{} flushed={}/{}",_session,this,_engine.getHandshakeStatus(),filled,_inbound.length(),flushed,_outbound.length()); // handle the current hand share status switch(_engine.getHandshakeStatus()) @@ -435,7 +444,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection } catch(SSLException e) { - LOG.warn(_endp+":",e); + LOG.warn(String.valueOf(_endp), e); _endp.close(); throw e; } @@ -511,10 +520,8 @@ public class SslConnection extends AbstractConnection implements AsyncConnection } catch(SSLException e) { - LOG.warn(_endp+":"+e); - LOG.debug(e); - if (_endp.isOpen()) - _endp.close(); + LOG.warn(String.valueOf(_endp), e); + _endp.close(); throw e; } finally From 8ea22a6a4c3cc1d9aca7c7d3a2b1a4e1dacdfd29 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 20 Dec 2011 18:01:45 +0100 Subject: [PATCH 43/56] 367219 - WebSocketClient.open() fails when URI uses default ports. --- .../jetty/websocket/WebSocketClient.java | 13 ++-- .../jetty/websocket/WebSocketClientTest.java | 64 +++++++++++++++---- 2 files changed, 59 insertions(+), 18 deletions(-) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java index 52ed8a4ce80..cff7de04304 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java @@ -332,18 +332,23 @@ public class WebSocketClient { if (!_factory.isStarted()) throw new IllegalStateException("Factory !started"); - String scheme=uri.getScheme(); + String scheme = uri.getScheme(); if (!("ws".equalsIgnoreCase(scheme) || "wss".equalsIgnoreCase(scheme))) - throw new IllegalArgumentException("Bad WebSocket scheme '"+scheme+"'"); + throw new IllegalArgumentException("Bad WebSocket scheme: " + scheme); + int port = uri.getPort(); + if (port == 0) + throw new IllegalArgumentException("Bad WebSocket port: " + port); + if (port < 0) + port = "ws".equals(scheme) ? 80 : 443; SocketChannel channel = SocketChannel.open(); if (_bindAddress != null) channel.socket().bind(_bindAddress); channel.socket().setTcpNoDelay(true); - InetSocketAddress address=new InetSocketAddress(uri.getHost(),uri.getPort()); + InetSocketAddress address = new InetSocketAddress(uri.getHost(), port); - final WebSocketFuture holder=new WebSocketFuture(websocket,uri,this,channel); + WebSocketFuture holder = new WebSocketFuture(websocket, uri, this, channel); channel.configureBlocking(false); channel.connect(address); diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java index 79d6016978a..77639bf0c65 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java @@ -15,8 +15,6 @@ *******************************************************************************/ package org.eclipse.jetty.websocket; -import static org.hamcrest.Matchers.greaterThan; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -45,6 +43,8 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import static org.hamcrest.Matchers.greaterThan; + public class WebSocketClientTest { private WebSocketClientFactory _factory = new WebSocketClientFactory(); @@ -148,7 +148,6 @@ public class WebSocketClientTest Assert.assertFalse(open.get()); } - @Test public void testAsyncConnectionRefused() throws Exception { @@ -187,8 +186,6 @@ public class WebSocketClientTest } - - @Test public void testConnectionNotAccepted() throws Exception { @@ -266,7 +263,6 @@ public class WebSocketClientTest } - @Test public void testBadHandshake() throws Exception { @@ -424,7 +420,6 @@ public class WebSocketClientTest Assert.assertEquals(WebSocketConnectionRFC6455.CLOSE_NORMAL,close.get()); } - @Test public void testNotIdle() throws Exception { @@ -499,7 +494,6 @@ public class WebSocketClientTest Assert.assertEquals("Invalid close code 1111", closeMessage.toString()); } - @Test public void testBlockSending() throws Exception { @@ -581,18 +575,17 @@ public class WebSocketClientTest long writeDur = (System.currentTimeMillis() - start); // wait for consumer to complete - while (totalB.get() Date: Tue, 20 Dec 2011 13:01:23 -0700 Subject: [PATCH 44/56] 367219 - WebSocketClient.open() fails when URI uses default ports. + Fixing testcase to not fail if http://localhost/ exists. Reworking code to not rely on existence of server to validate the correct behavior of URI port parsing. --- .../jetty/websocket/WebSocketClient.java | 34 ++++++----- .../jetty/websocket/WebSocketClientTest.java | 56 ++++++------------- 2 files changed, 37 insertions(+), 53 deletions(-) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java index cff7de04304..cc5db438838 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketClient.java @@ -332,6 +332,25 @@ public class WebSocketClient { if (!_factory.isStarted()) throw new IllegalStateException("Factory !started"); + + InetSocketAddress address = toSocketAddress(uri); + + SocketChannel channel = SocketChannel.open(); + if (_bindAddress != null) + channel.socket().bind(_bindAddress); + channel.socket().setTcpNoDelay(true); + + WebSocketFuture holder = new WebSocketFuture(websocket, uri, this, channel); + + channel.configureBlocking(false); + channel.connect(address); + _factory.getSelectorManager().register(channel, holder); + + return holder; + } + + public static final InetSocketAddress toSocketAddress(URI uri) + { String scheme = uri.getScheme(); if (!("ws".equalsIgnoreCase(scheme) || "wss".equalsIgnoreCase(scheme))) throw new IllegalArgumentException("Bad WebSocket scheme: " + scheme); @@ -341,20 +360,8 @@ public class WebSocketClient if (port < 0) port = "ws".equals(scheme) ? 80 : 443; - SocketChannel channel = SocketChannel.open(); - if (_bindAddress != null) - channel.socket().bind(_bindAddress); - channel.socket().setTcpNoDelay(true); - InetSocketAddress address = new InetSocketAddress(uri.getHost(), port); - - WebSocketFuture holder = new WebSocketFuture(websocket, uri, this, channel); - - channel.configureBlocking(false); - channel.connect(address); - _factory.getSelectorManager().register(channel, holder); - - return holder; + return address; } /* ------------------------------------------------------------ */ @@ -486,6 +493,7 @@ public class WebSocketClient return _maskGen; } + @Override public String toString() { return "[" + _uri + ","+_websocket+"]@"+hashCode(); diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java index 77639bf0c65..2ab060ac239 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketClientTest.java @@ -15,12 +15,15 @@ *******************************************************************************/ package org.eclipse.jetty.websocket; +import static org.hamcrest.Matchers.*; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.ConnectException; +import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.URI; @@ -43,8 +46,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import static org.hamcrest.Matchers.greaterThan; - public class WebSocketClientTest { private WebSocketClientFactory _factory = new WebSocketClientFactory(); @@ -711,44 +712,19 @@ public class WebSocketClientTest @Test public void testURIWithDefaultPort() throws Exception { - WebSocketClient client = new WebSocketClient(_factory); - - try - { - client.open(new URI("ws://localhost"), new WebSocket() - { - public void onOpen(Connection connection) - { - } - - public void onClose(int closeCode, String message) - { - System.out.println("closeCode = " + closeCode); - } - }).get(5, TimeUnit.SECONDS); - } - catch (ExecutionException x) - { - Assert.assertTrue(x.getCause() instanceof ConnectException); - } - - try - { - client.open(new URI("wss://localhost"), new WebSocket() - { - public void onOpen(Connection connection) - { - } - - public void onClose(int closeCode, String message) - { - } - }).get(5, TimeUnit.SECONDS); - } - catch (ExecutionException x) - { - Assert.assertTrue(x.getCause() instanceof ConnectException); - } + URI uri = new URI("ws://localhost"); + InetSocketAddress addr = WebSocketClient.toSocketAddress(uri); + Assert.assertThat("URI (" + uri + ").host", addr.getHostName(), is("localhost")); + Assert.assertThat("URI (" + uri + ").port", addr.getPort(), is(80)); + } + + @Test + public void testURIWithDefaultWSSPort() throws Exception + { + URI uri = new URI("wss://localhost"); + InetSocketAddress addr = WebSocketClient.toSocketAddress(uri); + Assert.assertThat("URI (" + uri + ").host", addr.getHostName(), is("localhost")); + Assert.assertThat("URI (" + uri + ").port", addr.getPort(), is(443)); } private void respondToClient(Socket connection, String serverResponse) throws IOException From a606529710031eda5d971c2eb1ee40d31ba00a77 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 21 Dec 2011 10:06:55 +1100 Subject: [PATCH 45/56] 364921 SslConnection does real close on idle if already oshut --- .../jetty/client/SslBytesServerTest.java | 63 +++++++++++++++---- .../eclipse/jetty/io/nio/SslConnection.java | 5 +- 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java index 0976b5459c0..f2f04f738fc 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; +import java.net.SocketException; import java.net.SocketTimeoutException; import java.nio.channels.SocketChannel; import java.util.Arrays; @@ -14,6 +15,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.net.ssl.SSLContext; @@ -51,6 +53,8 @@ import static org.hamcrest.Matchers.lessThan; public class SslBytesServerTest extends SslBytesTest { + private final static int MAX_IDLE_TIME=5000; + private final AtomicInteger sslHandles = new AtomicInteger(); private final AtomicInteger sslFlushes = new AtomicInteger(); private final AtomicInteger httpParses = new AtomicInteger(); @@ -58,7 +62,8 @@ public class SslBytesServerTest extends SslBytesTest private Server server; private SSLContext sslContext; private SimpleProxy proxy; - + private final AtomicReference sslConnection = new AtomicReference(); + @Before public void init() throws Exception { @@ -70,7 +75,7 @@ public class SslBytesServerTest extends SslBytesTest @Override protected SslConnection newSslConnection(AsyncEndPoint endPoint, SSLEngine engine) { - return new SslConnection(engine, endPoint) + SslConnection connection = new SslConnection(engine, endPoint) { @Override public Connection handle() throws IOException @@ -93,6 +98,8 @@ public class SslBytesServerTest extends SslBytesTest }; } }; + sslConnection.set(connection); + return connection; } @Override @@ -116,7 +123,7 @@ public class SslBytesServerTest extends SslBytesTest }; } }; - connector.setMaxIdleTime(5000); + connector.setMaxIdleTime(MAX_IDLE_TIME); // connector.setPort(5870); connector.setPort(0); @@ -1237,7 +1244,6 @@ public class SslBytesServerTest extends SslBytesTest closeClient(client); } - @Ignore @Test public void testServerCloseClientDoesNotClose() throws Exception { @@ -1273,16 +1279,51 @@ public class SslBytesServerTest extends SslBytesTest break; } + // Check client is at EOF + Assert.assertEquals(-1,client.getInputStream().read()); + + // Client should close the socket, but let's hold it open. + // Check that we did not spin + TimeUnit.MILLISECONDS.sleep(100); Assert.assertThat(sslHandles.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); - - // TODO: instead of sleeping, we should expect the connection being closed by the idle timeout - // TODO: mechanism; unfortunately this now is not working, and this test fails because the idle - // TODO: timeout will not trigger. - TimeUnit.SECONDS.sleep(100); - - closeClient(client); + + // Check it is still half closed on the server. + Assert.assertTrue(((AsyncEndPoint)sslConnection.get().getEndPoint()).isOpen()); + Assert.assertTrue(((AsyncEndPoint)sslConnection.get().getEndPoint()).isOutputShutdown()); + Assert.assertFalse(((AsyncEndPoint)sslConnection.get().getEndPoint()).isInputShutdown()); + + // wait for a bit more than MAX_IDLE_TIME + TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME+1000); + + // Server should have closed the endpoint + Assert.assertFalse(((AsyncEndPoint)sslConnection.get().getEndPoint()).isOpen()); + Assert.assertTrue(((AsyncEndPoint)sslConnection.get().getEndPoint()).isOutputShutdown()); + Assert.assertTrue(((AsyncEndPoint)sslConnection.get().getEndPoint()).isInputShutdown()); + + + // writing to client will eventually get broken pipe exception or similar + try + { + for (int i=0;i<100;i++) + { + clientOutput.write(("" + + "POST / HTTP/1.1\r\n" + + "Host: localhost\r\n" + + "Content-Type: text/plain\r\n" + + "Content-Length: " + content.length() + "\r\n" + + "Connection: close\r\n" + + "\r\n" + + content).getBytes("UTF-8")); + clientOutput.flush(); + } + Assert.fail("Client should have seen server close"); + } + catch(SocketException e) + { + // this was expected. + } } private void assumeJavaVersionSupportsTLSRenegotiations() diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index d859d126e10..d9af5953ca4 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -249,7 +249,10 @@ public class SslConnection extends AbstractConnection implements AsyncConnection try { LOG.debug("onIdleExpired {}ms on {}",idleForMs,this); - _sslEndPoint.shutdownOutput(); + if (_endp.isOutputShutdown()) + _sslEndPoint.close(); + else + _sslEndPoint.shutdownOutput(); } catch (IOException e) { From 93a89026ce51bb8dc38cd44093365b2b62bdfc2b Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 21 Dec 2011 12:44:50 +1100 Subject: [PATCH 46/56] 364921 Improved timeout tests --- .../jetty/server/ConnectorTimeoutTest.java | 101 +++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java index 7b2e2b5650e..0b66eda2f93 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java @@ -15,21 +15,23 @@ package org.eclipse.jetty.server; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.matchers.JUnitMatchers.containsString; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; +import java.net.SocketException; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import junit.framework.Assert; - import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.IO; +import org.junit.Assert; import org.junit.Test; public abstract class ConnectorTimeoutTest extends HttpServerTestFixture @@ -103,6 +105,101 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture Assert.assertTrue(System.currentTimeMillis()-start>200); Assert.assertTrue(System.currentTimeMillis()-start<5000); } + + @Test + public void testMaxIdleWithRequest10NoClientClose() throws Exception + { + configureServer(new HelloWorldHandler()); + Socket client=newSocket(HOST,_connector.getLocalPort()); + client.setSoTimeout(10000); + + assertFalse(client.isClosed()); + + OutputStream os=client.getOutputStream(); + InputStream is=client.getInputStream(); + + os.write(( + "GET / HTTP/1.0\r\n"+ + "host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+ + "connection: close\r\n"+ + "\r\n").getBytes("utf-8")); + os.flush(); + + String result=IO.toString(is); + Assert.assertThat("OK",result,containsString("200 OK")); + assertEquals(-1, is.read()); + + TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME); + + // further writes will get broken pipe or similar + try + { + for (int i=0;i<100;i++) + { + os.write(( + "GET / HTTP/1.0\r\n"+ + "host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+ + "connection: keep-alive\r\n"+ + "\r\n").getBytes("utf-8")); + os.flush(); + } + Assert.fail("half close should have timed out"); + } + catch(SocketException e) + { + // expected + } + } + + @Test + public void testMaxIdleWithRequest11NoClientClose() throws Exception + { + configureServer(new EchoHandler()); + Socket client=newSocket(HOST,_connector.getLocalPort()); + client.setSoTimeout(10000); + + assertFalse(client.isClosed()); + + OutputStream os=client.getOutputStream(); + InputStream is=client.getInputStream(); + + String content="Wibble"; + byte[] contentB=content.getBytes("utf-8"); + os.write(( + "POST /echo HTTP/1.1\r\n"+ + "host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+ + "content-type: text/plain; charset=utf-8\r\n"+ + "content-length: "+contentB.length+"\r\n"+ + "connection: close\r\n"+ + "\r\n").getBytes("utf-8")); + os.write(contentB); + os.flush(); + + IO.toString(is); + + assertEquals(-1, is.read()); + + TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME); + + // further writes will get broken pipe or similar + try + { + for (int i=0;i<100;i++) + { + os.write(( + "GET / HTTP/1.0\r\n"+ + "host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+ + "connection: keep-alive\r\n"+ + "\r\n").getBytes("utf-8")); + os.flush(); + } + Assert.fail("half close should have timed out"); + } + catch(SocketException e) + { + // expected + } + } @Test From 2028bbb444196d7e1b9d5f1813e44aa47e099b2f Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 21 Dec 2011 12:57:33 +1100 Subject: [PATCH 47/56] JETTY-1465 NPE in ContextHandler.toString --- .../jetty/server/handler/ContextHandler.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 8af31771943..1ed28f49f64 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -1381,14 +1381,17 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. StringBuilder b = new StringBuilder(); - String p = getClass().getPackage().getName(); - if (p != null && p.length() > 0) + Package pkg = getClass().getPackage(); + if (pkg != null) { - String[] ss = p.split("\\."); - for (String s : ss) - b.append(s.charAt(0)).append('.'); + String p = pkg.getName(); + if (p != null && p.length() > 0) + { + String[] ss = p.split("\\."); + for (String s : ss) + b.append(s.charAt(0)).append('.'); + } } - b.append(getClass().getSimpleName()); b.append('{').append(getContextPath()).append(',').append(getBaseResource()); From 744f76f6c9cbcdeb7f458684ff62eb51afe96d81 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 21 Dec 2011 10:34:33 +0100 Subject: [PATCH 48/56] Added an idle timeout test. --- .../jetty/client/SslBytesServerTest.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java index 0976b5459c0..bf23762a14f 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java @@ -14,6 +14,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.net.ssl.SSLContext; @@ -54,6 +55,8 @@ public class SslBytesServerTest extends SslBytesTest private final AtomicInteger sslHandles = new AtomicInteger(); private final AtomicInteger sslFlushes = new AtomicInteger(); private final AtomicInteger httpParses = new AtomicInteger(); + private final AtomicReference serverEndPoint = new AtomicReference(); + private final int idleTimeout = 5000; private ExecutorService threadPool; private Server server; private SSLContext sslContext; @@ -70,6 +73,7 @@ public class SslBytesServerTest extends SslBytesTest @Override protected SslConnection newSslConnection(AsyncEndPoint endPoint, SSLEngine engine) { + serverEndPoint.set(endPoint); return new SslConnection(engine, endPoint) { @Override @@ -116,7 +120,7 @@ public class SslBytesServerTest extends SslBytesTest }; } }; - connector.setMaxIdleTime(5000); + connector.setMaxIdleTime(idleTimeout); // connector.setPort(5870); connector.setPort(0); @@ -1237,9 +1241,9 @@ public class SslBytesServerTest extends SslBytesTest closeClient(client); } - @Ignore + @Ignore // TODO: currently not passing @Test - public void testServerCloseClientDoesNotClose() throws Exception + public void testServerShutdownOutputClientDoesNotCloseServerCloses() throws Exception { final SSLSocket client = newClient(); final OutputStream clientOutput = client.getOutputStream(); @@ -1261,7 +1265,6 @@ public class SslBytesServerTest extends SslBytesTest "\r\n" + content).getBytes("UTF-8")); clientOutput.flush(); - Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS)); BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8")); String line = reader.readLine(); @@ -1272,15 +1275,19 @@ public class SslBytesServerTest extends SslBytesTest if (line.trim().length() == 0) break; } + Assert.assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS)); // Check that we did not spin Assert.assertThat(sslHandles.get(), lessThan(20)); + Assert.assertThat(sslFlushes.get(), lessThan(20)); Assert.assertThat(httpParses.get(), lessThan(50)); - // TODO: instead of sleeping, we should expect the connection being closed by the idle timeout - // TODO: mechanism; unfortunately this now is not working, and this test fails because the idle - // TODO: timeout will not trigger. - TimeUnit.SECONDS.sleep(100); + // The server has shutdown the output since the client sent a Connection: close + // but the client does not close, so the server must idle timeout the endPoint. + + TimeUnit.MILLISECONDS.sleep(idleTimeout + idleTimeout / 2); + + Assert.assertFalse(serverEndPoint.get().isOpen()); closeClient(client); } From b99e03c465e14160cc693e86f5d68c3dbbb9e3cf Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 22 Dec 2011 00:48:25 +1100 Subject: [PATCH 49/56] 364921 moved setCheckForIdle handling to AsyncHttpConnection --- .../org/eclipse/jetty/client/SslBytesServerTest.java | 5 +---- .../eclipse/jetty/io/nio/SelectChannelEndPoint.java | 12 ++---------- .../java/org/eclipse/jetty/io/nio/SslConnection.java | 1 + .../eclipse/jetty/server/AsyncHttpConnection.java | 10 ++++++++++ .../jetty/server/nio/SelectChannelConnector.java | 1 - 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java index 99b22b03089..0bb5b22f357 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java @@ -1241,7 +1241,6 @@ public class SslBytesServerTest extends SslBytesTest closeClient(client); } - @Ignore // TODO: currently not passing @Test public void testServerShutdownOutputClientDoesNotCloseServerCloses() throws Exception { @@ -1291,11 +1290,9 @@ public class SslBytesServerTest extends SslBytesTest // The server has shutdown the output since the client sent a Connection: close // but the client does not close, so the server must idle timeout the endPoint. - TimeUnit.MILLISECONDS.sleep(idleTimeout + idleTimeout / 2); + TimeUnit.MILLISECONDS.sleep(idleTimeout + idleTimeout/2); Assert.assertFalse(serverEndPoint.get().isOpen()); - - closeClient(client); } private void assumeJavaVersionSupportsTLSRenegotiations() diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 1f10532588f..ab5d9ff75c0 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -257,15 +257,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo getSelectSet().scheduleTimeout(task,timeoutMs); } - - /* ------------------------------------------------------------ */ - @Override - public boolean isOutputShutdown() - { - setCheckForIdle(true); - return super.isOutputShutdown(); - } - /* ------------------------------------------------------------ */ public void setCheckForIdle(boolean check) { @@ -289,10 +280,11 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo public void checkIdleTimestamp(long now) { long idleTimestamp=_idleTimestamp; - + if (idleTimestamp!=0 && _maxIdleTime>0) { long idleForMs=now-idleTimestamp; + if (idleForMs>_maxIdleTime) { onIdleExpired(idleForMs); diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index d9af5953ca4..1668e511ff7 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -599,6 +599,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection public void shutdownOutput() throws IOException { + System.err.println("OSHUT SSL"); synchronized (SslConnection.this) { LOG.debug("{} ssl endp.oshut {}",_session,this); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java index 8ec0737e5a7..1ddedf015aa 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java @@ -54,6 +54,10 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async try { setCurrentConnection(this); + + // don't check for idle while dispatched (unless blocking IO is done). + _asyncEndp.setCheckForIdle(false); + // While progress and the connection has not changed while (progress && connection==this) @@ -133,10 +137,16 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async finally { setCurrentConnection(null); + + // If we are not suspended if (!_request.isAsyncStarted()) { + // return buffers _parser.returnBuffers(); _generator.returnBuffers(); + + // resuming checking for idle + _asyncEndp.setCheckForIdle(true); } // Safety net to catch spinning diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java index 998dc76638d..b6165d45fdf 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java @@ -122,7 +122,6 @@ public class SelectChannelConnector extends AbstractNIOConnector public void customize(EndPoint endpoint, Request request) throws IOException { AsyncEndPoint aEndp = ((AsyncEndPoint)endpoint); - aEndp.setCheckForIdle(false); request.setTimeStamp(System.currentTimeMillis()); endpoint.setMaxIdleTime(_maxIdleTime); super.customize(endpoint, request); From 7b2a0cb5024e1c1c5dc3f5c27fb84f6a693b320e Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 22 Dec 2011 00:53:33 +1100 Subject: [PATCH 50/56] 364921 removed debug --- .../src/main/java/org/eclipse/jetty/io/nio/SslConnection.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index 1668e511ff7..d9af5953ca4 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -599,7 +599,6 @@ public class SslConnection extends AbstractConnection implements AsyncConnection public void shutdownOutput() throws IOException { - System.err.println("OSHUT SSL"); synchronized (SslConnection.this) { LOG.debug("{} ssl endp.oshut {}",_session,this); From 8981176dda3eac8db537c3894a31d9d86305c2f7 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 21 Dec 2011 14:12:25 -0600 Subject: [PATCH 51/56] remove snapshot repo to see if that resolves issue with p2 snapshot build --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index d72b94869ac..63315d4c21c 100644 --- a/pom.xml +++ b/pom.xml @@ -311,6 +311,7 @@ + jetty-util jetty-jmx From f8cd2e9a0c8a62cb6ed2d9202560725385f16a97 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 22 Dec 2011 17:34:19 +1100 Subject: [PATCH 52/56] 365947 Set headers for Auth failure and retry in http-spi --- .../jetty/http/spi/HttpSpiContextHandler.java | 16 ++++- .../eclipse/jetty/http/spi/TestSPIServer.java | 71 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/TestSPIServer.java diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/HttpSpiContextHandler.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/HttpSpiContextHandler.java index 62c30cac169..7cf80112400 100644 --- a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/HttpSpiContextHandler.java +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/HttpSpiContextHandler.java @@ -15,6 +15,8 @@ package org.eclipse.jetty.http.spi; import java.io.IOException; import java.io.PrintWriter; +import java.util.List; +import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -25,6 +27,7 @@ import org.eclipse.jetty.server.handler.ContextHandler; import com.sun.net.httpserver.Authenticator; import com.sun.net.httpserver.Authenticator.Result; +import com.sun.net.httpserver.BasicAuthenticator; import com.sun.net.httpserver.HttpContext; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; @@ -108,12 +111,23 @@ public class HttpSpiContextHandler extends ContextHandler if (result instanceof Authenticator.Failure) { int rc = ((Authenticator.Failure)result).getResponseCode(); + for (Map.Entry> header : httpExchange.getResponseHeaders().entrySet()) + { + for (String value : header.getValue()) + resp.addHeader(header.getKey(),value); + } resp.sendError(rc); } else if (result instanceof Authenticator.Retry) { int rc = ((Authenticator.Retry)result).getResponseCode(); - resp.sendError(rc); + for (Map.Entry> header : httpExchange.getResponseHeaders().entrySet()) + { + for (String value : header.getValue()) + resp.addHeader(header.getKey(),value); + } + resp.setStatus(rc); + resp.flushBuffer(); } else if (result instanceof Authenticator.Success) { diff --git a/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/TestSPIServer.java b/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/TestSPIServer.java new file mode 100644 index 00000000000..27110811a61 --- /dev/null +++ b/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/TestSPIServer.java @@ -0,0 +1,71 @@ +package org.eclipse.jetty.http.spi; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import com.sun.net.httpserver.BasicAuthenticator; +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpContext; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; + + +public class TestSPIServer +{ + public static void main(String[] args) throws Exception + { + String host="localhost"; + int port = 8080; + + HttpServer server = new JettyHttpServerProvider().createHttpServer(new + InetSocketAddress(host, port), 10); + server.start(); + + final HttpContext httpContext = server.createContext("/", + new HttpHandler() + { + + @Override + public void handle(HttpExchange exchange) throws IOException + { + Headers responseHeaders = exchange.getResponseHeaders(); + responseHeaders.set("Content-Type","text/plain"); + exchange.sendResponseHeaders(200,0); + + OutputStream responseBody = exchange.getResponseBody(); + Headers requestHeaders = exchange.getRequestHeaders(); + Set keySet = requestHeaders.keySet(); + Iterator iter = keySet.iterator(); + while (iter.hasNext()) + { + String key = iter.next(); + List values = requestHeaders.get(key); + String s = key + " = " + values.toString() + "\n"; + responseBody.write(s.getBytes()); + } + responseBody.close(); + + } + }); + + httpContext.setAuthenticator(new BasicAuthenticator("Test") + { + @Override + public boolean checkCredentials(String username, String password) + { + if ("username".equals(username) && password.equals("password")) + return true; + return false; + } + }); + + + Thread.sleep(10000000); + + } +} From 6a967ff2fe42592110928b0fde20bfac99cf859d Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 22 Dec 2011 07:02:05 -0600 Subject: [PATCH 53/56] Skip two failing unit tests on mac and windows for the time being, tests are commented on what the underlying open question is --- .../jetty/client/SslBytesServerTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java index 0bb5b22f357..abcdce4d001 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesServerTest.java @@ -39,6 +39,7 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.toolchain.test.OS; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.After; import org.junit.Assert; @@ -568,6 +569,21 @@ public class SslBytesServerTest extends SslBytesTest @Test public void testRequestWithCloseAlert() throws Exception { + if ( !OS.IS_LINUX ) + { + // currently we are ignoring this test on anything other then linux + + //http://tools.ietf.org/html/rfc2246#section-7.2.1 + + // TODO (react to this portion which seems to allow win/mac behavior) + //It is required that the other party respond with a close_notify alert of its own + //and close down the connection immediately, discarding any pending writes. It is not + //required for the initiator of the close to wait for the responding + //close_notify alert before closing the read side of the connection. + return; + } + + final SSLSocket client = newClient(); SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow(); @@ -743,6 +759,20 @@ public class SslBytesServerTest extends SslBytesTest @Test public void testRequestWithCloseAlertWithSplitBoundary() throws Exception { + if ( !OS.IS_LINUX ) + { + // currently we are ignoring this test on anything other then linux + + //http://tools.ietf.org/html/rfc2246#section-7.2.1 + + // TODO (react to this portion which seems to allow win/mac behavior) + //It is required that the other party respond with a close_notify alert of its own + //and close down the connection immediately, discarding any pending writes. It is not + //required for the initiator of the close to wait for the responding + //close_notify alert before closing the read side of the connection. + return; + } + final SSLSocket client = newClient(); SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow(); From 31471e11cc898daf1f49ddc1b1f0b7e931adb553 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 23 Dec 2011 00:35:32 +1100 Subject: [PATCH 54/56] 364921 Made test less time sensitive --- .../jetty/server/ConnectorTimeoutTest.java | 72 +++++++++++++++++-- 1 file changed, 65 insertions(+), 7 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java index 0ffb90f5269..96445f1fcf5 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java @@ -18,12 +18,14 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.net.SocketException; +import java.util.concurrent.Exchanger; import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.IO; import org.junit.Assert; @@ -108,7 +110,23 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture @Test public void testMaxIdleWithRequest10NoClientClose() throws Exception { - configureServer(new HelloWorldHandler()); + final Exchanger endpoint = new Exchanger(); + configureServer(new HelloWorldHandler() + { + @Override + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, + ServletException + { + try + { + endpoint.exchange(baseRequest.getConnection().getEndPoint()); + } + catch(Exception e) + {} + super.handle(target,baseRequest,request,response); + } + + }); Socket client=newSocket(HOST,_connector.getLocalPort()); client.setSoTimeout(10000); @@ -124,16 +142,29 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture "\r\n").getBytes("utf-8")); os.flush(); + // Get the server side endpoint + EndPoint endp = endpoint.exchange(null,10,TimeUnit.SECONDS); + + // read the response String result=IO.toString(is); Assert.assertThat("OK",result,containsString("200 OK")); + + // check the server side is open and oshut and that client reads EOF + Assert.assertTrue(endp.isOpen()); + Assert.assertTrue(endp.isOutputShutdown()); + Assert.assertFalse(endp.isInputShutdown()); assertEquals(-1, is.read()); - TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME); + // wait for idle timeout + TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME+MAX_IDLE_TIME/2); + // check the server side is closed + Assert.assertFalse(endp.isOpen()); + // further writes will get broken pipe or similar try { - for (int i=0;i<100;i++) + for (int i=0;i<1000;i++) { os.write(( "GET / HTTP/1.0\r\n"+ @@ -153,7 +184,23 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture @Test public void testMaxIdleWithRequest11NoClientClose() throws Exception { - configureServer(new EchoHandler()); + final Exchanger endpoint = new Exchanger(); + configureServer(new EchoHandler() + { + @Override + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, + ServletException + { + try + { + endpoint.exchange(baseRequest.getConnection().getEndPoint()); + } + catch(Exception e) + {} + super.handle(target,baseRequest,request,response); + } + + }); Socket client=newSocket(HOST,_connector.getLocalPort()); client.setSoTimeout(10000); @@ -173,17 +220,28 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture "\r\n").getBytes("utf-8")); os.write(contentB); os.flush(); - + + // Get the server side endpoint + EndPoint endp = endpoint.exchange(null,10,TimeUnit.SECONDS); + + // read the response IO.toString(is); + // check the server side is open and oshut and that client reads EOF + Assert.assertTrue(endp.isOpen()); + Assert.assertTrue(endp.isOutputShutdown()); + Assert.assertFalse(endp.isInputShutdown()); assertEquals(-1, is.read()); - TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME); + TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME+MAX_IDLE_TIME/2); + // check the server side is closed + Assert.assertFalse(endp.isOpen()); + // further writes will get broken pipe or similar try { - for (int i=0;i<100;i++) + for (int i=0;i<1000;i++) { os.write(( "GET / HTTP/1.0\r\n"+ From b4ab738ca9e6b97df2dafdeb2d625bf1c9bdae33 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 23 Dec 2011 00:57:26 +1100 Subject: [PATCH 55/56] 364921 Made test less time sensitive for ssl --- .../org/eclipse/jetty/io/nio/SslConnection.java | 8 ++++++++ .../eclipse/jetty/server/ConnectorTimeoutTest.java | 13 +++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index d9af5953ca4..876db22112d 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -96,6 +96,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection _sslEndPoint = newSslEndPoint(); } + /* ------------------------------------------------------------ */ protected SslEndPoint newSslEndPoint() { return new SslEndPoint(); @@ -583,6 +584,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection return _sslEndPoint; } + /* ------------------------------------------------------------ */ public String toString() { return String.format("%s %s", super.toString(), _sslEndPoint); @@ -596,6 +598,11 @@ public class SslConnection extends AbstractConnection implements AsyncConnection { return _engine; } + + public AsyncEndPoint getEndpoint() + { + return _aEndp; + } public void shutdownOutput() throws IOException { @@ -822,5 +829,6 @@ public class SslConnection extends AbstractConnection implements AsyncConnection _ishut, _oshut, _connection); } + } } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java index 96445f1fcf5..996d1f0a560 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java @@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.io.nio.SslConnection; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.IO; import org.junit.Assert; @@ -144,15 +145,14 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture // Get the server side endpoint EndPoint endp = endpoint.exchange(null,10,TimeUnit.SECONDS); + if (endp instanceof SslConnection.SslEndPoint) + endp=((SslConnection.SslEndPoint)endp).getEndpoint(); // read the response String result=IO.toString(is); Assert.assertThat("OK",result,containsString("200 OK")); - // check the server side is open and oshut and that client reads EOF - Assert.assertTrue(endp.isOpen()); - Assert.assertTrue(endp.isOutputShutdown()); - Assert.assertFalse(endp.isInputShutdown()); + // check client reads EOF assertEquals(-1, is.read()); // wait for idle timeout @@ -227,10 +227,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture // read the response IO.toString(is); - // check the server side is open and oshut and that client reads EOF - Assert.assertTrue(endp.isOpen()); - Assert.assertTrue(endp.isOutputShutdown()); - Assert.assertFalse(endp.isInputShutdown()); + // check client reads EOF assertEquals(-1, is.read()); TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME+MAX_IDLE_TIME/2); From a4bba4f99cb75faf015778b9bd1930307a9b3c85 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 23 Dec 2011 01:23:59 +1100 Subject: [PATCH 56/56] 364921 Made test less time sensitive for ssl --- .../org/eclipse/jetty/server/ConnectorTimeoutTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java index 996d1f0a560..f01dfc831a8 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java @@ -158,8 +158,6 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture // wait for idle timeout TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME+MAX_IDLE_TIME/2); - // check the server side is closed - Assert.assertFalse(endp.isOpen()); // further writes will get broken pipe or similar try @@ -179,6 +177,8 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture { // expected } + // check the server side is closed + Assert.assertFalse(endp.isOpen()); } @Test @@ -232,8 +232,6 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture TimeUnit.MILLISECONDS.sleep(MAX_IDLE_TIME+MAX_IDLE_TIME/2); - // check the server side is closed - Assert.assertFalse(endp.isOpen()); // further writes will get broken pipe or similar try @@ -253,6 +251,9 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture { // expected } + + // check the server side is closed + Assert.assertFalse(endp.isOpen()); }