diff --git a/LICENSE-CONTRIBUTOR/cla-tbecker.txt b/LICENSE-CONTRIBUTOR/cla-tbecker.txt new file mode 100644 index 00000000000..8a44e3614f2 --- /dev/null +++ b/LICENSE-CONTRIBUTOR/cla-tbecker.txt @@ -0,0 +1,145 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Jetty Project +Contributor License Agreement V1.0 +based on http://www.apache.org/licenses/ + +Thank you for your interest in the Jetty project by Mort Bay +Consulting Pty. Ltd. Australia ("MortBay"). +In order to clarify the intellectual property license +granted with Contributions from any person or entity, MortBay +must have a Contributor License Agreement ("CLA") that has +been signed by each Contributor, indicating agreement to the license +terms below. This license is for your protection as a Contributor as +well as the protection of MortBay and its users; it does not +change your rights to use your own Contributions for any other +purpose. + +If you have not already done so, please complete this agreement +and commit it to the Jetty repository at +svn+ssh://svn.jetty.codehaus.org/home/projects/jetty/scm/jetty +at legal/cla-USERNAME.txt using your authenticated codehaus ssh +login. If you do not have commit privilege to the repository, please +email the file to eclipse@eclipse.com. If possible, digitally sign +the committed file, otherwise also send a signed Agreement to MortBay. + +Please read this document carefully before signing and keep a copy for +your records. + + Full name: Thomas Becker + E-Mail: thomas.becker00@googlemail.com + Mailing Address: + +You accept and agree to the following terms and conditions for Your +present and future Contributions submitted to MortBay. In return, +MortBay shall not use Your Contributions in a way that is contrary +to the software license in effect at the time of the Contribution. +Except for the license granted herein to MortBay and recipients of +software distributed by MortBay, You reserve all right, title, and +interest in and to Your Contributions. + +1. Definitions. + + "You" (or "Your") shall mean the copyright owner or legal entity + authorized by the copyright owner that is making this Agreement + with MortBay. For legal entities, the entity making a + Contribution and all other entities that control, are controlled + by, or are under common control with that entity are considered to + be a single Contributor. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "Contribution" shall mean any original work of authorship, + including any modifications or additions to an existing work, that + is intentionally submitted by You to MortBay for inclusion + in, or documentation of, any of the products owned or managed by + MortBay (the "Work"). For the purposes of this definition, + "submitted" means any form of electronic, verbal, or written + communication sent to MortBay or its representatives, + including but not limited to communication on electronic mailing + lists, source code control systems, and issue tracking systems that + are managed by, or on behalf of, MortBay for the purpose of + discussing and improving the Work, but excluding communication that + is conspicuously marked or otherwise designated in writing by You + as "Not a Contribution." + +2. Grant of Copyright License. Subject to the terms and conditions of + this Agreement, You hereby grant to MortBay and to + recipients of software distributed by MortBay a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare derivative works of, + publicly display, publicly perform, sublicense, and distribute Your + Contributions and such derivative works. + +3. Grant of Patent License. Subject to the terms and conditions of + this Agreement, You hereby grant to MortBay and to + recipients of software distributed by MortBay a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have + made, use, offer to sell, sell, import, and otherwise transfer the + Work, where such license applies only to those patent claims + licensable by You that are necessarily infringed by Your + Contribution(s) alone or by combination of Your Contribution(s) + with the Work to which such Contribution(s) was submitted. If any + entity institutes patent litigation against You or any other entity + (including a cross-claim or counterclaim in a lawsuit) alleging + that your Contribution, or the Work to which you have contributed, + constitutes direct or contributory patent infringement, then any + patent licenses granted to that entity under this Agreement for + that Contribution or Work shall terminate as of the date such + litigation is filed. + +4. You represent that you are legally entitled to grant the above + license. If your employer(s) has rights to intellectual property + that you create that includes your Contributions, you represent + that you have received permission to make Contributions on behalf + of that employer, that your employer has waived such rights for + your Contributions to MortBay, or that your employer has + executed a separate Corporate CLA with MortBay. + +5. You represent that each of Your Contributions is Your original + creation (see section 7 for submissions on behalf of others). You + represent that Your Contribution submissions include complete + details of any third-party license or other restriction (including, + but not limited to, related patents and trademarks) of which you + are personally aware and which are associated with any part of Your + Contributions. + +6. You are not expected to provide support for Your Contributions, + except to the extent You desire to provide support. You may provide + support for free, for a fee, or not at all. Unless required by + applicable law or agreed to in writing, You provide Your + Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied, including, without + limitation, any warranties or conditions of TITLE, NON- + INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. + +7. Should You wish to submit work that is not Your original creation, + You may submit it to MortBay separately from any + Contribution, identifying the complete details of its source and of + any license or other restriction (including, but not limited to, + related patents, trademarks, and license agreements) of which you + are personally aware, and conspicuously marking the work as + "Submitted on behalf of a third-party: [named here]". + +8. You agree to notify MortBay of any facts or circumstances of + which you become aware that would make these representations + inaccurate in any respect. + +Date: 2012-07-17 +Please sign: + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.10 (GNU/Linux) + +iQEcBAEBAgAGBQJQBb4tAAoJEMHhjBmtgF91HDcH/2nQDPuPztWFrBifnEoLF6Jl +RUkfJzAPZaLDtDMfiDz7ucdRL1RDodmz4VIF2+fbKeBYQquZXfXIeEghz+tKriK3 +0M12guFkNLDteQp9h2p3Zu9JU3K0y4m84IDWq72HRmh1nRyD6lzZFhDGZ/D+69fF +tgYG0FwEit00MAq/lRbsXHLpBOY+Jyh/Xy+QRnQTcAQ+tAgOlxds3w+JSs2sGdes +YLAJQQacLeGh7EzD3F+CKuiwT4c5ub64LdXSlAVj1u2OjZBfqLaJ3FA60Ti+I3kn +FNWKpzaeX+SQgMak6hsuatXi6EsVk6sIaskwEgl6+Xk+HYWy23ZQ8BKQRLKOZTw= +=gAqN +-----END PGP SIGNATURE----- diff --git a/README.txt b/README.txt index 3412f8ff169..412eb3a4426 100644 --- a/README.txt +++ b/README.txt @@ -3,8 +3,8 @@ This is a source checkout of the Jetty webserver. To build, use: - mvn install - + mvn clean install + The jetty distribution will be built in jetty-distribution/target/distribution @@ -12,8 +12,11 @@ The jetty distribution will be built in The first build may take a long time as Maven downloads all the dependencies. -The tests do a lot of stress testing, and on some machines it is +The tests do a lot of stress testing, and on some machines it is necessary to set the file descriptor limit to greater than 2048 -for the tests to all pass successfully. +for the tests to all pass successfully. + +Bypass tests by building with -Dmaven.test.skip=true but note +that this will not produce some test jars that are leveraged +in other places in the build. -Bypass tests by building with -Dmaven.test.skip=true but note that this will not produce some test jars that are leveraged in other places in the build. diff --git a/VERSION.txt b/VERSION.txt index 0b4ca594f5f..09c3a3d7a65 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,4 +1,30 @@ -jetty-7.6.5-SNAPSHOT +jetty-7.6.6-SNAPSHOT + +jetty-7.6.5.v20120716 - 16 July 2012 + + 376717 Balancer Servlet with round robin support, contribution, added + missing license + + 379250 Server is added to shutdown hook twice + + 380866 maxIdleTime set to 0 after session migration + + 381399 Unable to stop a jetty instance that has not finished starting + + 381401 Print log warning when stop attempt made with incorrect STOP.KEY + + 381402 Make ContextHandler take set of protected directories + + 381521 set Vary:Accept-Encoding header for content that might be compressed + + 381639 CrossOriginFilter does not support Access-Control-Expose-Headers. + + 381712 Support all declared servlets that implement + org.apache.jasper.servlet.JspServlet + + 381825 leave URI params in forwarded requestURI + + 381876 Monitor should wait for child to finish before exiting. + + 382343 Jetty XML support for Map is broken. + + 383251 500 for SocketExceptions + + 383881 WebSocketHandler sets request as handled + + 384254 revert change to writable when not dispatched + + 384847 CrossOriginFilter is not working. + + 384896 JDBCSessionManager fails to load existing sessions on oracle when + contextPath is / + + 384980 Jetty client unable to recover from Time outs when connection count + per address hits max. + + JETTY-1525 Show handle status in response debug message + + JETTY-1530 refine search control on ldap login module jetty-7.6.4.v20120524 - 24 May 2012 + 367608 ignore the aysncrequestreadtest as it is known to fail and is waiting diff --git a/example-jetty-embedded/pom.xml b/example-jetty-embedded/pom.xml index 49b6f185ffb..67db74a4bfb 100644 --- a/example-jetty-embedded/pom.xml +++ b/example-jetty-embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 example-jetty-embedded diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java index 428a1dbbf6b..4c2429e68d1 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.embedded; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.resource.Resource; diff --git a/jetty-aggregate/jetty-all-server/pom.xml b/jetty-aggregate/jetty-all-server/pom.xml index 87fb9c21ef7..f46c19b108a 100644 --- a/jetty-aggregate/jetty-all-server/pom.xml +++ b/jetty-aggregate/jetty-all-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-all-server diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index f0df1efb899..bfd8b672973 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-all diff --git a/jetty-aggregate/jetty-client/pom.xml b/jetty-aggregate/jetty-client/pom.xml index 75feea5ec65..71b83673298 100644 --- a/jetty-aggregate/jetty-client/pom.xml +++ b/jetty-aggregate/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-client diff --git a/jetty-aggregate/jetty-plus/pom.xml b/jetty-aggregate/jetty-plus/pom.xml index 1d00a213aee..15c9be179e5 100644 --- a/jetty-aggregate/jetty-plus/pom.xml +++ b/jetty-aggregate/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-plus diff --git a/jetty-aggregate/jetty-server/pom.xml b/jetty-aggregate/jetty-server/pom.xml index 9c0cfbdcbb1..158f6178f6b 100644 --- a/jetty-aggregate/jetty-server/pom.xml +++ b/jetty-aggregate/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-server diff --git a/jetty-aggregate/jetty-servlet/pom.xml b/jetty-aggregate/jetty-servlet/pom.xml index f866c2a2fd2..61fcb697473 100644 --- a/jetty-aggregate/jetty-servlet/pom.xml +++ b/jetty-aggregate/jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-servlet diff --git a/jetty-aggregate/jetty-webapp/pom.xml b/jetty-aggregate/jetty-webapp/pom.xml index 1703390fa54..e7484bce5cf 100644 --- a/jetty-aggregate/jetty-webapp/pom.xml +++ b/jetty-aggregate/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-webapp diff --git a/jetty-aggregate/jetty-websocket/pom.xml b/jetty-aggregate/jetty-websocket/pom.xml index ce1e0341840..9fe26d781f7 100644 --- a/jetty-aggregate/jetty-websocket/pom.xml +++ b/jetty-aggregate/jetty-websocket/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-websocket diff --git a/jetty-aggregate/pom.xml b/jetty-aggregate/pom.xml index 4dd94ad4aa4..da4200a24be 100644 --- a/jetty-aggregate/pom.xml +++ b/jetty-aggregate/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT org.eclipse.jetty.aggregate jetty-aggregate-project diff --git a/jetty-ajp/pom.xml b/jetty-ajp/pom.xml index fb027084702..5c54cbc47d8 100644 --- a/jetty-ajp/pom.xml +++ b/jetty-ajp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-ajp diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index 6163d20f0fd..ae6aae2ffd2 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-annotations diff --git a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/Multi.java b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/Multi.java index 36cbe8e24d2..790d2702cd1 100644 --- a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/Multi.java +++ b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/Multi.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.annotations; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/resources/TestResourceAnnotations.java b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/resources/TestResourceAnnotations.java index 451e899b95f..66ebc5a20fc 100644 --- a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/resources/TestResourceAnnotations.java +++ b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/resources/TestResourceAnnotations.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.annotations.resources; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.lang.reflect.Field; import java.util.List; diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index 878073e5b7a..edde246613e 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/CachedHeadersIsolationTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/CachedHeadersIsolationTest.java index 8a599808386..0cfdecb680e 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/CachedHeadersIsolationTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/CachedHeadersIsolationTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/Curl.java b/jetty-client/src/test/java/org/eclipse/jetty/client/Curl.java index 6c4d5102709..5f44036c08f 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/Curl.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/Curl.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; import java.util.concurrent.CountDownLatch; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ExpirationWithLimitedConnectionsTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ExpirationWithLimitedConnectionsTest.java new file mode 100644 index 00000000000..05b20fda9e9 --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ExpirationWithLimitedConnectionsTest.java @@ -0,0 +1,192 @@ +// ======================================================================== +// Copyright 2012-2012 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + +package org.eclipse.jetty.client; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; + +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; +import org.junit.Assert; +import org.junit.Test; +import org.junit.Ignore; + +public class ExpirationWithLimitedConnectionsTest +{ + @Ignore + public void testExpirationWithMaxConnectionPerAddressReached() throws Exception + { + final Logger logger = Log.getLogger("org.eclipse.jetty.client"); + logger.setDebugEnabled(true); + + HttpClient client = new HttpClient(); + int maxConnectionsPerAddress = 10; + client.setMaxConnectionsPerAddress(maxConnectionsPerAddress); + long timeout = 1000; + client.setTimeout(timeout); + client.start(); + + final List sockets = new CopyOnWriteArrayList(); + final List failures = new CopyOnWriteArrayList(); + final AtomicLong processingDelay = new AtomicLong(200); + + final ExecutorService threadPool = Executors.newCachedThreadPool(); + final ServerSocket server = new ServerSocket(0); + threadPool.submit(new Runnable() + { + public void run() + { + while (true) + { + try + { + final Socket socket = server.accept(); + sockets.add(socket); + logger.debug("CONNECTION {}", socket.getRemoteSocketAddress()); + threadPool.submit(new Runnable() + { + public void run() + { + while (true) + { + try + { + BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8")); + String firstLine = reader.readLine(); + String line = firstLine; + while (line != null) + { + if (line.length() == 0) + break; + line = reader.readLine(); + } + + if (line == null) + break; + + long sleep = processingDelay.get(); + logger.debug("{} {} {} ms", firstLine, socket.getRemoteSocketAddress(), sleep); + TimeUnit.MILLISECONDS.sleep(sleep); + + String response = "" + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 0\r\n" + + "\r\n"; + OutputStream output = socket.getOutputStream(); + output.write(response.getBytes("UTF-8")); + output.flush(); + } + catch (Exception x) + { + failures.add(x); + break; + } + } + } + }); + } + catch (Exception x) + { + failures.add(x); + break; + } + } + } + }); + + List exchanges = new ArrayList(); + + final AtomicBoolean firstExpired = new AtomicBoolean(); + int count = 0; + int maxAdditionalRequest = 100; + int additionalRequests = 0; + while (true) + { + TimeUnit.MILLISECONDS.sleep(1); // Just avoid being too fast + ContentExchange exchange = new ContentExchange(true) + { + @Override + protected void onResponseComplete() throws IOException + { + logger.debug("{} {} OK", getMethod(), getRequestURI()); + } + + @Override + protected void onExpire() + { + logger.debug("{} {} EXPIRED {}", getMethod(), getRequestURI(), this); + firstExpired.compareAndSet(false, true); + } + }; + exchanges.add(exchange); + Address address = new Address("localhost", server.getLocalPort()); + exchange.setAddress(address); + exchange.setMethod("GET"); + exchange.setRequestURI("/" + count); + exchange.setVersion("HTTP/1.1"); + exchange.setRequestHeader("Host", address.toString()); + logger.debug("{} {} SENT", exchange.getMethod(), exchange.getRequestURI()); + client.send(exchange); + ++count; + + if (processingDelay.get() > 0) + { + if (client.getDestination(address, false).getConnections() == maxConnectionsPerAddress) + { + if (firstExpired.get()) + { + ++additionalRequests; + if (additionalRequests == maxAdditionalRequest) + processingDelay.set(0); + } + } + } + else + { + ++additionalRequests; + if (additionalRequests == 2 * maxAdditionalRequest) + break; + } + } + + for (ContentExchange exchange : exchanges) + { + int status = exchange.waitForDone(); + Assert.assertTrue(status == HttpExchange.STATUS_COMPLETED || status == HttpExchange.STATUS_EXPIRED); + } + + client.stop(); + + Assert.assertTrue(failures.isEmpty()); + + for (Socket socket : sockets) + socket.close(); + server.close(); + + threadPool.shutdown(); + threadPool.awaitTermination(5, TimeUnit.SECONDS); + } +} diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAsserts.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAsserts.java index e0410057571..bd1e9d37412 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAsserts.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAsserts.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.Collections; import java.util.List; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpDestinationQueueTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpDestinationQueueTest.java index 4f3b970a62c..d292a8961b1 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpDestinationQueueTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpDestinationQueueTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.net.ServerSocket; import java.net.Socket; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java index 1d09edc80ad..6071f5ef1ae 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.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; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java index 89a55f510e0..b85fb5041e4 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java @@ -1,7 +1,18 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.IOException; import java.net.URLEncoder; @@ -229,7 +240,7 @@ public class ProxyTunnellingTest exchange.setURL("https://localhost:" + serverPort + "/echo?body=" + URLEncoder.encode(body, "UTF-8")); httpClient.send(exchange); - assertTrue(latch.await(serverConnectTimeout * 2, TimeUnit.MILLISECONDS)); + assertTrue("Server connect exception should have occurred", latch.await(serverConnectTimeout * 2, TimeUnit.MILLISECONDS)); } finally { diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/Siege.java b/jetty-client/src/test/java/org/eclipse/jetty/client/Siege.java index bc476c27fc7..00c24dc3dfd 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/Siege.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/Siege.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; import java.util.ArrayList; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SluggishServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SluggishServerTest.java index 65252038b7c..edc358ad5ff 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SluggishServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SluggishServerTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.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; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesClientTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesClientTest.java index a2f041b7d0e..7c2e57cccd2 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesClientTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslBytesClientTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.BufferedReader; import java.io.File; 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 be41f47bb96..fc046614b8a 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,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.*; 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 9b13bc30e02..db3762fd7c4 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 @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.EOFException; import java.io.IOException; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslSelectChannelValidationTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslSelectChannelValidationTest.java index ffba50d0586..a6bfd2fa7b4 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslSelectChannelValidationTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslSelectChannelValidationTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslSocketValidationTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslSocketValidationTest.java index eef2f2914d0..82380187937 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslSocketValidationTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslSocketValidationTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.server.ssl.SslSocketConnector; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslValidationTestBase.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslValidationTestBase.java index 50a733c4927..2ed12f43902 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslValidationTestBase.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslValidationTestBase.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.InputStream; import java.lang.reflect.Constructor; 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 4aefca55148..2c90a802660 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 @@ -1,4 +1,16 @@ package org.eclipse.jetty.client; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.*; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/UnexpectedDataTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/UnexpectedDataTest.java index 74dd69d43d4..5812ff8e041 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/UnexpectedDataTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/UnexpectedDataTest.java @@ -1,16 +1,15 @@ -// ======================================================================== -// Copyright 2006-2007 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ======================================================================== +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.client; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java index b9627e47dba..c5424b83c44 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client.helperClasses; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ExternalKeyStoreAsyncSslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ExternalKeyStoreAsyncSslServerAndClientCreator.java index 584f4b1a64b..c8442bc1e8c 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ExternalKeyStoreAsyncSslServerAndClientCreator.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ExternalKeyStoreAsyncSslServerAndClientCreator.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client.helperClasses; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.FileInputStream; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java index cc9ac055454..4694bfff130 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client.helperClasses; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java index d9a2f1d3eef..6f18ac85b30 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client.helperClasses; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.server.Connector; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ServerAndClientCreator.java index 015006f6802..98c063968c4 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ServerAndClientCreator.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ServerAndClientCreator.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client.helperClasses; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.server.Server; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/SslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/SslServerAndClientCreator.java index d0e0ad0a115..f1c30f030dc 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/SslServerAndClientCreator.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/SslServerAndClientCreator.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.client.helperClasses; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.client.HttpClient; diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml index c8203864124..622a388a824 100644 --- a/jetty-continuation/pom.xml +++ b/jetty-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-continuation diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationFilter.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationFilter.java index e5bd75144a5..c10ae1292c1 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationFilter.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationFilter.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.continuation; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationListener.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationListener.java index 54581a8f5b1..a3f3ee1ceba 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationListener.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationListener.java @@ -1,5 +1,16 @@ - package org.eclipse.jetty.continuation; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.EventListener; diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Jetty6Continuation.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Jetty6Continuation.java index 142b675ec2d..db43a22f7bd 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Jetty6Continuation.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Jetty6Continuation.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.continuation; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.ArrayList; import java.util.List; diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java index e4bca0be202..9a7e5b6eb39 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.continuation; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; import java.util.ArrayList; diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index de274f3fa2d..a8a37317b94 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-deploy diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java index 3bd53624942..447fb7bd7d0 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.deploy.jmx; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.ArrayList; import java.util.Collection; diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java index 323f836bf9a..2685b82fdcc 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.deploy.providers; +//======================================================================== +//Copyright 2009-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.FilenameFilter; diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java index c924b455a94..557edc0de94 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.deploy.providers; +//======================================================================== +//Copyright 2009-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.FilenameFilter; diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java index 99d619444fa..b29dc8fc694 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.deploy; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.Collection; import java.util.Set; diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/graph/GraphTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/graph/GraphTest.java index cc284e1f4dc..c067569a739 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/graph/GraphTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/graph/GraphTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.deploy.graph; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import junit.framework.Assert; diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java index 8e6357bd437..0685d889096 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.deploy.providers; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.util.Arrays; diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index df5a7e227ac..bf22f1e8f58 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT jetty-distribution Jetty :: Distribution Assemblies diff --git a/jetty-http-spi/pom.xml b/jetty-http-spi/pom.xml index ed5eccb6f0a..5e7251a22f5 100644 --- a/jetty-http-spi/pom.xml +++ b/jetty-http-spi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-http-spi 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 index 20ad8e97bee..f0d2327510e 100644 --- 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 @@ -1,4 +1,16 @@ package org.eclipse.jetty.http.spi; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.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.OutputStream; diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml index 273a6788b65..31b97e32399 100644 --- a/jetty-http/pom.xml +++ b/jetty-http/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-http diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/gzip/AbstractCompressedStream.java b/jetty-http/src/main/java/org/eclipse/jetty/http/gzip/AbstractCompressedStream.java index 316bcb27cae..2b136cec6ab 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/gzip/AbstractCompressedStream.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/gzip/AbstractCompressedStream.java @@ -234,9 +234,7 @@ public abstract class AbstractCompressedStream extends ServletOutputStream if (_response.isCommitted()) throw new IllegalStateException(); - setHeader("Content-Encoding", _encoding); - setHeader("Vary","Accept-Encoding"); - + setHeader("Content-Encoding", _encoding); if (_response.containsHeader("Content-Encoding")) { _out=_compressedOutputStream=createStream(); diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java index 7a5d156f0e1..fc1ab558af1 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.http.ssl; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== /* ------------------------------------------------------------ */ diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java index e3ea2973793..f95e6b0f10d 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.http; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.io.Buffer; import org.junit.Assert; diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index bdb887567d3..1c3ada51f39 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-io diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffers.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffers.java index b94710af5ca..9bc63cd1deb 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffers.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractBuffers.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.io; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.io.nio.DirectNIOBuffer; import org.eclipse.jetty.io.nio.IndirectNIOBuffer; 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 ef80cccb2ff..e3da77460e4 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 @@ -1,4 +1,16 @@ package org.eclipse.jetty.io; +//======================================================================== +//Copyright (c) 2006-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; diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/BuffersFactory.java b/jetty-io/src/main/java/org/eclipse/jetty/io/BuffersFactory.java index 693976a3d8b..db23f962326 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/BuffersFactory.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/BuffersFactory.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.io; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public class BuffersFactory { diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ConnectedEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ConnectedEndPoint.java index a7e66dd2842..ea550ce4090 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ConnectedEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ConnectedEndPoint.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.io; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public interface ConnectedEndPoint extends EndPoint { diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/PooledBuffers.java b/jetty-io/src/main/java/org/eclipse/jetty/io/PooledBuffers.java index 194eb9bf71b..f8356bab814 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/PooledBuffers.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/PooledBuffers.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.io; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; 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 a8db4ec100b..3ba70b035b2 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 @@ -333,9 +333,10 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo if (l==0 && ( header!=null && header.hasContent() || buffer!=null && buffer.hasContent() || trailer!=null && trailer.hasContent())) { synchronized (this) - { - if (_dispatched) - _writable=false; + { + _writable=false; + if (!_dispatched) + updateKey(); } } else if (l>0) @@ -358,9 +359,10 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo if (l==0 && buffer!=null && buffer.hasContent()) { synchronized (this) - { - if (_dispatched) - _writable=false; + { + _writable=false; + if (!_dispatched) + updateKey(); } } else if (l>0) diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/EndPointTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/EndPointTest.java index 51be3cd751f..62183eb1860 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/EndPointTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/EndPointTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.io; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/bio/SocketEndPointTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/bio/SocketEndPointTest.java index 277c6c7ccba..c412b427364 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/bio/SocketEndPointTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/bio/SocketEndPointTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.io.bio; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.net.ServerSocket; import java.net.Socket; diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/nio/ChannelEndPointTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/nio/ChannelEndPointTest.java index 1d8d5b2c7eb..2803722a0d9 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/nio/ChannelEndPointTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/nio/ChannelEndPointTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.io.nio; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointSslTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointSslTest.java index fbf3eae1ac7..e279f5cfa30 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointSslTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointSslTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.io.nio; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.IOException; diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointTest.java index 47e5f7daf54..5399f7fe414 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.io.nio; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.greaterThan; diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml index a65a5290166..95774ec9738 100644 --- a/jetty-jaspi/pom.xml +++ b/jetty-jaspi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-jaspi diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml index c109a0ebb7d..8f398e35bc4 100644 --- a/jetty-jmx/pom.xml +++ b/jetty-jmx/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-jmx diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index e9db91778e2..b97bebfe931 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-jndi diff --git a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/DataSourceCloser.java b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/DataSourceCloser.java index 352b745fccb..e0a46e9848f 100644 --- a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/DataSourceCloser.java +++ b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/DataSourceCloser.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.jndi; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.lang.reflect.Method; import java.sql.Statement; diff --git a/jetty-jsp/pom.xml b/jetty-jsp/pom.xml index 2a57dcdfb23..b0624653bad 100644 --- a/jetty-jsp/pom.xml +++ b/jetty-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-jsp diff --git a/jetty-monitor/pom.xml b/jetty-monitor/pom.xml index d8b0479c0f4..7a2a616a85d 100644 --- a/jetty-monitor/pom.xml +++ b/jetty-monitor/pom.xml @@ -19,7 +19,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-monitor diff --git a/jetty-monitor/src/main/config/etc/jetty-monitor.xml b/jetty-monitor/src/main/config/etc/jetty-monitor.xml index 6a866dda28c..dc97f88a495 100644 --- a/jetty-monitor/src/main/config/etc/jetty-monitor.xml +++ b/jetty-monitor/src/main/config/etc/jetty-monitor.xml @@ -8,14 +8,14 @@ 2000 90 - 3 + 5 2 diff --git a/jetty-nested/pom.xml b/jetty-nested/pom.xml index 1ed8c94dd2b..1cfb9375fa0 100644 --- a/jetty-nested/pom.xml +++ b/jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT jetty-nested Jetty :: Nested diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml index 37f5ad162db..ac587bcd448 100644 --- a/jetty-nosql/pom.xml +++ b/jetty-nosql/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-nosql diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/jmx/MongoSessionManagerMBean.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/jmx/MongoSessionManagerMBean.java index bb41ac918bb..646fad620c3 100644 --- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/jmx/MongoSessionManagerMBean.java +++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/jmx/MongoSessionManagerMBean.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.nosql.mongodb.jmx; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.nosql.mongodb.MongoSessionManager; import org.eclipse.jetty.server.handler.AbstractHandlerContainer; diff --git a/jetty-npn/src/main/java/org/eclipse/jetty/npn/NextProtoNego.java b/jetty-npn/src/main/java/org/eclipse/jetty/npn/NextProtoNego.java index 10d7b661712..c6ff784c77f 100644 --- a/jetty-npn/src/main/java/org/eclipse/jetty/npn/NextProtoNego.java +++ b/jetty-npn/src/main/java/org/eclipse/jetty/npn/NextProtoNego.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.npn; diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml index 6b8c5fe6ad6..3be8f742053 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java index 12b389756fc..35b07737e2a 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java +++ b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java @@ -85,7 +85,6 @@ public class WebappRegistrationCustomizerImpl implements WebappRegistrationCusto { // sanity check: Class cl = getClass().getClassLoader().loadClass("org.apache.jasper.servlet.JspServlet"); - // System.err.println("found the jsp servlet: " + cl.getName()); } catch (Exception e) { diff --git a/jetty-osgi/jetty-osgi-boot-logback/pom.xml b/jetty-osgi/jetty-osgi-boot-logback/pom.xml index a9df7b0f4ad..add2956f1ae 100644 --- a/jetty-osgi/jetty-osgi-boot-logback/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-logback/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml index df266b2923b..d80031f37b6 100644 --- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index 3083ed6d138..cadc68c15e8 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java index 94d38c50378..067d1579d9e 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java @@ -535,7 +535,6 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement //Create a WebAppContext suitable to deploy in OSGi ContextHandler ch = ((OSGiApp)app).createContextHandler(); - System.err.println("Created contexthandler "+ch); return ch; } diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java index 5a733768fa8..6a186de3745 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java @@ -144,7 +144,6 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper { // observed this on felix-2.0.0 String location = bundle.getLocation(); - // System.err.println("location " + location); if (location.startsWith("file:/")) { URI uri = new URI(URIUtil.encodePath(location)); diff --git a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml index e1a90d1af36..7eb53463ee9 100644 --- a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml +++ b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml index a146cce128e..a4873ab5af9 100644 --- a/jetty-osgi/jetty-osgi-httpservice/pom.xml +++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml index c0b3dfac9a9..b40b3a8abfe 100644 --- a/jetty-osgi/pom.xml +++ b/jetty-osgi/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml org.eclipse.jetty.osgi diff --git a/jetty-osgi/test-jetty-osgi-context/pom.xml b/jetty-osgi/test-jetty-osgi-context/pom.xml index 5756e084ff1..02a2679cf30 100644 --- a/jetty-osgi/test-jetty-osgi-context/pom.xml +++ b/jetty-osgi/test-jetty-osgi-context/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/test-jetty-osgi-webapp/pom.xml b/jetty-osgi/test-jetty-osgi-webapp/pom.xml index e16931d0209..99afc2f4642 100644 --- a/jetty-osgi/test-jetty-osgi-webapp/pom.xml +++ b/jetty-osgi/test-jetty-osgi-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 86d792cfa64..ac59643d2d2 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java index 5863d696787..4bebb9f3f8d 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java @@ -171,7 +171,7 @@ public class TestJettyOSGiBootWithJsp if (responseStatus == HttpStatus.OK_200) { content = getExchange.getResponseContent(); } - //System.err.println("content: " + content); + Assert.assertTrue(content.indexOf("ServletPath:/jsp/dump.jsp") != -1); } finally diff --git a/jetty-overlay-deployer/pom.xml b/jetty-overlay-deployer/pom.xml index ec829d9dd0b..f2ffbb6c807 100644 --- a/jetty-overlay-deployer/pom.xml +++ b/jetty-overlay-deployer/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-overlay-deployer diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index a72fcd0f317..b62d30e6702 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-plus diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/LdapLoginModule.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/LdapLoginModule.java index 5f7401724af..a939937e665 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/LdapLoginModule.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/LdapLoginModule.java @@ -327,6 +327,7 @@ public class LdapLoginModule extends AbstractLoginModule SearchControls ctls = new SearchControls(); ctls.setDerefLinkFlag(true); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); + ctls.setReturningAttributes(new String[]{_roleNameAttribute}); String filter = "(&(objectClass={0})({1}={2}))"; Object[] filterArguments = {_roleObjectClass, _roleMemberAttribute, userDn}; diff --git a/jetty-policy/pom.xml b/jetty-policy/pom.xml index d264981bf6a..617de094c72 100644 --- a/jetty-policy/pom.xml +++ b/jetty-policy/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT jetty-policy Jetty :: Policy Tool diff --git a/jetty-policy/src/main/java/org/eclipse/jetty/policy/PolicyMonitor.java b/jetty-policy/src/main/java/org/eclipse/jetty/policy/PolicyMonitor.java index 64a1755fecf..092ce5e0453 100644 --- a/jetty-policy/src/main/java/org/eclipse/jetty/policy/PolicyMonitor.java +++ b/jetty-policy/src/main/java/org/eclipse/jetty/policy/PolicyMonitor.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.policy; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.FileInputStream; diff --git a/jetty-policy/src/test/java/org/eclipse/jetty/policy/PolicyMonitorTest.java b/jetty-policy/src/test/java/org/eclipse/jetty/policy/PolicyMonitorTest.java index 06008534282..48315130486 100644 --- a/jetty-policy/src/test/java/org/eclipse/jetty/policy/PolicyMonitorTest.java +++ b/jetty-policy/src/test/java/org/eclipse/jetty/policy/PolicyMonitorTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.policy; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.util.HashMap; diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index 6663495d9b3..f2f8bf84cd4 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-rewrite diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml index f37c531e0d8..b52cf07a8e9 100644 --- a/jetty-security/pom.xml +++ b/jetty-security/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-security diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/DefaultAuthenticatorFactory.java b/jetty-security/src/main/java/org/eclipse/jetty/security/DefaultAuthenticatorFactory.java index 6c243a3a873..4dee1d083ba 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/DefaultAuthenticatorFactory.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/DefaultAuthenticatorFactory.java @@ -62,6 +62,8 @@ public class DefaultAuthenticatorFactory implements Authenticator.Factory authenticator=new FormAuthenticator(); else if ( Constraint.__SPNEGO_AUTH.equalsIgnoreCase(auth) ) authenticator = new SpnegoAuthenticator(); + else if ( Constraint.__NEGOTIATE_AUTH.equalsIgnoreCase(auth) ) // see Bug #377076 + authenticator = new SpnegoAuthenticator(Constraint.__NEGOTIATE_AUTH); if (Constraint.__CERT_AUTH.equalsIgnoreCase(auth)||Constraint.__CERT_AUTH2.equalsIgnoreCase(auth)) authenticator=new ClientCertAuthenticator(); diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java b/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java index d3921bcab0a..1c95cc1a238 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.security; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.FilenameFilter; diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoUserPrincipal.java b/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoUserPrincipal.java index a30f60996f5..26de9c2c20c 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoUserPrincipal.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoUserPrincipal.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.security; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.security.Principal; diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java index 9df7448468a..412d3fd30cb 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java @@ -36,9 +36,25 @@ public class SpnegoAuthenticator extends LoginAuthenticator { private static final Logger LOG = Log.getLogger(SpnegoAuthenticator.class); + private String _authMethod = Constraint.__SPNEGO_AUTH; + + public SpnegoAuthenticator() + { + + } + + /** + * Allow for a custom authMethod value to be set for instances where SPENGO may not be appropriate + * @param authMethod + */ + public SpnegoAuthenticator( String authMethod ) + { + _authMethod = authMethod; + } + public String getAuthMethod() { - return Constraint.__SPNEGO_AUTH; + return _authMethod; } public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java index 2e24c178c4d..3e70b3efbbf 100644 --- a/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java +++ b/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.security; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.BufferedWriter; import java.io.File; diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index 00f3e96c0ce..9360d2a8631 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-server 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 2a5ba0d8f0f..e1aeefef13b 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 @@ -378,7 +378,6 @@ public abstract class AbstractHttpConnection extends AbstractConnection } } }; - } _writer.setCharacterEncoding(encoding); return _printWriter; @@ -402,6 +401,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection _responseFields.clear(); _response.recycle(); _uri.clear(); + _writer=null; } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/DispatcherType.java b/jetty-server/src/main/java/org/eclipse/jetty/server/DispatcherType.java index 02da5df6b9f..fdf7fb93e09 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/DispatcherType.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/DispatcherType.java @@ -1,5 +1,17 @@ package org.eclipse.jetty.server; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public enum DispatcherType { 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 1ce798ddf7e..0a2bd9773b4 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 @@ -352,7 +352,7 @@ public class Server extends HandlerWrapper implements Attributes { LOG.debug("REQUEST "+target+" on "+connection); handle(target, request, request, response); - LOG.debug("RESPONSE "+target+" "+connection.getResponse().getStatus()); + LOG.debug("RESPONSE "+target+" "+connection.getResponse().getStatus()+" handled="+request.isHandled()); } else handle(target, request, request, response); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletResponseHttpWrapper.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletResponseHttpWrapper.java index 94038d9a971..03ad3627bd0 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletResponseHttpWrapper.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletResponseHttpWrapper.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; 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 cef2c5cc978..cc79dc2aa78 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 @@ -1,7 +1,21 @@ package org.eclipse.jetty.server.handler; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; import java.net.InetSocketAddress; +import java.net.SocketException; +import java.net.SocketTimeoutException; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; @@ -223,7 +237,33 @@ public class ConnectHandler extends HandlerWrapper return; } - SocketChannel channel = connectToServer(request, host, port); + SocketChannel channel; + + try + { + channel = connectToServer(request,host,port); + } + catch (SocketException se) + { + LOG.info("ConnectHandler: SocketException " + se.getMessage()); + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + baseRequest.setHandled(true); + return; + } + catch (SocketTimeoutException ste) + { + LOG.info("ConnectHandler: SocketTimeoutException" + ste.getMessage()); + response.setStatus(HttpServletResponse.SC_GATEWAY_TIMEOUT); + baseRequest.setHandled(true); + return; + } + catch (IOException ioe) + { + LOG.info("ConnectHandler: IOException" + ioe.getMessage()); + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + baseRequest.setHandled(true); + return; + } // Transfer unread data from old connection to new connection // We need to copy the data to avoid races: @@ -304,9 +344,10 @@ public class ConnectHandler extends HandlerWrapper return new ProxyToServerConnection(context, buffer); } + // may return null private SocketChannel connectToServer(HttpServletRequest request, String host, int port) throws IOException { - SocketChannel channel = connect(request, host, port); + SocketChannel channel = connect(request, host, port); channel.configureBlocking(false); return channel; } @@ -323,6 +364,12 @@ public class ConnectHandler extends HandlerWrapper protected SocketChannel connect(HttpServletRequest request, String host, int port) throws IOException { SocketChannel channel = SocketChannel.open(); + + if (channel == null) + { + throw new IOException("unable to connect to " + host + ":" + port); + } + try { // Connect to remote server 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 1baee0070b0..ebd07840490 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 @@ -1128,7 +1128,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. return; } - _protectedTargets = Arrays.copyOf(targets, targets.length); + _protectedTargets = new String[targets.length]; + System.arraycopy(targets, 0, _protectedTargets, 0, targets.length); } public String[] getProtectedTargets () @@ -1136,7 +1137,9 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. if (_protectedTargets == null) return null; - return Arrays.copyOf(_protectedTargets, _protectedTargets.length); + String[] tmp = new String[_protectedTargets.length]; + System.arraycopy(_protectedTargets, 0, tmp, 0, _protectedTargets.length); + return tmp; } @@ -1782,8 +1785,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. query = uriInContext.substring(q + 1); uriInContext = uriInContext.substring(0,q); } - if ((q = uriInContext.indexOf(';')) > 0) - uriInContext = uriInContext.substring(0,q); + // if ((q = uriInContext.indexOf(';')) > 0) + // uriInContext = uriInContext.substring(0,q); String pathInContext = URIUtil.canonicalPath(URIUtil.decodePath(uriInContext)); String uri = URIUtil.addPaths(getContextPath(),uriInContext); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DebugHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DebugHandler.java index d224474e3a8..dd463edb78e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DebugHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DebugHandler.java @@ -1,15 +1,14 @@ //======================================================================== -//Copyright 2009 Mort Bay Consulting Pty. Ltd. +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. //------------------------------------------------------------------------ -//Licensed under the Apache License, Version 2.0 (the "License"); -//you may not use this file except in compliance with the License. -//You may obtain a copy of the License at -//http://www.apache.org/licenses/LICENSE-2.0 -//Unless required by applicable law or agreed to in writing, software -//distributed under the License is distributed on an "AS IS" BASIS, -//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//See the License for the specific language governing permissions and -//limitations under the License. +//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.server.handler; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ProxyHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ProxyHandler.java index 96b4dfd8544..bf8c556b887 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ProxyHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ProxyHandler.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.handler; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.server.Handler; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ScopedHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ScopedHandler.java index d4ff318c7a3..674c780d7e3 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ScopedHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ScopedHandler.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.handler; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java index 8bc7eb5287f..c22dbf82476 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.session; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.ArrayList; import java.util.Collections; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashedSession.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashedSession.java index 5db2550a132..20ead438926 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashedSession.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashedSession.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.session; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.DataOutputStream; import java.io.File; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java index d929d30ee13..c0ff9135976 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java @@ -85,7 +85,6 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager protected String _insertSession; protected String _deleteSession; - protected String _selectSession; protected String _updateSession; protected String _updateSessionNode; protected String _updateSessionAccessTime; @@ -110,6 +109,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager String _dbName; boolean _isLower; boolean _isUpper; + public DatabaseAdaptor (DatabaseMetaData dbMeta) @@ -189,6 +189,39 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager return "rowId"; } + + + public boolean isEmptyStringNull () + { + return (_dbName.startsWith("oracle")); + } + + public PreparedStatement getLoadStatement (Connection connection, String rowId, String contextPath, String virtualHosts) + throws SQLException + { + if (contextPath == null || "".equals(contextPath)) + { + if (isEmptyStringNull()) + { + PreparedStatement statement = connection.prepareStatement("select * from "+_sessionTable+ + " where sessionId = ? and contextPath is null and virtualHost = ?"); + statement.setString(1, rowId); + statement.setString(2, virtualHosts); + + return statement; + } + } + + + + PreparedStatement statement = connection.prepareStatement("select * from "+_sessionTable+ + " where sessionId = ? and contextPath = ? and virtualHost = ?"); + statement.setString(1, rowId); + statement.setString(2, contextPath); + statement.setString(3, virtualHosts); + + return statement; + } } @@ -628,10 +661,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager _deleteSession = "delete from "+_sessionTable+ " where "+_sessionTableRowId+" = ?"; - - _selectSession = "select * from "+_sessionTable+ - " where sessionId = ? and contextPath = ? and virtualHost = ?"; - + _updateSession = "update "+_sessionTable+ " set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ?, map = ? where "+_sessionTableRowId+" = ?"; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java index b23e252c7af..121fa6cc8f5 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java @@ -24,6 +24,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Statement; import java.util.HashMap; import java.util.List; import java.util.ListIterator; @@ -831,10 +832,7 @@ public class JDBCSessionManager extends AbstractSessionManager try { connection = getConnection(); - statement = connection.prepareStatement(_jdbcSessionIdMgr._selectSession); - statement.setString(1, id); - statement.setString(2, canonicalContextPath); - statement.setString(3, vhost); + statement = _jdbcSessionIdMgr._dbAdaptor.getLoadStatement(connection, id, canonicalContextPath, vhost); ResultSet result = statement.executeQuery(); if (result.next()) { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslCertificates.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslCertificates.java index 7fcd9f8d111..f0e047b8d15 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslCertificates.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslCertificates.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.ssl; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java index fb04d57d61c..ae45de39fe6 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.ssl; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.security.SecureRandom; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java index 607c271abe7..0fa1972d51d 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.BufferedReader; import java.io.IOException; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java index 3d21c413757..6edd05115f1 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; 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 3bd3cf3920e..6e13a24622c 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,4 +1,16 @@ package org.eclipse.jetty.server; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; import java.net.Socket; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java index 833e5ff97b0..db9782dbb1b 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.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; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SuspendHandler.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SuspendHandler.java index 1c16dc956ab..8f6cf65a6f7 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/SuspendHandler.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SuspendHandler.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.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; 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 eb07c09aade..aa78cd69fc5 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 @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.handler; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.BufferedReader; import java.io.EOFException; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerSSLTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerSSLTest.java index 25284911cae..2af503aee68 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerSSLTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerSSLTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.handler; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.BufferedReader; import java.io.ByteArrayOutputStream; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerTest.java index da1f5c57075..8a5ac5b5d2c 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ConnectHandlerTest.java @@ -1,4 +1,19 @@ package org.eclipse.jetty.server.handler; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + +import static org.junit.Assert.*; +import static org.junit.Assume.*; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; @@ -6,9 +21,12 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.net.InetAddress; import java.net.Socket; +import java.net.UnknownHostException; import java.nio.channels.SocketChannel; import java.util.concurrent.ConcurrentMap; + import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; @@ -19,13 +37,10 @@ import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.toolchain.test.OS; -import org.eclipse.jetty.util.log.Log; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assume.assumeTrue; - /** * @version $Revision$ $Date$ */ @@ -104,6 +119,53 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest } } + + @Test + public void testCONNECTBadHostPort() throws Exception + { + String invalidHostname = "AMAZEBALLS_BADHOST.webtide.com"; + + try + { + InetAddress addr = InetAddress.getByName(invalidHostname); + StringBuilder err = new StringBuilder(); + err.append("DNS Hijacking detected: "); + err.append(invalidHostname).append(" should have not returned a valid IP address ["); + err.append(addr.getHostAddress()).append("]. "); + err.append("Fix your DNS provider to have this test pass."); + err.append("\nFor more info see https://en.wikipedia.org/wiki/DNS_hijacking"); + Assert.assertNull(err.toString(), addr); + } + catch (UnknownHostException e) + { + // expected path + } + + String hostPort = String.format("%s:%d",invalidHostname,serverConnector.getLocalPort()); + String request = "" + + "CONNECT " + hostPort + " HTTP/1.1\r\n" + + "Host: " + hostPort + "\r\n" + + "\r\n"; + Socket socket = newSocket(); + socket.setSoTimeout(30000); + try + { + OutputStream output = socket.getOutputStream(); + BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream())); + + output.write(request.getBytes("UTF-8")); + output.flush(); + + // Expect 500 OK from the CONNECT request + Response response = readResponse(input); + assertEquals("Response Code", "500", response.getCode()); + } + finally + { + socket.close(); + } + } + @Test public void testCONNECT10AndGET() throws Exception { @@ -355,6 +417,14 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest @Test public void testCONNECTAndPOSTWithBigBody() throws Exception { + // fails under windows and occasionally on mac due to OOME + boolean stress = Boolean.getBoolean( "STRESS" ); + + if (!stress) + { + return; + } + // Log.getLogger(ConnectHandler.class).setDebugEnabled(true); String hostPort = "localhost:" + serverConnector.getLocalPort(); String request = "" + 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 57e4de8f59b..183dc57ee25 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 @@ -1,5 +1,4 @@ // ======================================================================== -// $Id$ // Copyright (c) 2006-2009 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ // All rights reserved. This program and the accompanying materials diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ScopedHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ScopedHandlerTest.java index 0fa811db0b2..b74e9fc9e40 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ScopedHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ScopedHandlerTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.handler; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionHandlerTest.java index ba0f58a407a..4b59884018c 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionHandlerTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.session; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java index eb927154972..321122e0a67 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java @@ -1,15 +1,14 @@ //======================================================================== -//Copyright 2004-2008 Mort Bay Consulting Pty. Ltd. +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. //------------------------------------------------------------------------ -//Licensed under the Apache License, Version 2.0 (the "License"); -//you may not use this file except in compliance with the License. -//You may obtain a copy of the License at -//http://www.apache.org/licenses/LICENSE-2.0 -//Unless required by applicable law or agreed to in writing, software -//distributed under the License is distributed on an "AS IS" BASIS, -//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//See the License for the specific language governing permissions and -//limitations under the License. +//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. //======================================================================== // JettyTest.java -- diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java index 79ef7d32f21..67efa218849 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.ssl; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.BufferedReader; import java.io.FileInputStream; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslRenegotiateTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslRenegotiateTest.java index a38967f164c..65864527f80 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslRenegotiateTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslRenegotiateTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.ssl; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml index 47ef14183b1..78381ecb209 100644 --- a/jetty-servlet/pom.xml +++ b/jetty-servlet/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-servlet diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java index 378e490ddfc..31643879753 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java @@ -421,6 +421,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory boolean gzip=false; if (!included.booleanValue() && _gzip && reqRanges==null && !endsWithSlash ) { + // Tell caches that response may vary by accept-encoding + response.setHeader(HttpHeaders.VARY,HttpHeaders.ACCEPT_ENCODING); + // Should we vary this response according to accept-encoding? String accept=request.getHeader(HttpHeaders.ACCEPT_ENCODING); if (accept!=null && accept.indexOf("gzip")>=0) gzip=true; @@ -497,7 +500,6 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory if (gzip) { response.setHeader(HttpHeaders.CONTENT_ENCODING,"gzip"); - response.setHeader(HttpHeaders.VARY,HttpHeaders.ACCEPT_ENCODING); String mt=_servletContext.getMimeType(pathInContext); if (mt!=null) response.setContentType(mt); 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 76f360592ad..80574bdc303 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 @@ -252,44 +252,7 @@ public class ServletHandler extends ScopedHandler return null; return _servletPathMap.getMatch(pathInContext); } - - /* ------------------------------------------------------------ */ - /** - * @param uriInContext uri to get dispatcher for - * @return A {@link RequestDispatcher dispatcher} wrapping the resource at uriInContext, - * or null if the specified uri cannot be dispatched to. - */ - public RequestDispatcher getRequestDispatcher(String uriInContext) - { - if (uriInContext == null || _contextHandler==null) - return null; - - if (!uriInContext.startsWith("/")) - return null; - - try - { - String query=null; - int q; - if ((q=uriInContext.indexOf('?'))>0) - { - query=uriInContext.substring(q+1); - uriInContext=uriInContext.substring(0,q); - } - if ((q=uriInContext.indexOf(';'))>0) - uriInContext=uriInContext.substring(0,q); - - String pathInContext=URIUtil.canonicalPath(URIUtil.decodePath(uriInContext)); - String uri=URIUtil.addPaths(_contextHandler.getContextPath(), uriInContext); - return new Dispatcher(_contextHandler, uri, pathInContext, query); - } - catch(Exception e) - { - LOG.ignore(e); - } - return null; - } - + /* ------------------------------------------------------------ */ public ServletContext getServletContext() { diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java index 2448ad29cf6..f210bb1db2e 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java @@ -38,7 +38,9 @@ import org.eclipse.jetty.security.IdentityService; import org.eclipse.jetty.security.RunAsToken; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.UserIdentity; +import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.servlet.api.ServletRegistration; +import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -459,6 +461,12 @@ public class ServletHolder extends Holder implements UserIdentity.Scope { old_run_as=_identityService.setRunAs(_identityService.getSystemUserIdentity(),_runAsToken); } + + // Handle configuring servlets that implement org.apache.jasper.servlet.JspServlet + if (isJspServlet()) + { + initJspServlet(); + } _servlet.init(_config); } @@ -492,6 +500,31 @@ public class ServletHolder extends Holder implements UserIdentity.Scope } + /* ------------------------------------------------------------ */ + /** + * @throws Exception + */ + protected void initJspServlet () throws Exception + { + ContextHandler ch = ((ContextHandler.Context)getServletHandler().getServletContext()).getContextHandler(); + + /* Set the webapp's classpath for Jasper */ + ch.setAttribute("org.apache.catalina.jsp_classpath", ch.getClassPath()); + + /* Set the system classpath for Jasper */ + setInitParameter("com.sun.appserv.jsp.classpath", Loader.getClassPath(ch.getClassLoader().getParent())); + + /* Set up other classpath attribute */ + if ("?".equals(getInitParameter("classpath"))) + { + String classpath = ch.getClassPath(); + LOG.debug("classpath=" + classpath); + if (classpath != null) + setInitParameter("classpath", classpath); + } + } + + /* ------------------------------------------------------------ */ /** * @see org.eclipse.jetty.server.UserIdentity.Scope#getContextPath() @@ -583,6 +616,34 @@ public class ServletHolder extends Holder implements UserIdentity.Scope request.setAttribute("javax.servlet.error.servlet_name",getName()); } } + + + /* ------------------------------------------------------------ */ + private boolean isJspServlet () + { + if (_servlet == null) + return false; + + Class c = _servlet.getClass(); + + boolean result = false; + while (c != null && !result) + { + result = isJspServlet(c.getName()); + c = c.getSuperclass(); + } + + return result; + } + + + /* ------------------------------------------------------------ */ + private boolean isJspServlet (String classname) + { + if (classname == null) + return false; + return ("org.apache.jasper.servlet.JspServlet".equals(classname)); + } /* ------------------------------------------------------------ */ diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/FilterRegistration.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/FilterRegistration.java index 6ff1b97afd5..2250da88486 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/FilterRegistration.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/FilterRegistration.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlet.api; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.Collection; import java.util.EnumSet; diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/Registration.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/Registration.java index d83bd2ceb34..3f1ea5a90c0 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/Registration.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/Registration.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlet.api; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.Map; import java.util.Set; diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/ServletRegistration.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/ServletRegistration.java index c6f231dff2f..f1d2cf3443c 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/ServletRegistration.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/api/ServletRegistration.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlet.api; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.Collection; import java.util.Set; diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java index 27497fa0854..27d1a5502f9 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlet; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java index f10d24fa93a..7ae67f7facc 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlet; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java index 4a4f2fad1b5..22519f9a3d3 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlet; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertTrue; diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java index 6aede63657e..2ec9d9c5bd9 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java @@ -105,6 +105,27 @@ public class DispatcherTest assertEquals(expected, responses); } + + @Test + public void testForwardWithParam() throws Exception + { + _contextHandler.addServlet(ForwardServlet.class, "/ForwardServlet/*"); + _contextHandler.addServlet(EchoURIServlet.class, "/EchoURI/*"); + + String expected= + "HTTP/1.1 200 OK\r\n"+ + "Content-Type: text/plain\r\n"+ + "Content-Length: 54\r\n"+ + "\r\n"+ + "/context\r\n"+ + "/EchoURI\r\n"+ + "/x x\r\n"+ + "/context/EchoURI/x%20x;a=1\r\n"; + + String responses = _connector.getResponses("GET /context/ForwardServlet;ignore=true?do=req.echo&uri=EchoURI%2Fx%2520x%3Ba=1%3Fb=2 HTTP/1.1\n" + "Host: localhost\n\n"); + + assertEquals(expected, responses); + } @Test public void testInclude() throws Exception @@ -279,6 +300,10 @@ public class DispatcherTest dispatcher = getServletContext().getRequestDispatcher("/AssertIncludeForwardServlet/assertpath?do=end"); else if(request.getParameter("do").equals("assertforward")) dispatcher = getServletContext().getRequestDispatcher("/AssertForwardServlet?do=end&do=the"); + else if(request.getParameter("do").equals("ctx.echo")) + dispatcher = getServletContext().getRequestDispatcher(request.getParameter("uri")); + else if(request.getParameter("do").equals("req.echo")) + dispatcher = request.getRequestDispatcher(request.getParameter("uri")); dispatcher.forward(request, response); } } @@ -462,6 +487,19 @@ public class DispatcherTest } } + public static class EchoURIServlet extends HttpServlet implements Servlet + { + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + response.setContentType("text/plain"); + response.setStatus(HttpServletResponse.SC_OK); + response.getOutputStream().println(request.getContextPath()); + response.getOutputStream().println(request.getServletPath()); + response.getOutputStream().println(request.getPathInfo()); + response.getOutputStream().println(request.getRequestURI()); + } + } + public static class AssertForwardServlet extends HttpServlet implements Servlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java index 522643605ff..820c5805a09 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlet; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; diff --git a/jetty-servlets/pom.xml b/jetty-servlets/pom.xml index 7eb2ed147d2..523fa987280 100644 --- a/jetty-servlets/pom.xml +++ b/jetty-servlets/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-servlets diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/BalancerServlet.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/BalancerServlet.java new file mode 100644 index 00000000000..f7ef7db0097 --- /dev/null +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/BalancerServlet.java @@ -0,0 +1,417 @@ +// ======================================================================== +// Copyright (c) 2012 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.servlets; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.UnavailableException; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; + +import org.eclipse.jetty.http.HttpURI; +import org.eclipse.jetty.server.Request; + +/** + * 6 + */ +public class BalancerServlet extends ProxyServlet +{ + + private static final class BalancerMember + { + + private String _name; + + private String _proxyTo; + + private HttpURI _backendURI; + + public BalancerMember(String name, String proxyTo) + { + super(); + _name = name; + _proxyTo = proxyTo; + _backendURI = new HttpURI(_proxyTo); + } + + public String getProxyTo() + { + return _proxyTo; + } + + public HttpURI getBackendURI() + { + return _backendURI; + } + + @Override + public String toString() + { + return "BalancerMember [_name=" + _name + ", _proxyTo=" + _proxyTo + "]"; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((_name == null)?0:_name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BalancerMember other = (BalancerMember)obj; + if (_name == null) + { + if (other._name != null) + return false; + } + else if (!_name.equals(other._name)) + return false; + return true; + } + + } + + private static final class RoundRobinIterator implements Iterator + { + + private BalancerMember[] _balancerMembers; + + private AtomicInteger _index; + + public RoundRobinIterator(Collection balancerMembers) + { + _balancerMembers = (BalancerMember[])balancerMembers.toArray(new BalancerMember[balancerMembers.size()]); + _index = new AtomicInteger(-1); + } + + public boolean hasNext() + { + return true; + } + + public BalancerMember next() + { + BalancerMember balancerMember = null; + while (balancerMember == null) + { + int currentIndex = _index.get(); + int nextIndex = (currentIndex + 1) % _balancerMembers.length; + if (_index.compareAndSet(currentIndex,nextIndex)) + { + balancerMember = _balancerMembers[nextIndex]; + } + } + return balancerMember; + } + + public void remove() + { + throw new UnsupportedOperationException(); + } + + } + + private static final String BALANCER_MEMBER_PREFIX = "BalancerMember."; + + private static final List FORBIDDEN_CONFIG_PARAMETERS; + static + { + List params = new LinkedList(); + params.add("HostHeader"); + params.add("whiteList"); + params.add("blackList"); + FORBIDDEN_CONFIG_PARAMETERS = Collections.unmodifiableList(params); + } + + private static final List REVERSE_PROXY_HEADERS; + static + { + List params = new LinkedList(); + params.add("Location"); + params.add("Content-Location"); + params.add("URI"); + REVERSE_PROXY_HEADERS = Collections.unmodifiableList(params); + } + + private static final String JSESSIONID = "jsessionid"; + + private static final String JSESSIONID_URL_PREFIX = JSESSIONID + "="; + + private boolean _stickySessions; + + private Set _balancerMembers = new HashSet(); + + private boolean _proxyPassReverse; + + private RoundRobinIterator _roundRobinIterator; + + @Override + public void init(ServletConfig config) throws ServletException + { + validateConfig(config); + super.init(config); + initStickySessions(config); + initBalancers(config); + initProxyPassReverse(config); + postInit(); + } + + private void validateConfig(ServletConfig config) throws ServletException + { + @SuppressWarnings("unchecked") + List initParameterNames = Collections.list(config.getInitParameterNames()); + for (String initParameterName : initParameterNames) + { + if (FORBIDDEN_CONFIG_PARAMETERS.contains(initParameterName)) + { + throw new UnavailableException(initParameterName + " not supported in " + getClass().getName()); + } + } + } + + private void initStickySessions(ServletConfig config) throws ServletException + { + _stickySessions = "true".equalsIgnoreCase(config.getInitParameter("StickySessions")); + } + + private void initBalancers(ServletConfig config) throws ServletException + { + Set balancerNames = getBalancerNames(config); + for (String balancerName : balancerNames) + { + String memberProxyToParam = BALANCER_MEMBER_PREFIX + balancerName + ".ProxyTo"; + String proxyTo = config.getInitParameter(memberProxyToParam); + if (proxyTo == null || proxyTo.trim().length() == 0) + { + throw new UnavailableException(memberProxyToParam + " parameter is empty."); + } + _balancerMembers.add(new BalancerMember(balancerName,proxyTo)); + } + } + + private void initProxyPassReverse(ServletConfig config) + { + _proxyPassReverse = "true".equalsIgnoreCase(config.getInitParameter("ProxyPassReverse")); + } + + private void postInit() + { + _roundRobinIterator = new RoundRobinIterator(_balancerMembers); + } + + private Set getBalancerNames(ServletConfig config) throws ServletException + { + Set names = new HashSet(); + @SuppressWarnings("unchecked") + List initParameterNames = Collections.list(config.getInitParameterNames()); + for (String initParameterName : initParameterNames) + { + if (!initParameterName.startsWith(BALANCER_MEMBER_PREFIX)) + { + continue; + } + int endOfNameIndex = initParameterName.lastIndexOf("."); + if (endOfNameIndex <= BALANCER_MEMBER_PREFIX.length()) + { + throw new UnavailableException(initParameterName + " parameter does not provide a balancer member name"); + } + names.add(initParameterName.substring(BALANCER_MEMBER_PREFIX.length(),endOfNameIndex)); + } + return names; + } + + @Override + protected HttpURI proxyHttpURI(HttpServletRequest request, String uri) throws MalformedURLException + { + BalancerMember balancerMember = selectBalancerMember(request); + try + { + URI dstUri = new URI(balancerMember.getProxyTo() + "/" + uri).normalize(); + return new HttpURI(dstUri.toString()); + } + catch (URISyntaxException e) + { + throw new MalformedURLException(e.getMessage()); + } + } + + private BalancerMember selectBalancerMember(HttpServletRequest request) + { + BalancerMember balancerMember = null; + if (_stickySessions) + { + String name = getBalancerMemberNameFromSessionId(request); + if (name != null) + { + balancerMember = findBalancerMemberByName(name); + if (balancerMember != null) + { + return balancerMember; + } + } + } + return _roundRobinIterator.next(); + } + + private BalancerMember findBalancerMemberByName(String name) + { + BalancerMember example = new BalancerMember(name,""); + for (BalancerMember balancerMember : _balancerMembers) + { + if (balancerMember.equals(example)) + { + return balancerMember; + } + } + return null; + } + + private String getBalancerMemberNameFromSessionId(HttpServletRequest request) + { + String name = getBalancerMemberNameFromSessionCookie(request); + if (name == null) + { + name = getBalancerMemberNameFromURL(request); + } + return name; + } + + private String getBalancerMemberNameFromSessionCookie(HttpServletRequest request) + { + Cookie[] cookies = request.getCookies(); + String name = null; + for (Cookie cookie : cookies) + { + if (JSESSIONID.equalsIgnoreCase(cookie.getName())) + { + name = extractBalancerMemberNameFromSessionId(cookie.getValue()); + break; + } + } + return name; + } + + private String getBalancerMemberNameFromURL(HttpServletRequest request) + { + String name = null; + String requestURI = request.getRequestURI(); + int idx = requestURI.lastIndexOf(";"); + if (idx != -1) + { + String requestURISuffix = requestURI.substring(idx); + if (requestURISuffix.startsWith(JSESSIONID_URL_PREFIX)) + { + name = extractBalancerMemberNameFromSessionId(requestURISuffix.substring(JSESSIONID_URL_PREFIX.length())); + } + } + return name; + } + + private String extractBalancerMemberNameFromSessionId(String sessionId) + { + String name = null; + int idx = sessionId.lastIndexOf("."); + if (idx != -1) + { + String sessionIdSuffix = sessionId.substring(idx + 1); + name = (sessionIdSuffix.length() > 0)?sessionIdSuffix:null; + } + return name; + } + + @Override + protected String filterResponseHeaderValue(String headerName, String headerValue, HttpServletRequest request) + { + if (_proxyPassReverse && REVERSE_PROXY_HEADERS.contains(headerName)) + { + HttpURI locationURI = new HttpURI(headerValue); + if (isAbsoluteLocation(locationURI) && isBackendLocation(locationURI)) + { + Request jettyRequest = (Request)request; + URI reverseUri; + try + { + reverseUri = new URI(jettyRequest.getRootURL().append(locationURI.getCompletePath()).toString()).normalize(); + return reverseUri.toURL().toString(); + } + catch (Exception e) + { + _log.warn("Not filtering header response",e); + return headerValue; + } + } + } + return headerValue; + } + + private boolean isBackendLocation(HttpURI locationURI) + { + for (BalancerMember balancerMember : _balancerMembers) + { + HttpURI backendURI = balancerMember.getBackendURI(); + if (backendURI.getHost().equals(locationURI.getHost()) && backendURI.getScheme().equals(locationURI.getScheme()) + && backendURI.getPort() == locationURI.getPort()) + { + return true; + } + } + return false; + } + + private boolean isAbsoluteLocation(HttpURI locationURI) + { + return locationURI.getHost() != null; + } + + @Override + public String getHostHeader() + { + throw new UnsupportedOperationException("HostHeader not supported in " + getClass().getName()); + } + + @Override + public void setHostHeader(String hostHeader) + { + throw new UnsupportedOperationException("HostHeader not supported in " + getClass().getName()); + } + + @Override + public boolean validateDestination(String host, String path) + { + return true; + } + +} \ No newline at end of file diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java index bb57608c4b4..6561166a18c 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java @@ -54,15 +54,18 @@ import org.eclipse.jetty.util.log.Logger; * and any 3 letter top-level domain (.com, .net, .org, etc.). *
  • allowedMethods, a comma separated list of HTTP methods that * are allowed to be used when accessing the resources. Default value is - * GET,POST
  • + * GET,POST,HEAD *
  • allowedHeaders, a comma separated list of HTTP headers that * are allowed to be specified when accessing the resources. Default value - * is X-Requested-With
  • + * is X-Requested-With,Content-Type,Accept,Origin *
  • preflightMaxAge, the number of seconds that preflight requests * can be cached by the client. Default value is 1800 seconds, or 30 * minutes
  • *
  • allowCredentials, a boolean indicating if the resource allows * requests with credentials. Default value is false
  • + *
  • exposeHeaders, a comma separated list of HTTP headers that + * are allowed to be exposed on the client. Default value is the + * empty list
  • *

    *

    A typical configuration could be: *

    @@ -79,8 +82,6 @@ import org.eclipse.jetty.util.log.Logger;
      *     ...
      * </web-app>
      * 

    - * - * @version $Revision$ $Date$ */ public class CrossOriginFilter implements Filter { @@ -96,12 +97,15 @@ public class CrossOriginFilter implements Filter public static final String ACCESS_CONTROL_ALLOW_HEADERS_HEADER = "Access-Control-Allow-Headers"; public static final String ACCESS_CONTROL_MAX_AGE_HEADER = "Access-Control-Max-Age"; public static final String ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER = "Access-Control-Allow-Credentials"; + public static final String ACCESS_CONTROL_EXPOSE_HEADERS_HEADER = "Access-Control-Expose-Headers"; // Implementation constants public static final String ALLOWED_ORIGINS_PARAM = "allowedOrigins"; public static final String ALLOWED_METHODS_PARAM = "allowedMethods"; public static final String ALLOWED_HEADERS_PARAM = "allowedHeaders"; public static final String PREFLIGHT_MAX_AGE_PARAM = "preflightMaxAge"; public static final String ALLOW_CREDENTIALS_PARAM = "allowCredentials"; + public static final String EXPOSED_HEADERS_PARAM = "exposedHeaders"; + public static final String FORWARD_PREFLIGHT_PARAM = "forwardPreflight"; private static final String ANY_ORIGIN = "*"; private static final List SIMPLE_HTTP_METHODS = Arrays.asList("GET", "POST", "HEAD"); @@ -109,8 +113,10 @@ public class CrossOriginFilter implements Filter private List allowedOrigins = new ArrayList(); private List allowedMethods = new ArrayList(); private List allowedHeaders = new ArrayList(); - private int preflightMaxAge = 0; + private List exposedHeaders = new ArrayList(); + private int preflightMaxAge; private boolean allowCredentials; + private boolean forwardPreflight; public void init(FilterConfig config) throws ServletException { @@ -163,6 +169,16 @@ public class CrossOriginFilter implements Filter allowedCredentialsConfig = "true"; allowCredentials = Boolean.parseBoolean(allowedCredentialsConfig); + String exposedHeadersConfig = config.getInitParameter(EXPOSED_HEADERS_PARAM); + if (exposedHeadersConfig == null) + exposedHeadersConfig = ""; + exposedHeaders.addAll(Arrays.asList(exposedHeadersConfig.split(","))); + + String forwardPreflightConfig = config.getInitParameter(FORWARD_PREFLIGHT_PARAM); + if (forwardPreflightConfig == null) + forwardPreflightConfig = "true"; + forwardPreflight = Boolean.parseBoolean(forwardPreflightConfig); + if (LOG.isDebugEnabled()) { LOG.debug("Cross-origin filter configuration: " + @@ -170,7 +186,10 @@ public class CrossOriginFilter implements Filter ALLOWED_METHODS_PARAM + " = " + allowedMethodsConfig + ", " + ALLOWED_HEADERS_PARAM + " = " + allowedHeadersConfig + ", " + PREFLIGHT_MAX_AGE_PARAM + " = " + preflightMaxAgeConfig + ", " + - ALLOW_CREDENTIALS_PARAM + " = " + allowedCredentialsConfig); + ALLOW_CREDENTIALS_PARAM + " = " + allowedCredentialsConfig + "," + + EXPOSED_HEADERS_PARAM + " = " + exposedHeadersConfig + "," + + FORWARD_PREFLIGHT_PARAM + " = " + forwardPreflightConfig + ); } } @@ -196,6 +215,10 @@ public class CrossOriginFilter implements Filter { LOG.debug("Cross-origin request to {} is a preflight cross-origin request", request.getRequestURI()); handlePreflightResponse(request, response, origin); + if (forwardPreflight) + LOG.debug("Preflight cross-origin request to {} forwarded to application", request.getRequestURI()); + else + return; } else { @@ -305,6 +328,8 @@ public class CrossOriginFilter implements Filter response.setHeader(ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, origin); if (allowCredentials) response.setHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER, "true"); + if (!exposedHeaders.isEmpty()) + response.setHeader(ACCESS_CONTROL_EXPOSE_HEADERS_HEADER, commify(exposedHeaders)); } private void handlePreflightResponse(HttpServletRequest request, HttpServletResponse response, String origin) diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java index 8b9a9c76d3f..2837be9c97a 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java @@ -201,7 +201,11 @@ public class GzipFilter extends UserAgentFilter { HttpServletRequest request=(HttpServletRequest)req; HttpServletResponse response=(HttpServletResponse)res; + + // Inform caches that responses may vary according to Accept-Encoding + response.setHeader("Vary","Accept-Encoding"); + // Should we vary this response according to Accept-Encoding String compressionType = selectCompression(request.getHeader("accept-encoding")); if (compressionType!=null && !response.containsHeader("Content-Encoding") && !HttpMethods.HEAD.equalsIgnoreCase(request.getMethod())) { 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 50ee23ae346..f6a308bb7ff 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 @@ -79,6 +79,15 @@ public class IncludableGzipFilter extends GzipFilter { return new GZIPOutputStream(_response.getOutputStream(),_bufferSize); } + + @Override + protected void setHeader(String name, String value) + { + super.setHeader(name, value); + HttpServletResponse response = (HttpServletResponse)getResponse(); + if (!response.containsHeader(name)) + response.setHeader("org.eclipse.jetty.server.include." + name, value); + } }; } }; @@ -97,6 +106,15 @@ public class IncludableGzipFilter extends GzipFilter { return new DeflaterOutputStream(_response.getOutputStream(),new Deflater(_deflateCompressionLevel, _deflateNoWrap)); } + + @Override + protected void setHeader(String name, String value) + { + super.setHeader(name, value); + HttpServletResponse response = (HttpServletResponse)getResponse(); + if (!response.containsHeader(name)) + response.setHeader("org.eclipse.jetty.server.include." + name, value); + } }; } }; @@ -108,8 +126,8 @@ public class IncludableGzipFilter extends GzipFilter configureWrappedResponse(wrappedResponse); return wrappedResponse; } - - + + // Extend CompressedResponseWrapper to be able to set headers during include and to create unchecked printwriters private abstract class IncludableResponseWrapper extends CompressedResponseWrapper { @@ -124,7 +142,7 @@ public class IncludableGzipFilter extends GzipFilter super.setHeader(name,value); HttpServletResponse response = (HttpServletResponse)getResponse(); if (!response.containsHeader(name)) - response.setHeader("org.eclipse.jetty.server.include."+name,value);; + response.setHeader("org.eclipse.jetty.server.include."+name,value); } @Override protected PrintWriter newWriter(OutputStream out, String encoding) throws UnsupportedEncodingException diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/ProxyServlet.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/ProxyServlet.java index 7fa971838a5..6687903a6a5 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/ProxyServlet.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/ProxyServlet.java @@ -483,13 +483,20 @@ public class ProxyServlet implements Servlet @Override protected void onResponseHeader(Buffer name, Buffer value) throws IOException { - String s = name.toString().toLowerCase(); + String nameString = name.toString(); + String s = nameString.toLowerCase(); if (!_DontProxyHeaders.contains(s) || (HttpHeaders.CONNECTION_BUFFER.equals(name) && HttpHeaderValues.CLOSE_BUFFER.equals(value))) { if (debug != 0) _log.debug(debug + " " + name + ": " + value); - response.addHeader(name.toString(),value.toString()); + String filteredHeaderValue = filterResponseHeaderValue(nameString,value.toString(),request); + if (filteredHeaderValue != null && filteredHeaderValue.trim().length() > 0) + { + if (debug != 0) + _log.debug(debug + " " + name + ": (filtered): " + filteredHeaderValue); + response.addHeader(nameString,filteredHeaderValue); + } } else if (debug != 0) _log.debug(debug + " " + name + "! " + value); @@ -785,9 +792,23 @@ public class ProxyServlet implements Servlet } } + /** + * Extension point for remote server response header filtering. The default implementation returns the header value as is. If null is returned, this header + * won't be forwarded back to the client. + * + * @param headerName + * @param headerValue + * @param request + * @return filteredHeaderValue + */ + protected String filterResponseHeaderValue(String headerName, String headerValue, HttpServletRequest request) + { + return headerValue; + } + /** * Transparent Proxy. - * + * * This convenience extension to ProxyServlet configures the servlet as a transparent proxy. The servlet is configured with init parameters: *
      *
    • ProxyTo - a URI like http://host:80/context to which the request is proxied. @@ -795,7 +816,7 @@ public class ProxyServlet implements Servlet *
    * For example, if a request was received at /foo/bar and the ProxyTo was http://host:80/context and the Prefix was /foo, then the request would be proxied * to http://host:80/context/bar - * + * */ public static class Transparent extends ProxyServlet { diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractBalancerServletTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractBalancerServletTest.java new file mode 100644 index 00000000000..e798396adc8 --- /dev/null +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractBalancerServletTest.java @@ -0,0 +1,157 @@ +package org.eclipse.jetty.servlets; + +//======================================================================== +//Copyright (c) 2012 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. +//======================================================================== + +import java.io.IOException; + +import javax.servlet.http.HttpServlet; + +import org.eclipse.jetty.client.ContentExchange; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.http.HttpCookie; +import org.eclipse.jetty.http.HttpMethods; +import org.eclipse.jetty.io.Buffer; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.nio.SelectChannelConnector; +import org.eclipse.jetty.server.session.HashSessionIdManager; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.junit.After; +import org.junit.Before; + + +public abstract class AbstractBalancerServletTest +{ + + private boolean _stickySessions; + + private Server _node1; + + private Server _node2; + + private Server _balancerServer; + + private HttpClient _httpClient; + + @Before + public void setUp() throws Exception + { + _httpClient = new HttpClient(); + _httpClient.registerListener("org.eclipse.jetty.client.RedirectListener"); + _httpClient.start(); + } + + @After + public void tearDown() throws Exception + { + stopServer(_node1); + stopServer(_node2); + stopServer(_balancerServer); + _httpClient.stop(); + } + + private void stopServer(Server server) + { + try + { + server.stop(); + } + catch (Exception e) + { + // Do nothing + } + } + + protected void setStickySessions(boolean stickySessions) + { + _stickySessions = stickySessions; + } + + protected void startBalancer(Class httpServletClass) throws Exception + { + _node1 = createServer(new ServletHolder(httpServletClass.newInstance()),"/pipo","/molo/*"); + setSessionIdManager(_node1,"node1"); + _node1.start(); + + _node2 = createServer(new ServletHolder(httpServletClass.newInstance()),"/pipo","/molo/*"); + setSessionIdManager(_node2,"node2"); + _node2.start(); + + BalancerServlet balancerServlet = new BalancerServlet(); + ServletHolder balancerServletHolder = new ServletHolder(balancerServlet); + balancerServletHolder.setInitParameter("StickySessions",String.valueOf(_stickySessions)); + balancerServletHolder.setInitParameter("ProxyPassReverse","true"); + balancerServletHolder.setInitParameter("BalancerMember." + "node1" + ".ProxyTo","http://localhost:" + getServerPort(_node1)); + balancerServletHolder.setInitParameter("BalancerMember." + "node2" + ".ProxyTo","http://localhost:" + getServerPort(_node2)); + + _balancerServer = createServer(balancerServletHolder,"/pipo","/molo/*"); + _balancerServer.start(); + } + + private Server createServer(ServletHolder servletHolder, String appContext, String servletUrlPattern) + { + Server server = new Server(); + SelectChannelConnector httpConnector = new SelectChannelConnector(); + server.addConnector(httpConnector); + + ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); + context.setContextPath(appContext); + server.setHandler(context); + + context.addServlet(servletHolder,servletUrlPattern); + + return server; + } + + private void setSessionIdManager(Server node, String nodeName) + { + HashSessionIdManager sessionIdManager = new HashSessionIdManager(); + sessionIdManager.setWorkerName(nodeName); + node.setSessionIdManager(sessionIdManager); + } + + private int getServerPort(Server node) + { + return node.getConnectors()[0].getLocalPort(); + } + + protected byte[] sendRequestToBalancer(String requestUri) throws IOException, InterruptedException + { + ContentExchange exchange = new ContentExchange() + { + @Override + protected void onResponseHeader(Buffer name, Buffer value) throws IOException + { + // Cookie persistence + if (name.toString().equals("Set-Cookie")) + { + String cookieVal = value.toString(); + if (cookieVal.startsWith("JSESSIONID=")) + { + String jsessionid = cookieVal.split(";")[0].substring("JSESSIONID=".length()); + _httpClient.getDestination(getAddress(),false).addCookie(new HttpCookie("JSESSIONID",jsessionid)); + } + } + } + }; + exchange.setURL("http://localhost:" + getServerPort(_balancerServer) + "/pipo/molo/" + requestUri); + exchange.setMethod(HttpMethods.GET); + + _httpClient.send(exchange); + exchange.waitForDone(); + + return exchange.getResponseContentBytes(); + } + +} diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java index 44cb5d92bc2..1af2c1f0504 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/BalancerServletTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/BalancerServletTest.java new file mode 100644 index 00000000000..9513895fc61 --- /dev/null +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/BalancerServletTest.java @@ -0,0 +1,129 @@ +package org.eclipse.jetty.servlets; +//======================================================================== +//Copyright (c) 2012 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. +//======================================================================== + +import static org.junit.Assert.*; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Test; + +/** + * + */ +public class BalancerServletTest extends AbstractBalancerServletTest +{ + + @Test + public void testRoundRobinBalancer() throws Exception + { + setStickySessions(false); + startBalancer(CounterServlet.class); + + for (int i = 0; i < 10; i++) + { + byte[] responseBytes = sendRequestToBalancer("/"); + String returnedCounter = readFirstLine(responseBytes); + // RR : response should increment every other request + String expectedCounter = String.valueOf(i / 2); + assertEquals(expectedCounter,returnedCounter); + } + } + + @Test + public void testStickySessionsBalancer() throws Exception + { + setStickySessions(true); + startBalancer(CounterServlet.class); + + for (int i = 0; i < 10; i++) + { + byte[] responseBytes = sendRequestToBalancer("/"); + String returnedCounter = readFirstLine(responseBytes); + // RR : response should increment on each request + String expectedCounter = String.valueOf(i); + assertEquals(expectedCounter,returnedCounter); + } + } + + @Test + public void testProxyPassReverse() throws Exception + { + setStickySessions(false); + startBalancer(RelocationServlet.class); + + byte[] responseBytes = sendRequestToBalancer("index.html"); + String msg = readFirstLine(responseBytes); + assertEquals("success",msg); + } + + private String readFirstLine(byte[] responseBytes) throws IOException + { + BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(responseBytes))); + return reader.readLine(); + } + + @SuppressWarnings("serial") + public static final class CounterServlet extends HttpServlet + { + + private int counter; + + @Override + public void init() throws ServletException + { + counter = 0; + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + // Force session creation + req.getSession(); + resp.setContentType("text/plain"); + resp.getWriter().println(counter++); + } + } + + @SuppressWarnings("serial") + public static final class RelocationServlet extends HttpServlet + { + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + if (req.getRequestURI().endsWith("/index.html")) + { + resp.sendRedirect("http://localhost:" + req.getLocalPort() + req.getContextPath() + req.getServletPath() + "/other.html?secret=pipo%20molo"); + return; + } + resp.setContentType("text/plain"); + if ("pipo molo".equals(req.getParameter("secret"))) + { + resp.getWriter().println("success"); + } + else + { + resp.getWriter().println("failure"); + } + } + } + +} diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/CrossOriginFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/CrossOriginFilterTest.java index fb8d6bba490..d33c43152ce 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/CrossOriginFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/CrossOriginFilterTest.java @@ -1,3 +1,16 @@ +// ======================================================================== +// Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + package org.eclipse.jetty.servlets; import java.io.IOException; @@ -371,6 +384,51 @@ public class CrossOriginFilterTest Assert.assertTrue(latch.await(1, TimeUnit.SECONDS)); } + @Test + public void testSimpleRequestWithExposedHeaders() throws Exception + { + FilterHolder filterHolder = new FilterHolder(new CrossOriginFilter()); + filterHolder.setInitParameter("exposedHeaders", "Content-Length"); + tester.getContext().addFilter(filterHolder, "/*", FilterMapping.DEFAULT); + + CountDownLatch latch = new CountDownLatch(1); + tester.getContext().addServlet(new ServletHolder(new ResourceServlet(latch)), "/*"); + + String request = "" + + "GET / HTTP/1.1\r\n" + + "Host: localhost\r\n" + + "Origin: http://localhost\r\n" + + "\r\n"; + String response = tester.getResponses(request); + Assert.assertTrue(response.contains("HTTP/1.1 200")); + Assert.assertTrue(response.contains(CrossOriginFilter.ACCESS_CONTROL_EXPOSE_HEADERS_HEADER)); + Assert.assertTrue(latch.await(1, TimeUnit.SECONDS)); + } + + @Test + public void testForwardPreflightRequest() throws Exception + { + FilterHolder filterHolder = new FilterHolder(new CrossOriginFilter()); + filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "PUT"); + filterHolder.setInitParameter(CrossOriginFilter.FORWARD_PREFLIGHT_PARAM, "false"); + tester.getContext().addFilter(filterHolder, "/*", FilterMapping.DEFAULT); + + CountDownLatch latch = new CountDownLatch(1); + tester.getContext().addServlet(new ServletHolder(new ResourceServlet(latch)), "/*"); + + // Preflight request + String request = "" + + "OPTIONS / HTTP/1.1\r\n" + + "Host: localhost\r\n" + + CrossOriginFilter.ACCESS_CONTROL_REQUEST_METHOD_HEADER + ": PUT\r\n" + + "Origin: http://localhost\r\n" + + "\r\n"; + String response = tester.getResponses(request); + Assert.assertTrue(response.contains("HTTP/1.1 200")); + Assert.assertTrue(response.contains(CrossOriginFilter.ACCESS_CONTROL_ALLOW_METHODS_HEADER)); + Assert.assertFalse(latch.await(1, TimeUnit.SECONDS)); + } + public static class ResourceServlet extends HttpServlet { private static final long serialVersionUID = 1L; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java index a214ce33971..757af84bc10 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java @@ -1,15 +1,14 @@ -// ======================================================================== -// Copyright 2009 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. //======================================================================== package org.eclipse.jetty.servlets; 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 c752591bc25..60307270b4a 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,4 +1,16 @@ package org.eclipse.jetty.servlets; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.util.Arrays; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultNoRecompressTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultNoRecompressTest.java index a890b96b628..8920bf08b6a 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultNoRecompressTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultNoRecompressTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.IOException; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java index 8fd8a0336f9..38496601c69 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; import java.util.Arrays; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipWithPipeliningTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipWithPipeliningTest.java index a77d1a39e58..13e396f4a25 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipWithPipeliningTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipWithPipeliningTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.greaterThan; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PipelineHelper.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PipelineHelper.java index ad58c1bad6e..3ea4641cf9b 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PipelineHelper.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PipelineHelper.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.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; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/ProxyServletTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/ProxyServletTest.java index 80e1fe396fa..04f06623fb1 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/ProxyServletTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/ProxyServletTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.FileInputStream; 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 9fb1720c8a1..fa332f6dff1 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,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/Hex.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/Hex.java index ee17583c92b..3d1608f7a9d 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/Hex.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/Hex.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public final class Hex { diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/NoOpOutputStream.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/NoOpOutputStream.java index 0a3c857a0ab..bb457d7682e 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/NoOpOutputStream.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/NoOpOutputStream.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.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.OutputStream; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestDirContentServlet.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestDirContentServlet.java index 440528b332b..4b95545e996 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestDirContentServlet.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestDirContentServlet.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.ByteArrayOutputStream; import java.io.File; 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 index 3a3c9897f6c..7b071cf2e04 100644 --- 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 @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletLengthStreamTypeWrite.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletLengthStreamTypeWrite.java index 5c5cd4810b3..01873fedcca 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletLengthStreamTypeWrite.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletLengthStreamTypeWrite.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletLengthTypeStreamWrite.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletLengthTypeStreamWrite.java index 4cf6a4acafe..aa7b0908890 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletLengthTypeStreamWrite.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletLengthTypeStreamWrite.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamLengthTypeWrite.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamLengthTypeWrite.java index f10d5305ce3..271f1432170 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamLengthTypeWrite.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamLengthTypeWrite.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamTypeLengthWrite.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamTypeLengthWrite.java index efd5bcdc12e..9c85cc139a1 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamTypeLengthWrite.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletStreamTypeLengthWrite.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletTypeLengthStreamWrite.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletTypeLengthStreamWrite.java index 7551d4d4a6a..9185cd3e033 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletTypeLengthStreamWrite.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletTypeLengthStreamWrite.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletTypeStreamLengthWrite.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletTypeStreamLengthWrite.java index 9efc34d43ea..87f04c204d9 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletTypeStreamLengthWrite.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestServletTypeStreamLengthWrite.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestStaticMimeTypeServlet.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestStaticMimeTypeServlet.java index 298fc0aa9be..fd85fc3b73b 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestStaticMimeTypeServlet.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/TestStaticMimeTypeServlet.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.servlets.gzip; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-spdy/pom.xml b/jetty-spdy/pom.xml index 75b43fe7462..51dd090e0c6 100644 --- a/jetty-spdy/pom.xml +++ b/jetty-spdy/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 diff --git a/jetty-spdy/spdy-core/pom.xml b/jetty-spdy/spdy-core/pom.xml index aeac9d6393f..1e205ea9712 100644 --- a/jetty-spdy/spdy-core/pom.xml +++ b/jetty-spdy/spdy-core/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.spdy spdy-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ByteBufferPool.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ByteBufferPool.java index 68eac61ac04..e2964cc0f00 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ByteBufferPool.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ByteBufferPool.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/CompressionDictionary.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/CompressionDictionary.java index 0aa024d30f7..8b8b83a134c 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/CompressionDictionary.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/CompressionDictionary.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/CompressionFactory.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/CompressionFactory.java index f81a5b3f491..620c24ac100 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/CompressionFactory.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/CompressionFactory.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Controller.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Controller.java index 998efd57749..75e26ef934c 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Controller.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Controller.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/FlowControlStrategy.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/FlowControlStrategy.java index e4a6e4502be..c08bc421218 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/FlowControlStrategy.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/FlowControlStrategy.java @@ -1,19 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; import org.eclipse.jetty.spdy.api.DataInfo; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ISession.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ISession.java index c69af218385..41bbfd7da87 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ISession.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ISession.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/IStream.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/IStream.java index dcaa3b01f80..ad75f406a7f 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/IStream.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/IStream.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/IdleListener.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/IdleListener.java index 8ca26add0d5..42e44496790 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/IdleListener.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/IdleListener.java @@ -1,19 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +///======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; public interface IdleListener diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Promise.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Promise.java index 6f107874d54..b08cde8c498 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Promise.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Promise.java @@ -1,21 +1,19 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; +import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -89,6 +87,8 @@ public class Promise implements Handler, Future private T result() throws ExecutionException { + if (isCancelled()) + throw new CancellationException(); Throwable failure = this.failure; if (failure != null) throw new ExecutionException(failure); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/PushSynInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/PushSynInfo.java index a460d54d7d4..8befef43edb 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/PushSynInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/PushSynInfo.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.spdy; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.spdy.api.SynInfo; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SPDYv3FlowControlStrategy.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SPDYv3FlowControlStrategy.java index 0b7fe2c202f..8eb4b0ebdfe 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SPDYv3FlowControlStrategy.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SPDYv3FlowControlStrategy.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SessionException.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SessionException.java index fa9a55e7c3a..65f375412d1 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SessionException.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/SessionException.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardByteBufferPool.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardByteBufferPool.java index 3ecc001da7c..60b6190bf24 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardByteBufferPool.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardByteBufferPool.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardCompressionFactory.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardCompressionFactory.java index f0a7eebbdff..1e7e6e084d3 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardCompressionFactory.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardCompressionFactory.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java index d97d41db003..d5524e2f617 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; +import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.InterruptedByTimeoutException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -64,10 +64,13 @@ import org.eclipse.jetty.spdy.frames.SynStreamFrame; import org.eclipse.jetty.spdy.frames.WindowUpdateFrame; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; +import org.eclipse.jetty.util.Atomics; +import org.eclipse.jetty.util.component.AggregateLifeCycle; +import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -public class StandardSession implements ISession, Parser.Listener, Handler +public class StandardSession implements ISession, Parser.Listener, Handler, Dumpable { private static final Logger logger = Log.getLogger(Session.class); private static final ThreadLocal handlerInvocations = new ThreadLocal() @@ -79,6 +82,7 @@ public class StandardSession implements ISession, Parser.Listener, Handler attributes = new ConcurrentHashMap<>(); private final List listeners = new CopyOnWriteArrayList<>(); private final ConcurrentMap streams = new ConcurrentHashMap<>(); private final LinkedList queue = new LinkedList<>(); @@ -208,7 +212,7 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler) { SettingsFrame frame = new SettingsFrame(version,settingsInfo.getFlags(),settingsInfo.getSettings()); - control(null,frame,timeout,unit,handler,null); + control(null, frame, timeout, unit, handler, null); } @Override @@ -244,7 +248,7 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler) { - goAway(SessionStatus.OK,timeout,unit,handler); + goAway(SessionStatus.OK, timeout, unit, handler); } private void goAway(SessionStatus sessionStatus, long timeout, TimeUnit unit, Handler handler) @@ -269,6 +273,30 @@ public class StandardSession implements ISession, Parser.Listener, Handler oldValue) - { - if (lastStreamId.compareAndSet(oldValue,streamId)) - break; - oldValue = lastStreamId.get(); - } - } + if (streamId % 2 != streamIds.get() % 2) + Atomics.updateMax(lastStreamId, streamId); } @Override @@ -1076,6 +1093,27 @@ public class StandardSession implements ISession, Parser.Listener, Handler { public IStream getStream(); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardStream.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardStream.java index e655afe1452..360a6395919 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardStream.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardStream.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; @@ -29,7 +26,6 @@ import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.RstInfo; -import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.StreamStatus; @@ -37,7 +33,6 @@ import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.HeadersFrame; import org.eclipse.jetty.spdy.frames.SynReplyFrame; -import org.eclipse.jetty.spdy.frames.SynStreamFrame; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -45,9 +40,10 @@ public class StandardStream implements IStream { private static final Logger logger = Log.getLogger(Stream.class); private final Map attributes = new ConcurrentHashMap<>(); - private final IStream associatedStream; - private final SynStreamFrame frame; + private final int id; + private final byte priority; private final ISession session; + private final IStream associatedStream; private final AtomicInteger windowSize = new AtomicInteger(); private final Set pushedStreams = Collections.newSetFromMap(new ConcurrentHashMap()); private volatile StreamFrameListener listener; @@ -55,9 +51,10 @@ public class StandardStream implements IStream private volatile CloseState closeState = CloseState.OPENED; private volatile boolean reset = false; - public StandardStream(SynStreamFrame frame, ISession session, IStream associatedStream) + public StandardStream(int id, byte priority, ISession session, IStream associatedStream) { - this.frame = frame; + this.id = id; + this.priority = priority; this.session = session; this.associatedStream = associatedStream; } @@ -65,7 +62,7 @@ public class StandardStream implements IStream @Override public int getId() { - return frame.getStreamId(); + return id; } @Override @@ -95,7 +92,7 @@ public class StandardStream implements IStream @Override public byte getPriority() { - return frame.getPriority(); + return priority; } @Override @@ -112,7 +109,7 @@ public class StandardStream implements IStream } @Override - public Session getSession() + public ISession getSession() { return session; } @@ -141,6 +138,11 @@ public class StandardStream implements IStream this.listener = listener; } + public StreamFrameListener getStreamFrameListener() + { + return listener; + } + @Override public void updateCloseState(boolean close, boolean local) { @@ -150,7 +152,7 @@ public class StandardStream implements IStream { case OPENED: { - closeState = local?CloseState.LOCALLY_CLOSED:CloseState.REMOTELY_CLOSED; + closeState = local ? CloseState.LOCALLY_CLOSED : CloseState.REMOTELY_CLOSED; break; } case LOCALLY_CLOSED: @@ -191,16 +193,16 @@ public class StandardStream implements IStream { openState = OpenState.REPLY_RECV; SynReplyFrame synReply = (SynReplyFrame)frame; - updateCloseState(synReply.isClose(),false); - ReplyInfo replyInfo = new ReplyInfo(synReply.getHeaders(),synReply.isClose()); + updateCloseState(synReply.isClose(), false); + ReplyInfo replyInfo = new ReplyInfo(synReply.getHeaders(), synReply.isClose()); notifyOnReply(replyInfo); break; } case HEADERS: { HeadersFrame headers = (HeadersFrame)frame; - updateCloseState(headers.isClose(),false); - HeadersInfo headersInfo = new HeadersInfo(headers.getHeaders(),headers.isClose(),headers.isResetCompression()); + updateCloseState(headers.isClose(), false); + HeadersInfo headersInfo = new HeadersInfo(headers.getHeaders(), headers.isClose(), headers.isResetCompression()); notifyOnHeaders(headersInfo); break; } @@ -269,7 +271,7 @@ public class StandardStream implements IStream { if (listener != null) { - logger.debug("Invoking headers callback with {} on listener {}", frame, listener); + logger.debug("Invoking headers callback with {} on listener {}", headersInfo, listener); listener.onHeaders(this, headersInfo); } } @@ -320,11 +322,11 @@ public class StandardStream implements IStream { if (isClosed() || isReset()) { - handler.failed(this, new StreamException(getId(),StreamStatus.STREAM_ALREADY_CLOSED)); + handler.failed(this, new StreamException(getId(), StreamStatus.STREAM_ALREADY_CLOSED)); return; } - PushSynInfo pushSynInfo = new PushSynInfo(getId(),synInfo); - session.syn(pushSynInfo,null,timeout,unit,handler); + PushSynInfo pushSynInfo = new PushSynInfo(getId(), synInfo); + session.syn(pushSynInfo, null, timeout, unit, handler); } @Override @@ -341,9 +343,9 @@ public class StandardStream implements IStream if (isUnidirectional()) throw new IllegalStateException("Protocol violation: cannot send SYN_REPLY frames in unidirectional streams"); openState = OpenState.REPLY_SENT; - updateCloseState(replyInfo.isClose(),true); - SynReplyFrame frame = new SynReplyFrame(session.getVersion(),replyInfo.getFlags(),getId(),replyInfo.getHeaders()); - session.control(this,frame,timeout,unit,handler,null); + updateCloseState(replyInfo.isClose(), true); + SynReplyFrame frame = new SynReplyFrame(session.getVersion(), replyInfo.getFlags(), getId(), replyInfo.getHeaders()); + session.control(this, frame, timeout, unit, handler, null); } @Override @@ -359,18 +361,18 @@ public class StandardStream implements IStream { if (!canSend()) { - session.rst(new RstInfo(getId(),StreamStatus.PROTOCOL_ERROR)); + session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR)); throw new IllegalStateException("Protocol violation: cannot send a DATA frame before a SYN_REPLY frame"); } if (isLocallyClosed()) { - session.rst(new RstInfo(getId(),StreamStatus.PROTOCOL_ERROR)); + session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR)); throw new IllegalStateException("Protocol violation: cannot send a DATA frame on a closed stream"); } // Cannot update the close state here, because the data that we send may // be flow controlled, so we need the stream to update the window size. - session.data(this,dataInfo,timeout,unit,handler,null); + session.data(this, dataInfo, timeout, unit, handler, null); } @Override @@ -386,18 +388,18 @@ public class StandardStream implements IStream { if (!canSend()) { - session.rst(new RstInfo(getId(),StreamStatus.PROTOCOL_ERROR)); + session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR)); throw new IllegalStateException("Protocol violation: cannot send a HEADERS frame before a SYN_REPLY frame"); } if (isLocallyClosed()) { - session.rst(new RstInfo(getId(),StreamStatus.PROTOCOL_ERROR)); + session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR)); throw new IllegalStateException("Protocol violation: cannot send a HEADERS frame on a closed stream"); } - updateCloseState(headersInfo.isClose(),true); - HeadersFrame frame = new HeadersFrame(session.getVersion(),headersInfo.getFlags(),getId(),headersInfo.getHeaders()); - session.control(this,frame,timeout,unit,handler,null); + updateCloseState(headersInfo.isClose(), true); + HeadersFrame frame = new HeadersFrame(session.getVersion(), headersInfo.getFlags(), getId(), headersInfo.getHeaders()); + session.control(this, frame, timeout, unit, handler, null); } @Override @@ -440,7 +442,7 @@ public class StandardStream implements IStream @Override public String toString() { - return String.format("stream=%d v%d %s",getId(),session.getVersion(),closeState); + return String.format("stream=%d v%d windowSize=%db reset=%s %s %s", getId(), session.getVersion(), getWindowSize(), isReset(), openState, closeState); } private boolean canSend() diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StreamException.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StreamException.java index 5b4bd7f4562..4a0a954918e 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StreamException.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StreamException.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ByteBufferDataInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ByteBufferDataInfo.java index 678ff516e36..3b856f66192 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ByteBufferDataInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ByteBufferDataInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; @@ -68,4 +65,10 @@ public class ByteBufferDataInfo extends DataInfo } return space; } + + @Override + protected ByteBuffer allocate(int size) + { + return buffer.isDirect() ? ByteBuffer.allocateDirect(size) : super.allocate(size); + } } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/BytesDataInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/BytesDataInfo.java index beeb9ef7606..9d2123b066f 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/BytesDataInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/BytesDataInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/DataInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/DataInfo.java index 40364017f57..8253e40fc86 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/DataInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/DataInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/GoAwayInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/GoAwayInfo.java index 4ebc7262fc6..1e16e345348 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/GoAwayInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/GoAwayInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Handler.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Handler.java index c94d5efadcf..b69467e368d 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Handler.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Handler.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Headers.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Headers.java index 31615006042..261a94f730d 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Headers.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Headers.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; @@ -219,13 +216,15 @@ public class Headers implements Iterable if (obj == null || getClass() != obj.getClass()) return false; Header that = (Header)obj; - return name.equals(that.name) && Arrays.equals(values, that.values); + // Header names must be lowercase, thus we lowercase them before transmission, but keep them as is + // internally. That's why we've to compare them case insensitive. + return name.equalsIgnoreCase(that.name) && Arrays.equals(values, that.values); } @Override public int hashCode() { - int result = name.hashCode(); + int result = name.toLowerCase().hashCode(); result = 31 * result + Arrays.hashCode(values); return result; } @@ -268,6 +267,21 @@ public class Headers implements Iterable return values; } + /** + * @return the values as a comma separated list + */ + public String valuesAsString() + { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < values.length; ++i) + { + if (i > 0) + result.append(", "); + result.append(values[i]); + } + return result.toString(); + } + /** * @return whether the header has multiple values */ diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/HeadersInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/HeadersInfo.java index 62ae07f6091..97a6a7e59cb 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/HeadersInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/HeadersInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/PingInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/PingInfo.java index bbcd9a87d08..28bc7a7c993 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/PingInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/PingInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ReplyInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ReplyInfo.java index 9ce0ef6eb5d..9e511436e61 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ReplyInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/ReplyInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/RstInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/RstInfo.java index f1f5ee482a0..101fd713967 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/RstInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/RstInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SPDY.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SPDY.java index 8ec2d8d6687..31d7620ad55 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SPDY.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SPDY.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SPDYException.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SPDYException.java index a0585f7ad73..af21428e877 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SPDYException.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SPDYException.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Session.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Session.java index 5e2e5e281d7..bbe17fc7295 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Session.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Session.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; @@ -75,7 +72,7 @@ public interface Session * @see #syn(SynInfo, StreamFrameListener, long, TimeUnit, Handler) */ public Future syn(SynInfo synInfo, StreamFrameListener listener); - + /** *

    Sends asynchronously a SYN_FRAME to create a new {@link Stream SPDY stream}.

    *

    Callers may pass a non-null completion handler to be notified of when the @@ -90,7 +87,7 @@ public interface Session */ public void syn(SynInfo synInfo, StreamFrameListener listener, long timeout, TimeUnit unit, Handler handler); - + /** *

    Sends asynchronously a RST_STREAM to abort a stream.

    *

    Callers may use the returned future to wait for the reset to be sent.

    @@ -180,10 +177,40 @@ public interface Session public void goAway(long timeout, TimeUnit unit, Handler handler); /** - * @return the streams currently active in this session + * @return a snapshot of the streams currently active in this session + * @see #getStream(int) */ public Set getStreams(); + /** + * @param streamId the id of the stream to retrieve + * @return the stream with the given stream id + * @see #getStreams() + */ + public Stream getStream(int streamId); + + /** + * @param key the attribute key + * @return an arbitrary object associated with the given key to this session + * @see #setAttribute(String, Object) + */ + public Object getAttribute(String key); + + /** + * @param key the attribute key + * @param value an arbitrary object to associate with the given key to this session + * @see #getAttribute(String) + * @see #removeAttribute(String) + */ + public void setAttribute(String key, Object value); + + /** + * @param key the attribute key + * @return the arbitrary object associated with the given key to this session + * @see #setAttribute(String, Object) + */ + public Object removeAttribute(String key); + /** *

    Super interface for listeners with callbacks that are invoked on specific session events.

    */ diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SessionFrameListener.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SessionFrameListener.java index 467919c29cf..7e507e3fd84 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SessionFrameListener.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SessionFrameListener.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SessionStatus.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SessionStatus.java index c9c40d137f5..56e9355ef15 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SessionStatus.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SessionStatus.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Settings.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Settings.java index 6db03e814c8..6ed59a00dbb 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Settings.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Settings.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SettingsInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SettingsInfo.java index 3823382d3d3..d622189797c 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SettingsInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SettingsInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Stream.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Stream.java index c7f6e3537d8..092c7a35499 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Stream.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Stream.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StreamFrameListener.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StreamFrameListener.java index a279f38a01d..23b5b169439 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StreamFrameListener.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StreamFrameListener.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StreamStatus.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StreamStatus.java index c9908c8a146..b3e48e0b489 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StreamStatus.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StreamStatus.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StringDataInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StringDataInfo.java index b6a73cb6b16..164c6fb4302 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StringDataInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/StringDataInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SynInfo.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SynInfo.java index c51a0016dd0..3f8eb605df0 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SynInfo.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/SynInfo.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/server/ServerSessionFrameListener.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/server/ServerSessionFrameListener.java index 79415505698..7b330a9ceae 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/server/ServerSessionFrameListener.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/server/ServerSessionFrameListener.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api.server; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/ControlFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/ControlFrame.java index afd554c67e8..a9c7b0a5af6 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/ControlFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/ControlFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/ControlFrameType.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/ControlFrameType.java index e3b8f40ae7f..1fb28346d6d 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/ControlFrameType.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/ControlFrameType.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/CredentialFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/CredentialFrame.java index ac3e65b9d40..5bd882fb967 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/CredentialFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/CredentialFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/DataFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/DataFrame.java index 3ce17eeb9f7..e261bf8f5ee 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/DataFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/DataFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/GoAwayFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/GoAwayFrame.java index bda5755522f..15f04f1a4dc 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/GoAwayFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/GoAwayFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/HeadersFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/HeadersFrame.java index e0545b68703..ea88513075e 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/HeadersFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/HeadersFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/NoOpFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/NoOpFrame.java index bf9eac00f3f..e4cffcc3f77 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/NoOpFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/NoOpFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/PingFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/PingFrame.java index aa1ac543d27..3989a09ccc0 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/PingFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/PingFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/RstStreamFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/RstStreamFrame.java index 334b8166ac6..0877da45d52 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/RstStreamFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/RstStreamFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SettingsFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SettingsFrame.java index afddb371fa7..8b676cde732 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SettingsFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SettingsFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynReplyFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynReplyFrame.java index 91081686382..82888b14bf6 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynReplyFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynReplyFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynStreamFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynStreamFrame.java index f74ae92799f..c5aa8d3bc5b 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynStreamFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/SynStreamFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/WindowUpdateFrame.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/WindowUpdateFrame.java index 22a4129e769..8ed37d4784c 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/WindowUpdateFrame.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/frames/WindowUpdateFrame.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/ControlFrameGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/ControlFrameGenerator.java index c872beddb67..ff7302cfc7a 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/ControlFrameGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/ControlFrameGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/CredentialGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/CredentialGenerator.java index f46d39313fb..f2064fb68fd 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/CredentialGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/CredentialGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/DataFrameGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/DataFrameGenerator.java index 075cbc081f7..aed8fbc7583 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/DataFrameGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/DataFrameGenerator.java @@ -1,19 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/Generator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/Generator.java index 4f114b75451..cccbf15586c 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/Generator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/Generator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/GoAwayGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/GoAwayGenerator.java index 80c824f860a..dced42a64ee 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/GoAwayGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/GoAwayGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersBlockGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersBlockGenerator.java index 93a2dd6210b..6290841b794 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersBlockGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersBlockGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; @@ -43,7 +40,7 @@ public class HeadersBlockGenerator writeCount(version, buffer, headers.size()); for (Headers.Header header : headers) { - String name = header.name(); + String name = header.name().toLowerCase(); byte[] nameBytes = name.getBytes(iso1); writeNameLength(version, buffer, nameBytes.length); buffer.write(nameBytes, 0, nameBytes.length); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersGenerator.java index 9a894f6c0af..6f520d91ea0 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/NoOpGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/NoOpGenerator.java index 5678df329cb..86a2feb5c03 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/NoOpGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/NoOpGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/PingGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/PingGenerator.java index ae2a3e4ebc8..0ead892baa5 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/PingGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/PingGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/RstStreamGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/RstStreamGenerator.java index d7d1a21af6f..63a014250ee 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/RstStreamGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/RstStreamGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SettingsGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SettingsGenerator.java index c61846ebd84..6004afa905a 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SettingsGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SettingsGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynReplyGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynReplyGenerator.java index 4820086da20..fc8f3827007 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynReplyGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynReplyGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynStreamGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynStreamGenerator.java index 50371d6dabc..ff6ace8699e 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynStreamGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynStreamGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/WindowUpdateGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/WindowUpdateGenerator.java index 329d058489a..38092803cf2 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/WindowUpdateGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/WindowUpdateGenerator.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.generator; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/ControlFrameBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/ControlFrameBodyParser.java index a9499a8ad41..f820b599c87 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/ControlFrameBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/ControlFrameBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/ControlFrameParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/ControlFrameParser.java index d7c9a6586c7..73c01898664 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/ControlFrameParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/ControlFrameParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/CredentialBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/CredentialBodyParser.java index c79129ce163..0dbb3d6b8ea 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/CredentialBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/CredentialBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/DataFrameParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/DataFrameParser.java index 74ea686837f..1926ab7352e 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/DataFrameParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/DataFrameParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/GoAwayBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/GoAwayBodyParser.java index 926948c4f4a..cb9fd37d93a 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/GoAwayBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/GoAwayBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBlockParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBlockParser.java index 2b4b70bafb8..60725f821e3 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBlockParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBlockParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBodyParser.java index 208d66734aa..a91a19c5c39 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/HeadersBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/NoOpBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/NoOpBodyParser.java index ac14c798b55..f0efe09dd49 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/NoOpBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/NoOpBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/Parser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/Parser.java index 8cc42e18144..df897603b51 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/Parser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/Parser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/PingBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/PingBodyParser.java index 3f078f6e640..0e8ed613343 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/PingBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/PingBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/RstStreamBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/RstStreamBodyParser.java index 81c9b3ccf83..e05aea4906d 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/RstStreamBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/RstStreamBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SettingsBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SettingsBodyParser.java index d76382ad0e3..e4fc7c76cec 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SettingsBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SettingsBodyParser.java @@ -1,19 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; import java.nio.ByteBuffer; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynReplyBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynReplyBodyParser.java index ec58478f290..4c93210d3f0 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynReplyBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynReplyBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynStreamBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynStreamBodyParser.java index 4809dd40938..ba54e739f99 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynStreamBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/SynStreamBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameBodyParser.java index ea5890ff6f0..0de0d37eeb9 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/WindowUpdateBodyParser.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/WindowUpdateBodyParser.java index 697b885308d..9010a346bc1 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/WindowUpdateBodyParser.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/parser/WindowUpdateBodyParser.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/AsyncTimeoutTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/AsyncTimeoutTest.java index 3876f1ecc71..16af7c7a51b 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/AsyncTimeoutTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/AsyncTimeoutTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java index 07822e26676..6406f623aec 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; @@ -405,7 +402,7 @@ public class StandardSessionTest final CountDownLatch failedCalledLatch = new CountDownLatch(2); SynStreamFrame synStreamFrame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, null); - IStream stream = new StandardStream(synStreamFrame, session, null); + IStream stream = new StandardStream(synStreamFrame.getStreamId(), synStreamFrame.getPriority(), session, null); stream.updateWindowSize(8192); Handler.Adapter handler = new Handler.Adapter() { diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardStreamTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardStreamTest.java index 314905bf4a3..f75c7237395 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardStreamTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardStreamTest.java @@ -1,16 +1,15 @@ -// ======================================================================== -// 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. -// ======================================================================== - +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; @@ -46,15 +45,13 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; - -/* ------------------------------------------------------------ */ -/** - */ @RunWith(MockitoJUnitRunner.class) public class StandardStreamTest { - @Mock private ISession session; - @Mock private SynStreamFrame synStreamFrame; + @Mock + private ISession session; + @Mock + private SynStreamFrame synStreamFrame; /** * Test method for {@link org.eclipse.jetty.spdy.StandardStream#syn(org.eclipse.jetty.spdy.api.SynInfo)}. @@ -63,17 +60,18 @@ public class StandardStreamTest @Test public void testSyn() { - Stream stream = new StandardStream(synStreamFrame,session,null); + Stream stream = new StandardStream(synStreamFrame.getStreamId(), synStreamFrame.getPriority(), session, null); Set streams = new HashSet<>(); streams.add(stream); when(synStreamFrame.isClose()).thenReturn(false); SynInfo synInfo = new SynInfo(false); when(session.getStreams()).thenReturn(streams); stream.syn(synInfo); - verify(session).syn(argThat(new PushSynInfoMatcher(stream.getId(),synInfo)),any(StreamFrameListener.class),anyLong(),any(TimeUnit.class),any(Handler.class)); + verify(session).syn(argThat(new PushSynInfoMatcher(stream.getId(), synInfo)), any(StreamFrameListener.class), anyLong(), any(TimeUnit.class), any(Handler.class)); } - private class PushSynInfoMatcher extends ArgumentMatcher{ + private class PushSynInfoMatcher extends ArgumentMatcher + { int associatedStreamId; SynInfo synInfo; @@ -82,15 +80,18 @@ public class StandardStreamTest this.associatedStreamId = associatedStreamId; this.synInfo = synInfo; } + @Override public boolean matches(Object argument) { PushSynInfo pushSynInfo = (PushSynInfo)argument; - if(pushSynInfo.getAssociatedStreamId() != associatedStreamId){ + if (pushSynInfo.getAssociatedStreamId() != associatedStreamId) + { System.out.println("streamIds do not match!"); return false; } - if(pushSynInfo.isClose() != synInfo.isClose()){ + if (pushSynInfo.isClose() != synInfo.isClose()) + { System.out.println("isClose doesn't match"); return false; } @@ -99,13 +100,14 @@ public class StandardStreamTest } @Test - public void testSynOnClosedStream(){ - IStream stream = new StandardStream(synStreamFrame,session,null); - stream.updateCloseState(true,true); - stream.updateCloseState(true,false); - assertThat("stream expected to be closed",stream.isClosed(),is(true)); + public void testSynOnClosedStream() + { + IStream stream = new StandardStream(synStreamFrame.getStreamId(), synStreamFrame.getPriority(), session, null); + stream.updateCloseState(true, true); + stream.updateCloseState(true, false); + assertThat("stream expected to be closed", stream.isClosed(), is(true)); final CountDownLatch failedLatch = new CountDownLatch(1); - stream.syn(new SynInfo(false),1,TimeUnit.SECONDS,new Handler.Adapter() + stream.syn(new SynInfo(false), 1, TimeUnit.SECONDS, new Handler.Adapter() { @Override public void failed(Stream stream, Throwable x) @@ -121,7 +123,7 @@ public class StandardStreamTest public void testSendDataOnHalfClosedStream() throws InterruptedException, ExecutionException, TimeoutException { SynStreamFrame synStreamFrame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, null); - IStream stream = new StandardStream(synStreamFrame, session, null); + IStream stream = new StandardStream(synStreamFrame.getStreamId(), synStreamFrame.getPriority(), session, null); stream.updateWindowSize(8192); stream.updateCloseState(synStreamFrame.isClose(), true); assertThat("stream is half closed", stream.isHalfClosed(), is(true)); diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java index 18407c8aea2..9de7f49175a 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java index a8bff06d67b..b1a326fc17a 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.api; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/CredentialGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/CredentialGenerateParseTest.java index 0678c768ebc..e7db2c8c7a6 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/CredentialGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/CredentialGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/DataGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/DataGenerateParseTest.java index ea83e10dd93..6f53b64c09c 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/DataGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/DataGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/GoAwayGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/GoAwayGenerateParseTest.java index c32df12ba02..c3ae26d4368 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/GoAwayGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/GoAwayGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java index 99bd4b37edd..fd5a36de3d8 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; @@ -25,65 +22,77 @@ import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; -import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + public class HeadersGenerateParseTest { - @Test - public void testGenerateParse() throws Exception + + private Headers headers = new Headers(); + private int streamId = 13; + private byte flags = HeadersInfo.FLAG_RESET_COMPRESSION; + private final TestSPDYParserListener listener = new TestSPDYParserListener(); + private final Parser parser = new Parser(new StandardCompressionFactory().newDecompressor()); + private ByteBuffer buffer; + + @Before + public void setUp() { - byte flags = HeadersInfo.FLAG_RESET_COMPRESSION; - int streamId = 13; - Headers headers = new Headers(); + parser.addListener(listener); headers.put("a", "b"); + buffer = createHeadersFrameBuffer(headers); + } + + private ByteBuffer createHeadersFrameBuffer(Headers headers) + { HeadersFrame frame1 = new HeadersFrame(SPDY.V2, flags, streamId, headers); Generator generator = new Generator(new StandardByteBufferPool(), new StandardCompressionFactory().newCompressor()); ByteBuffer buffer = generator.control(frame1); + assertThat("Buffer is not null", buffer, notNullValue()); + return buffer; + } - Assert.assertNotNull(buffer); - - TestSPDYParserListener listener = new TestSPDYParserListener(); - Parser parser = new Parser(new StandardCompressionFactory().newDecompressor()); - parser.addListener(listener); + @Test + public void testGenerateParse() throws Exception + { parser.parse(buffer); - ControlFrame frame2 = listener.getControlFrame(); - - Assert.assertNotNull(frame2); - Assert.assertEquals(ControlFrameType.HEADERS, frame2.getType()); - HeadersFrame headersFrame = (HeadersFrame)frame2; - Assert.assertEquals(SPDY.V2, headersFrame.getVersion()); - Assert.assertEquals(streamId, headersFrame.getStreamId()); - Assert.assertEquals(flags, headersFrame.getFlags()); - Assert.assertEquals(headers, headersFrame.getHeaders()); + assertExpectationsAreMet(headers); } @Test public void testGenerateParseOneByteAtATime() throws Exception { - byte flags = HeadersInfo.FLAG_RESET_COMPRESSION; - int streamId = 13; - Headers headers = new Headers(); - headers.put("a", "b"); - HeadersFrame frame1 = new HeadersFrame(SPDY.V2, flags, streamId, headers); - Generator generator = new Generator(new StandardByteBufferPool(), new StandardCompressionFactory().newCompressor()); - ByteBuffer buffer = generator.control(frame1); - - Assert.assertNotNull(buffer); - - TestSPDYParserListener listener = new TestSPDYParserListener(); - Parser parser = new Parser(new StandardCompressionFactory().newDecompressor()); - parser.addListener(listener); while (buffer.hasRemaining()) parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()})); - ControlFrame frame2 = listener.getControlFrame(); - Assert.assertNotNull(frame2); - Assert.assertEquals(ControlFrameType.HEADERS, frame2.getType()); - HeadersFrame headersFrame = (HeadersFrame)frame2; - Assert.assertEquals(SPDY.V2, headersFrame.getVersion()); - Assert.assertEquals(streamId, headersFrame.getStreamId()); - Assert.assertEquals(flags, headersFrame.getFlags()); - Assert.assertEquals(headers, headersFrame.getHeaders()); + assertExpectationsAreMet(headers); + } + + @Test + public void testHeadersAreTranslatedToLowerCase() + { + Headers headers = new Headers(); + headers.put("Via","localhost"); + parser.parse(createHeadersFrameBuffer(headers)); + HeadersFrame parsedHeadersFrame = assertExpectationsAreMet(headers); + Headers.Header viaHeader = parsedHeadersFrame.getHeaders().get("via"); + assertThat("Via Header name is lowercase", viaHeader.name(), is("via")); + } + + private HeadersFrame assertExpectationsAreMet(Headers headers) + { + ControlFrame parsedControlFrame = listener.getControlFrame(); + assertThat("listener received controlFrame", parsedControlFrame, notNullValue()); + assertThat("ControlFrame type is HEADERS", ControlFrameType.HEADERS, is(parsedControlFrame.getType())); + HeadersFrame headersFrame = (HeadersFrame)parsedControlFrame; + assertThat("Version matches", SPDY.V2, is(headersFrame.getVersion())); + assertThat("StreamId matches", streamId, is(headersFrame.getStreamId())); + assertThat("flags match", flags, is(headersFrame.getFlags())); + assertThat("headers match", headers, is(headersFrame.getHeaders())); + return headersFrame; } } diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/NoOpGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/NoOpGenerateParseTest.java index 50afa5f4b6e..9c248be4ed6 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/NoOpGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/NoOpGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/PingGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/PingGenerateParseTest.java index 231406a6a9f..1bd87f86010 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/PingGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/PingGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/RstStreamGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/RstStreamGenerateParseTest.java index 378a3faf917..df70d3695d4 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/RstStreamGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/RstStreamGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SettingsGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SettingsGenerateParseTest.java index 3fc531b93ad..88b640d63cc 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SettingsGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SettingsGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java index ed51e826753..6da3189c542 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java index a1268a2db31..5cf4b223c17 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/TestSPDYParserListener.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/TestSPDYParserListener.java index 4642ca5d3bf..14e0cf35c87 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/TestSPDYParserListener.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/TestSPDYParserListener.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/WindowUpdateGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/WindowUpdateGenerateParseTest.java index 8f7dbee2117..41bdf676acf 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/WindowUpdateGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/WindowUpdateGenerateParseTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.frames; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/LiveChromiumRequestParserTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/LiveChromiumRequestParserTest.java index 56b65f0b6fe..46b7897f7ac 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/LiveChromiumRequestParserTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/LiveChromiumRequestParserTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/ParseVersusCacheBenchmarkTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/ParseVersusCacheBenchmarkTest.java index abaac53a2c2..cc92e0c6293 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/ParseVersusCacheBenchmarkTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/ParseVersusCacheBenchmarkTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy.parser; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java index ffecdc10b83..12c470c40ce 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java @@ -1,3 +1,16 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.parser; import java.nio.ByteBuffer; diff --git a/jetty-spdy/spdy-jetty-http-webapp/pom.xml b/jetty-spdy/spdy-jetty-http-webapp/pom.xml index f7d04ac3643..e3a3625e516 100644 --- a/jetty-spdy/spdy-jetty-http-webapp/pom.xml +++ b/jetty-spdy/spdy-jetty-http-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.spdy spdy-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 spdy-jetty-http-webapp @@ -60,4 +60,45 @@ --> + + + diff --git a/jetty-spdy/spdy-jetty-http-webapp/src/main/config/etc/jetty-spdy-proxy.xml b/jetty-spdy/spdy-jetty-http-webapp/src/main/config/etc/jetty-spdy-proxy.xml new file mode 100644 index 00000000000..9c637ec41f8 --- /dev/null +++ b/jetty-spdy/spdy-jetty-http-webapp/src/main/config/etc/jetty-spdy-proxy.xml @@ -0,0 +1,98 @@ + + + + + + + src/main/resources/keystore.jks + storepwd + src/main/resources/truststore.jks + storepwd + TLSv1 + + + + + + + + + 9090 + + + spdy/2 + + + + + + + + + + + + + + + + + + + spdy/2 + + + + + + localhost + + + spdy/2 + 127.0.0.1 + 9090 + + + + + + + + + + + + + 8080 + + + + + + + + + 8443 + + + + + + diff --git a/jetty-spdy/spdy-jetty-http-webapp/src/main/config/etc/jetty-spdy.xml b/jetty-spdy/spdy-jetty-http-webapp/src/main/config/etc/jetty-spdy.xml index 4218d4630e4..0d847bcbd48 100644 --- a/jetty-spdy/spdy-jetty-http-webapp/src/main/config/etc/jetty-spdy.xml +++ b/jetty-spdy/spdy-jetty-http-webapp/src/main/config/etc/jetty-spdy.xml @@ -11,11 +11,45 @@ TLSv1
    + + + + + + 8080 @@ -26,6 +60,24 @@ + + 8443 diff --git a/jetty-spdy/spdy-jetty-http/pom.xml b/jetty-spdy/spdy-jetty-http/pom.xml index 3a2c730eb6b..2aac0c0174a 100644 --- a/jetty-spdy/spdy-jetty-http/pom.xml +++ b/jetty-spdy/spdy-jetty-http/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.spdy spdy-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 spdy-jetty-http @@ -72,6 +72,11 @@ ${slf4j-version} test + + org.mockito + mockito-core + test + diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/AbstractHTTPSPDYServerConnector.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/AbstractHTTPSPDYServerConnector.java new file mode 100644 index 00000000000..543f78323ca --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/AbstractHTTPSPDYServerConnector.java @@ -0,0 +1,61 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + +package org.eclipse.jetty.spdy.http; + +import java.io.IOException; + +import org.eclipse.jetty.http.HttpSchemes; +import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.spdy.SPDYServerConnector; +import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.util.ssl.SslContextFactory; + +public class AbstractHTTPSPDYServerConnector extends SPDYServerConnector +{ + public AbstractHTTPSPDYServerConnector(ServerSessionFrameListener listener, SslContextFactory sslContextFactory) + { + super(listener, sslContextFactory); + } + + @Override + public void customize(EndPoint endPoint, Request request) throws IOException + { + super.customize(endPoint, request); + if (getSslContextFactory() != null) + request.setScheme(HttpSchemes.HTTPS); + } + + @Override + public boolean isConfidential(Request request) + { + if (getSslContextFactory() != null) + { + int confidentialPort = getConfidentialPort(); + return confidentialPort == 0 || confidentialPort == request.getServerPort(); + } + return super.isConfidential(request); + } + + @Override + public boolean isIntegral(Request request) + { + if (getSslContextFactory() != null) + { + int integralPort = getIntegralPort(); + return integralPort == 0 || integralPort == request.getServerPort(); + } + return super.isIntegral(request); + } +} diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYHeader.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYHeader.java index 76fed62346f..7149aa5ae0b 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYHeader.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYHeader.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYServerConnector.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYServerConnector.java index 4fb73d9d1ab..8b76589cb32 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYServerConnector.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYServerConnector.java @@ -1,89 +1,64 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; -import java.io.IOException; +import java.util.Collections; +import java.util.Map; -import org.eclipse.jetty.http.HttpSchemes; -import org.eclipse.jetty.io.EndPoint; -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.spdy.SPDYServerConnector; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.util.ssl.SslContextFactory; -public class HTTPSPDYServerConnector extends SPDYServerConnector +public class HTTPSPDYServerConnector extends AbstractHTTPSPDYServerConnector { public HTTPSPDYServerConnector() { - this(null, new PushStrategy.None()); + this(null, Collections.emptyMap()); } - public HTTPSPDYServerConnector(PushStrategy pushStrategy) + public HTTPSPDYServerConnector(Map pushStrategies) { - this(null, pushStrategy); + this(null, pushStrategies); } public HTTPSPDYServerConnector(SslContextFactory sslContextFactory) { - this(sslContextFactory, new PushStrategy.None()); + this(sslContextFactory, Collections.emptyMap()); } - public HTTPSPDYServerConnector(SslContextFactory sslContextFactory, PushStrategy pushStrategy) + public HTTPSPDYServerConnector(SslContextFactory sslContextFactory, Map pushStrategies) { // We pass a null ServerSessionFrameListener because for // HTTP over SPDY we need one that references the endPoint super(null, sslContextFactory); - // Override the "spdy/3" protocol by handling HTTP over SPDY - putAsyncConnectionFactory("spdy/3", new ServerHTTPSPDYAsyncConnectionFactory(SPDY.V3, getByteBufferPool(), getExecutor(), getScheduler(), this, pushStrategy)); - // Override the "spdy/2" protocol by handling HTTP over SPDY - putAsyncConnectionFactory("spdy/2", new ServerHTTPSPDYAsyncConnectionFactory(SPDY.V2, getByteBufferPool(), getExecutor(), getScheduler(), this, pushStrategy)); - // Add the "http/1.1" protocol for browsers that support NPN but not SPDY + clearAsyncConnectionFactories(); + // The "spdy/3" protocol handles HTTP over SPDY + putAsyncConnectionFactory("spdy/3", new ServerHTTPSPDYAsyncConnectionFactory(SPDY.V3, getByteBufferPool(), getExecutor(), getScheduler(), this, getPushStrategy(SPDY.V3,pushStrategies))); + // The "spdy/2" protocol handles HTTP over SPDY + putAsyncConnectionFactory("spdy/2", new ServerHTTPSPDYAsyncConnectionFactory(SPDY.V2, getByteBufferPool(), getExecutor(), getScheduler(), this, getPushStrategy(SPDY.V2,pushStrategies))); + // The "http/1.1" protocol handles browsers that support NPN but not SPDY putAsyncConnectionFactory("http/1.1", new ServerHTTPAsyncConnectionFactory(this)); - // Override the default connection factory for non-SSL connections to speak plain HTTP + // The default connection factory handles plain HTTP on non-SSL or non-NPN connections setDefaultAsyncConnectionFactory(getAsyncConnectionFactory("http/1.1")); } - @Override - public void customize(EndPoint endPoint, Request request) throws IOException + private PushStrategy getPushStrategy(short version, Map pushStrategies) { - super.customize(endPoint, request); - if (getSslContextFactory() != null) - request.setScheme(HttpSchemes.HTTPS); + PushStrategy pushStrategy = pushStrategies.get(version); + if(pushStrategy == null) + pushStrategy = new PushStrategy.None(); + return pushStrategy; } - @Override - public boolean isConfidential(Request request) - { - if (getSslContextFactory() != null) - { - int confidentialPort = getConfidentialPort(); - return confidentialPort == 0 || confidentialPort == request.getServerPort(); - } - return super.isConfidential(request); - } - - @Override - public boolean isIntegral(Request request) - { - if (getSslContextFactory() != null) - { - int integralPort = getIntegralPort(); - return integralPort == 0 || integralPort == request.getServerPort(); - } - return super.isIntegral(request); - } } diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/PushStrategy.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/PushStrategy.java index 780a5b22d1d..c15fe5baac9 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/PushStrategy.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/PushStrategy.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java index 52f1243d734..00798977266 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; @@ -23,6 +21,8 @@ import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; import java.util.regex.Pattern; import org.eclipse.jetty.spdy.api.Headers; @@ -37,12 +37,13 @@ import org.eclipse.jetty.util.log.Logger; * will have a Referer HTTP header that points to index.html, which we * use to link the associated resource to the main resource.

    *

    However, also following a hyperlink generates a HTTP request with a Referer - * HTTP header that points to index.html; therefore main resources and associated - * resources must be distinguishable.

    - *

    This class distinguishes associated resources by their URL path suffix and content + * HTTP header that points to index.html; therefore a proper value for {@link #getReferrerPushPeriod()} + * has to be set. If the referrerPushPeriod for a main resource has been passed, no more + * associated resources will be added for that main resource.

    + *

    This class distinguishes associated main resources by their URL path suffix and content * type. * CSS stylesheets, images and JavaScript files have recognizable URL path suffixes that - * are classified as associated resources.

    + * are classified as associated resources. The suffix regexs can be configured by constructor argument

    *

    When CSS stylesheets refer to images, the CSS image request will have the CSS * stylesheet as referrer. This implementation will push also the CSS image.

    *

    The push metadata built by this implementation is limited by the number of pages @@ -55,11 +56,12 @@ import org.eclipse.jetty.util.log.Logger; public class ReferrerPushStrategy implements PushStrategy { private static final Logger logger = Log.getLogger(ReferrerPushStrategy.class); - private final ConcurrentMap> resources = new ConcurrentHashMap<>(); + private final ConcurrentMap mainResources = new ConcurrentHashMap<>(); private final Set pushRegexps = new HashSet<>(); private final Set pushContentTypes = new HashSet<>(); private final Set allowedPushOrigins = new HashSet<>(); private volatile int maxAssociatedResources = 32; + private volatile int referrerPushPeriod = 5000; public ReferrerPushStrategy() { @@ -101,22 +103,33 @@ public class ReferrerPushStrategy implements PushStrategy this.maxAssociatedResources = maxAssociatedResources; } + public int getReferrerPushPeriod() + { + return referrerPushPeriod; + } + + public void setReferrerPushPeriod(int referrerPushPeriod) + { + this.referrerPushPeriod = referrerPushPeriod; + } + @Override public Set apply(Stream stream, Headers requestHeaders, Headers responseHeaders) { - Set result = Collections.emptySet(); + Set result = Collections.emptySet(); short version = stream.getSession().getVersion(); - String scheme = requestHeaders.get(HTTPSPDYHeader.SCHEME.name(version)).value(); - String host = requestHeaders.get(HTTPSPDYHeader.HOST.name(version)).value(); - String origin = new StringBuilder(scheme).append("://").append(host).toString(); - String url = requestHeaders.get(HTTPSPDYHeader.URI.name(version)).value(); - String absoluteURL = new StringBuilder(origin).append(url).toString(); - logger.debug("Applying push strategy for {}", absoluteURL); - if (isValidMethod(requestHeaders.get(HTTPSPDYHeader.METHOD.name(version)).value())) + if (!isIfModifiedSinceHeaderPresent(requestHeaders) && isValidMethod(requestHeaders.get(HTTPSPDYHeader.METHOD.name(version)).value())) { + String scheme = requestHeaders.get(HTTPSPDYHeader.SCHEME.name(version)).value(); + String host = requestHeaders.get(HTTPSPDYHeader.HOST.name(version)).value(); + String origin = scheme + "://" + host; + String url = requestHeaders.get(HTTPSPDYHeader.URI.name(version)).value(); + String absoluteURL = origin + url; + logger.debug("Applying push strategy for {}", absoluteURL); if (isMainResource(url, responseHeaders)) { - result = pushResources(absoluteURL); + MainResource mainResource = getOrCreateMainResource(absoluteURL); + result = mainResource.getResources(); } else if (isPushResource(url, responseHeaders)) { @@ -124,18 +137,49 @@ public class ReferrerPushStrategy implements PushStrategy if (referrerHeader != null) { String referrer = referrerHeader.value(); - Set pushResources = resources.get(referrer); - if (pushResources == null || !pushResources.contains(url)) - buildMetadata(origin, url, referrer); + MainResource mainResource = mainResources.get(referrer); + if (mainResource == null) + mainResource = getOrCreateMainResource(referrer); + + Set pushResources = mainResource.getResources(); + if (!pushResources.contains(url)) + mainResource.addResource(url, origin, referrer); else - result = pushResources(absoluteURL); + result = getPushResources(absoluteURL); } } + logger.debug("Pushing {} resources for {}: {}", result.size(), absoluteURL, result); } - logger.debug("Push resources for {}: {}", absoluteURL, result); return result; } + private Set getPushResources(String absoluteURL) + { + Set result = Collections.emptySet(); + if (mainResources.get(absoluteURL) != null) + result = mainResources.get(absoluteURL).getResources(); + return result; + } + + private MainResource getOrCreateMainResource(String absoluteURL) + { + MainResource mainResource = mainResources.get(absoluteURL); + if (mainResource == null) + { + logger.debug("Creating new main resource for {}", absoluteURL); + MainResource value = new MainResource(absoluteURL); + mainResource = mainResources.putIfAbsent(absoluteURL, value); + if (mainResource == null) + mainResource = value; + } + return mainResource; + } + + private boolean isIfModifiedSinceHeaderPresent(Headers headers) + { + return headers.get("if-modified-since") != null; + } + private boolean isValidMethod(String method) { return "GET".equalsIgnoreCase(method); @@ -165,49 +209,71 @@ public class ReferrerPushStrategy implements PushStrategy return false; } - private Set pushResources(String absoluteURL) + private class MainResource { - Set pushResources = resources.get(absoluteURL); - if (pushResources == null) - return Collections.emptySet(); - return Collections.unmodifiableSet(pushResources); - } + private final String name; + private final Set resources = Collections.newSetFromMap(new ConcurrentHashMap()); + private final AtomicLong firstResourceAdded = new AtomicLong(-1); - private void buildMetadata(String origin, String url, String referrer) - { - if (referrer.startsWith(origin) || isPushOriginAllowed(origin)) + private MainResource(String name) { - Set pushResources = resources.get(referrer); - if (pushResources == null) + this.name = name; + } + + public boolean addResource(String url, String origin, String referrer) + { + // We start the push period here and not when initializing the main resource, because a browser with a + // prefilled cache won't request the subresources. If the browser with warmed up cache now hits the main + // resource after a server restart, the push period shouldn't start until the first subresource is + // being requested. + firstResourceAdded.compareAndSet(-1, System.nanoTime()); + + long delay = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - firstResourceAdded.get()); + if (!referrer.startsWith(origin) && !isPushOriginAllowed(origin)) { - pushResources = Collections.newSetFromMap(new ConcurrentHashMap()); - Set existing = resources.putIfAbsent(referrer, pushResources); - if (existing != null) - pushResources = existing; + logger.debug("Skipped store of push metadata {} for {}: Origin: {} doesn't match or origin not allowed", + url, name, origin); + return false; } + // This check is not strictly concurrent-safe, but limiting // the number of associated resources is achieved anyway // although in rare cases few more resources will be stored - if (pushResources.size() < getMaxAssociatedResources()) - { - pushResources.add(url); - logger.debug("Stored push metadata for {}: {}", referrer, pushResources); - } - else + if (resources.size() >= maxAssociatedResources) { logger.debug("Skipped store of push metadata {} for {}: max associated resources ({}) reached", - url, referrer, maxAssociatedResources); + url, name, maxAssociatedResources); + return false; + } + if (delay > referrerPushPeriod) + { + logger.debug("Delay: {}ms longer than referrerPushPeriod: {}ms. Not adding resource: {} for: {}", delay, referrerPushPeriod, url, name); + return false; } - } - } - private boolean isPushOriginAllowed(String origin) - { - for (Pattern allowedPushOrigin : allowedPushOrigins) - { - if (allowedPushOrigin.matcher(origin).matches()) - return true; + logger.debug("Adding resource: {} for: {} with delay: {}ms.", url, name, delay); + resources.add(url); + return true; + } + + public Set getResources() + { + return Collections.unmodifiableSet(resources); + } + + public String toString() + { + return "MainResource: " + name + " associated resources:" + resources.size(); + } + + private boolean isPushOriginAllowed(String origin) + { + for (Pattern allowedPushOrigin : allowedPushOrigins) + { + if (allowedPushOrigin.matcher(origin).matches()) + return true; + } + return false; } - return false; } } diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPAsyncConnectionFactory.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPAsyncConnectionFactory.java index 3622b2fdf69..b0bae06de1c 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPAsyncConnectionFactory.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPAsyncConnectionFactory.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; @@ -21,18 +19,23 @@ import java.nio.channels.SocketChannel; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.nio.AsyncConnection; import org.eclipse.jetty.server.AsyncHttpConnection; -import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.spdy.AsyncConnectionFactory; +import org.eclipse.jetty.spdy.SPDYServerConnector; public class ServerHTTPAsyncConnectionFactory implements AsyncConnectionFactory { - private final Connector connector; + private final SPDYServerConnector connector; - public ServerHTTPAsyncConnectionFactory(Connector connector) + public ServerHTTPAsyncConnectionFactory(SPDYServerConnector connector) { this.connector = connector; } + public SPDYServerConnector getConnector() + { + return connector; + } + @Override public AsyncConnection newAsyncConnection(SocketChannel channel, AsyncEndPoint endPoint, Object attachment) { diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnection.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnection.java index 5fb09f555c9..ecc241ea975 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnection.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnection.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; @@ -55,6 +53,7 @@ import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.RstInfo; +import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamStatus; import org.eclipse.jetty.spdy.api.SynInfo; @@ -177,6 +176,10 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem logger.debug("HTTP > {} {} {}", m, u, v); startRequest(new ByteArrayBuffer(m), new ByteArrayBuffer(u), new ByteArrayBuffer(v)); + Headers.Header schemeHeader = headers.get(HTTPSPDYHeader.SCHEME.name(this.version)); + if(schemeHeader != null) + _request.setScheme(schemeHeader.value()); + updateState(State.HEADERS); handle(); break; @@ -403,7 +406,7 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem if (!stream.isUnidirectional()) stream.reply(replyInfo); if (replyInfo.getHeaders().get(HTTPSPDYHeader.STATUS.name(version)).value().startsWith("200") && - !stream.isClosed() && !isIfModifiedSinceHeaderPresent()) + !stream.isClosed()) { // We have a 200 OK with some content to send @@ -411,19 +414,12 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem Headers.Header host = headers.get(HTTPSPDYHeader.HOST.name(version)); Headers.Header uri = headers.get(HTTPSPDYHeader.URI.name(version)); Set pushResources = pushStrategy.apply(stream, headers, replyInfo.getHeaders()); - String referrer = new StringBuilder(scheme.value()).append("://").append(host.value()).append(uri.value()).toString(); - for (String pushURL : pushResources) + + for (String pushResourcePath : pushResources) { - final Headers pushHeaders = new Headers(); - pushHeaders.put(HTTPSPDYHeader.METHOD.name(version), "GET"); - pushHeaders.put(HTTPSPDYHeader.URI.name(version), pushURL); - pushHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); - pushHeaders.put(scheme); - pushHeaders.put(host); - pushHeaders.put("referer", referrer); - pushHeaders.put("x-spdy-push", "true"); - // Remember support for gzip encoding - pushHeaders.put(headers.get("accept-encoding")); + final Headers requestHeaders = createRequestHeaders(scheme, host, uri, pushResourcePath); + final Headers pushHeaders = createPushHeaders(scheme, host, pushResourcePath); + stream.syn(new SynInfo(pushHeaders, false), getMaxIdleTime(), TimeUnit.MILLISECONDS, new Handler.Adapter() { @Override @@ -431,16 +427,43 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem { ServerHTTPSPDYAsyncConnection pushConnection = new ServerHTTPSPDYAsyncConnection(getConnector(), getEndPoint(), getServer(), version, connection, pushStrategy, pushStream); - pushConnection.beginRequest(pushHeaders, true); + pushConnection.beginRequest(requestHeaders, true); } }); } } } - private boolean isIfModifiedSinceHeaderPresent() + private Headers createRequestHeaders(Headers.Header scheme, Headers.Header host, Headers.Header uri, String pushResourcePath) { - return headers.get("if-modified-since") != null; + final Headers requestHeaders = new Headers(); + requestHeaders.put(HTTPSPDYHeader.METHOD.name(version), "GET"); + requestHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); + requestHeaders.put(scheme); + requestHeaders.put(host); + requestHeaders.put(HTTPSPDYHeader.URI.name(version), pushResourcePath); + String referrer = scheme.value() + "://" + host.value() + uri.value(); + requestHeaders.put("referer", referrer); + // Remember support for gzip encoding + requestHeaders.put(headers.get("accept-encoding")); + requestHeaders.put("x-spdy-push", "true"); + return requestHeaders; + } + + private Headers createPushHeaders(Headers.Header scheme, Headers.Header host, String pushResourcePath) + { + final Headers pushHeaders = new Headers(); + if (version == SPDY.V2) + pushHeaders.put(HTTPSPDYHeader.URI.name(version), scheme.value() + "://" + host.value() + pushResourcePath); + else + { + pushHeaders.put(HTTPSPDYHeader.URI.name(version), pushResourcePath); + pushHeaders.put(scheme); + pushHeaders.put(host); + } + pushHeaders.put(HTTPSPDYHeader.STATUS.name(version), "200"); + pushHeaders.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); + return pushHeaders; } private Buffer consumeContent(long maxIdleTime) throws IOException, InterruptedException @@ -699,6 +722,7 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem logger.debug("HTTP < {} bytes of content", dataInfo.length()); stream.data(dataInfo).get(maxIdleTime, TimeUnit.MILLISECONDS); content.clear(); + _bypass = false; content = getContentBuffer(); } } diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnectionFactory.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnectionFactory.java index b3d4a5237c0..7a5f381b3c3 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnectionFactory.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnectionFactory.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/HTTPSPDYProxyConnector.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/HTTPSPDYProxyConnector.java new file mode 100644 index 00000000000..2827af05ceb --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/HTTPSPDYProxyConnector.java @@ -0,0 +1,39 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + + +package org.eclipse.jetty.spdy.proxy; + +import org.eclipse.jetty.spdy.ServerSPDYAsyncConnectionFactory; +import org.eclipse.jetty.spdy.api.SPDY; +import org.eclipse.jetty.spdy.http.AbstractHTTPSPDYServerConnector; +import org.eclipse.jetty.util.ssl.SslContextFactory; + +public class HTTPSPDYProxyConnector extends AbstractHTTPSPDYServerConnector +{ + public HTTPSPDYProxyConnector(ProxyEngineSelector proxyEngineSelector) + { + this(proxyEngineSelector, null); + } + + public HTTPSPDYProxyConnector(ProxyEngineSelector proxyEngineSelector, SslContextFactory sslContextFactory) + { + super(proxyEngineSelector, sslContextFactory); + clearAsyncConnectionFactories(); + + putAsyncConnectionFactory("spdy/3", new ServerSPDYAsyncConnectionFactory(SPDY.V3, getByteBufferPool(), getExecutor(), getScheduler(), proxyEngineSelector)); + putAsyncConnectionFactory("spdy/2", new ServerSPDYAsyncConnectionFactory(SPDY.V2, getByteBufferPool(), getExecutor(), getScheduler(), proxyEngineSelector)); + putAsyncConnectionFactory("http/1.1", new ProxyHTTPAsyncConnectionFactory(this, SPDY.V2, proxyEngineSelector)); + setDefaultAsyncConnectionFactory(getAsyncConnectionFactory("http/1.1")); + } +} diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngine.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngine.java new file mode 100644 index 00000000000..0a172614a56 --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngine.java @@ -0,0 +1,94 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + + +package org.eclipse.jetty.spdy.proxy; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import org.eclipse.jetty.spdy.api.Headers; +import org.eclipse.jetty.spdy.api.Stream; +import org.eclipse.jetty.spdy.api.StreamFrameListener; +import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; + +/** + *

    {@link ProxyEngine} is the class for SPDY proxy functionalities that receives a SPDY request and converts it to + * any protocol to its server side.

    + *

    This class listens for SPDY events sent by clients; subclasses are responsible for translating + * these SPDY client events into appropriate events to forward to the server, in the appropriate + * protocol that is understood by the server.

    + */ +public abstract class ProxyEngine +{ + protected final Logger logger = Log.getLogger(getClass()); + private final String name; + + protected ProxyEngine() + { + this(name()); + } + + private static String name() + { + try + { + return InetAddress.getLocalHost().getHostName(); + } + catch (UnknownHostException x) + { + return "localhost"; + } + } + + public abstract StreamFrameListener proxy(Stream clientStream, SynInfo clientSynInfo, ProxyEngineSelector.ProxyServerInfo proxyServerInfo); + + protected ProxyEngine(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + protected void addRequestProxyHeaders(Stream stream, Headers headers) + { + addViaHeader(headers); + String address = (String)stream.getSession().getAttribute("org.eclipse.jetty.spdy.remoteAddress"); + if (address != null) + headers.add("X-Forwarded-For", address); + } + + protected void addResponseProxyHeaders(Stream stream, Headers headers) + { + addViaHeader(headers); + } + + private void addViaHeader(Headers headers) + { + headers.add("Via", "http/1.1 " + getName()); + } + + protected void customizeRequestHeaders(Stream stream, Headers headers) + { + } + + protected void customizeResponseHeaders(Stream stream, Headers headers) + { + } + +} diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngineSelector.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngineSelector.java new file mode 100644 index 00000000000..52855be3927 --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyEngineSelector.java @@ -0,0 +1,169 @@ +package org.eclipse.jetty.spdy.proxy; + +import java.net.InetSocketAddress; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.eclipse.jetty.spdy.api.GoAwayInfo; +import org.eclipse.jetty.spdy.api.Headers; +import org.eclipse.jetty.spdy.api.PingInfo; +import org.eclipse.jetty.spdy.api.RstInfo; +import org.eclipse.jetty.spdy.api.Session; +import org.eclipse.jetty.spdy.api.Stream; +import org.eclipse.jetty.spdy.api.StreamFrameListener; +import org.eclipse.jetty.spdy.api.StreamStatus; +import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.spdy.http.HTTPSPDYHeader; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; + +/** + *

    {@link ProxyEngineSelector} is the main entry point for syn stream events of a jetty SPDY proxy. It receives the + * syn stream frames from the clients, checks if there's an appropriate {@link ProxyServerInfo} for the given target + * host and forwards the syn to a {@link ProxyEngine} for the protocol defined in {@link ProxyServerInfo}.

    + * + *

    If no {@link ProxyServerInfo} can be found for the given target host or no {@link ProxyEngine} can be found for + * the given protocol, it resets the client stream.

    + * + *

    This class also provides configuration for the proxy rules.

    + */ +public class ProxyEngineSelector extends ServerSessionFrameListener.Adapter +{ + protected final Logger logger = Log.getLogger(getClass()); + private final Map proxyInfos = new ConcurrentHashMap<>(); + private final Map proxyEngines = new ConcurrentHashMap<>(); + + @Override + public final StreamFrameListener onSyn(final Stream clientStream, SynInfo clientSynInfo) + { + logger.debug("C -> P {} on {}", clientSynInfo, clientStream); + + final Session clientSession = clientStream.getSession(); + short clientVersion = clientSession.getVersion(); + Headers headers = new Headers(clientSynInfo.getHeaders(), false); + + Headers.Header hostHeader = headers.get(HTTPSPDYHeader.HOST.name(clientVersion)); + if (hostHeader == null) + { + logger.debug("No host header found: " + headers); + rst(clientStream); + return null; + } + + String host = hostHeader.value(); + int colon = host.indexOf(':'); + if (colon >= 0) + host = host.substring(0, colon); + + ProxyServerInfo proxyServerInfo = getProxyServerInfo(host); + if (proxyServerInfo == null) + { + logger.debug("No matching ProxyServerInfo found for: " + host); + rst(clientStream); + return null; + } + + String protocol = proxyServerInfo.getProtocol(); + ProxyEngine proxyEngine = proxyEngines.get(protocol); + if (proxyEngine == null) + { + logger.debug("No matching ProxyEngine found for: " + protocol); + rst(clientStream); + return null; + } + + return proxyEngine.proxy(clientStream, clientSynInfo, proxyServerInfo); + } + + @Override + public void onPing(Session clientSession, PingInfo pingInfo) + { + // We do not know to which upstream server + // to send the PING so we just ignore it + } + + @Override + public void onGoAway(Session session, GoAwayInfo goAwayInfo) + { + // TODO: + } + + public Map getProxyEngines() + { + return new HashMap<>(proxyEngines); + } + + public void setProxyEngines(Map proxyEngines) + { + this.proxyEngines.clear(); + this.proxyEngines.putAll(proxyEngines); + } + + public ProxyEngine getProxyEngine(String protocol) + { + return proxyEngines.get(protocol); + } + + public void putProxyEngine(String protocol, ProxyEngine proxyEngine) + { + proxyEngines.put(protocol, proxyEngine); + } + + public Map getProxyServerInfos() + { + return new HashMap<>(proxyInfos); + } + + protected ProxyServerInfo getProxyServerInfo(String host) + { + return proxyInfos.get(host); + } + + public void setProxyServerInfos(Map proxyServerInfos) + { + this.proxyInfos.clear(); + this.proxyInfos.putAll(proxyServerInfos); + } + + public void putProxyServerInfo(String host, ProxyServerInfo proxyServerInfo) + { + proxyInfos.put(host, proxyServerInfo); + } + + private void rst(Stream stream) + { + RstInfo rstInfo = new RstInfo(stream.getId(), StreamStatus.REFUSED_STREAM); + stream.getSession().rst(rstInfo); + } + + public static class ProxyServerInfo + { + private final String protocol; + private final String host; + private final InetSocketAddress address; + + public ProxyServerInfo(String protocol, String host, int port) + { + this.protocol = protocol; + this.host = host; + this.address = new InetSocketAddress(host, port); + } + + public String getProtocol() + { + return protocol; + } + + public String getHost() + { + return host; + } + + public InetSocketAddress getAddress() + { + return address; + } + } +} diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPAsyncConnectionFactory.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPAsyncConnectionFactory.java new file mode 100644 index 00000000000..f73c7e819bb --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPAsyncConnectionFactory.java @@ -0,0 +1,41 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + + +package org.eclipse.jetty.spdy.proxy; + +import java.nio.channels.SocketChannel; + +import org.eclipse.jetty.io.AsyncEndPoint; +import org.eclipse.jetty.io.nio.AsyncConnection; +import org.eclipse.jetty.spdy.SPDYServerConnector; +import org.eclipse.jetty.spdy.http.ServerHTTPAsyncConnectionFactory; + +public class ProxyHTTPAsyncConnectionFactory extends ServerHTTPAsyncConnectionFactory +{ + private final short version; + private final ProxyEngineSelector proxyEngineSelector; + + public ProxyHTTPAsyncConnectionFactory(SPDYServerConnector connector, short version, ProxyEngineSelector proxyEngineSelector) + { + super(connector); + this.version = version; + this.proxyEngineSelector = proxyEngineSelector; + } + + @Override + public AsyncConnection newAsyncConnection(SocketChannel channel, AsyncEndPoint endPoint, Object attachment) + { + return new ProxyHTTPSPDYAsyncConnection(getConnector(), endPoint, version, proxyEngineSelector); + } +} diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYAsyncConnection.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYAsyncConnection.java new file mode 100644 index 00000000000..92c318479a6 --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYAsyncConnection.java @@ -0,0 +1,337 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + + +package org.eclipse.jetty.spdy.proxy; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.jetty.http.HttpFields; +import org.eclipse.jetty.http.HttpGenerator; +import org.eclipse.jetty.io.AsyncEndPoint; +import org.eclipse.jetty.io.Buffer; +import org.eclipse.jetty.io.ByteArrayBuffer; +import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.io.nio.DirectNIOBuffer; +import org.eclipse.jetty.io.nio.IndirectNIOBuffer; +import org.eclipse.jetty.io.nio.NIOBuffer; +import org.eclipse.jetty.server.AsyncHttpConnection; +import org.eclipse.jetty.spdy.ISession; +import org.eclipse.jetty.spdy.IStream; +import org.eclipse.jetty.spdy.SPDYServerConnector; +import org.eclipse.jetty.spdy.StandardSession; +import org.eclipse.jetty.spdy.StandardStream; +import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; +import org.eclipse.jetty.spdy.api.BytesDataInfo; +import org.eclipse.jetty.spdy.api.DataInfo; +import org.eclipse.jetty.spdy.api.GoAwayInfo; +import org.eclipse.jetty.spdy.api.Handler; +import org.eclipse.jetty.spdy.api.Headers; +import org.eclipse.jetty.spdy.api.HeadersInfo; +import org.eclipse.jetty.spdy.api.ReplyInfo; +import org.eclipse.jetty.spdy.api.RstInfo; +import org.eclipse.jetty.spdy.api.SessionStatus; +import org.eclipse.jetty.spdy.api.Stream; +import org.eclipse.jetty.spdy.api.StreamFrameListener; +import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.spdy.http.HTTPSPDYHeader; + +public class ProxyHTTPSPDYAsyncConnection extends AsyncHttpConnection +{ + private final Headers headers = new Headers(); + private final short version; + private final ProxyEngineSelector proxyEngineSelector; + private final HttpGenerator generator; + private final ISession session; + private HTTPStream stream; + private Buffer content; + + public ProxyHTTPSPDYAsyncConnection(SPDYServerConnector connector, EndPoint endPoint, short version, ProxyEngineSelector proxyEngineSelector) + { + super(connector, endPoint, connector.getServer()); + this.version = version; + this.proxyEngineSelector = proxyEngineSelector; + this.generator = (HttpGenerator)_generator; + this.session = new HTTPSession(version, connector); + this.session.setAttribute("org.eclipse.jetty.spdy.remoteAddress", endPoint.getRemoteAddr()); + } + + @Override + public AsyncEndPoint getEndPoint() + { + return (AsyncEndPoint)super.getEndPoint(); + } + + @Override + protected void startRequest(Buffer method, Buffer uri, Buffer httpVersion) throws IOException + { + SPDYServerConnector connector = (SPDYServerConnector)getConnector(); + String scheme = connector.getSslContextFactory() != null ? "https" : "http"; + headers.put(HTTPSPDYHeader.SCHEME.name(version), scheme); + headers.put(HTTPSPDYHeader.METHOD.name(version), method.toString("UTF-8")); + headers.put(HTTPSPDYHeader.URI.name(version), uri.toString("UTF-8")); + headers.put(HTTPSPDYHeader.VERSION.name(version), httpVersion.toString("UTF-8")); + } + + @Override + protected void parsedHeader(Buffer name, Buffer value) throws IOException + { + String headerName = name.toString("UTF-8").toLowerCase(); + String headerValue = value.toString("UTF-8"); + switch (headerName) + { + case "host": + headers.put(HTTPSPDYHeader.HOST.name(version), headerValue); + break; + default: + headers.put(headerName, headerValue); + break; + } + } + + @Override + protected void headerComplete() throws IOException + { + } + + @Override + protected void content(Buffer buffer) throws IOException + { + if (content == null) + { + stream = syn(false); + content = buffer; + } + else + { + stream.getStreamFrameListener().onData(stream, toDataInfo(buffer, false)); + } + } + + @Override + public void messageComplete(long contentLength) throws IOException + { + if (stream == null) + { + assert content == null; + if (headers.isEmpty()) + proxyEngineSelector.onGoAway(session, new GoAwayInfo(0, SessionStatus.OK)); + else + syn(true); + } + else + { + stream.getStreamFrameListener().onData(stream, toDataInfo(content, true)); + } + headers.clear(); + stream = null; + content = null; + } + + private HTTPStream syn(boolean close) + { + HTTPStream stream = new HTTPStream(1, (byte)0, session, null); + StreamFrameListener streamFrameListener = proxyEngineSelector.onSyn(stream, new SynInfo(headers, close)); + stream.setStreamFrameListener(streamFrameListener); + return stream; + } + + private DataInfo toDataInfo(Buffer buffer, boolean close) + { + if (buffer instanceof ByteArrayBuffer) + return new BytesDataInfo(buffer.array(), buffer.getIndex(), buffer.length(), close); + + if (buffer instanceof NIOBuffer) + { + ByteBuffer byteBuffer = ((NIOBuffer)buffer).getByteBuffer(); + byteBuffer.limit(buffer.putIndex()); + byteBuffer.position(buffer.getIndex()); + return new ByteBufferDataInfo(byteBuffer, close); + } + + return new BytesDataInfo(buffer.asArray(), close); + } + + private class HTTPSession extends StandardSession + { + private HTTPSession(short version, SPDYServerConnector connector) + { + super(version, connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), null, null, 1, proxyEngineSelector, null, null); + } + + @Override + public void rst(RstInfo rstInfo, long timeout, TimeUnit unit, Handler handler) + { + // Not much we can do in HTTP land: just close the connection + goAway(timeout, unit, handler); + } + + @Override + public void goAway(long timeout, TimeUnit unit, Handler handler) + { + try + { + getEndPoint().close(); + handler.completed(null); + } + catch (IOException x) + { + handler.failed(null, x); + } + } + } + + /** + *

    This stream will convert the SPDY invocations performed by the proxy into HTTP to be sent to the client.

    + */ + private class HTTPStream extends StandardStream + { + private final Pattern statusRegexp = Pattern.compile("(\\d{3})\\s*(.*)"); + + private HTTPStream(int id, byte priority, ISession session, IStream associatedStream) + { + super(id, priority, session, associatedStream); + } + + @Override + public void syn(SynInfo synInfo, long timeout, TimeUnit unit, Handler handler) + { + // HTTP does not support pushed streams + handler.completed(new HTTPPushStream(2, getPriority(), getSession(), this)); + } + + @Override + public void headers(HeadersInfo headersInfo, long timeout, TimeUnit unit, Handler handler) + { + // TODO + throw new UnsupportedOperationException("Not Yet Implemented"); + } + + @Override + public void reply(ReplyInfo replyInfo, long timeout, TimeUnit unit, Handler handler) + { + try + { + Headers headers = new Headers(replyInfo.getHeaders(), false); + + headers.remove(HTTPSPDYHeader.SCHEME.name(version)); + + String status = headers.remove(HTTPSPDYHeader.STATUS.name(version)).value(); + Matcher matcher = statusRegexp.matcher(status); + matcher.matches(); + int code = Integer.parseInt(matcher.group(1)); + String reason = matcher.group(2); + generator.setResponse(code, reason); + + String httpVersion = headers.remove(HTTPSPDYHeader.VERSION.name(version)).value(); + generator.setVersion(Integer.parseInt(httpVersion.replaceAll("\\D", ""))); + + Headers.Header host = headers.remove(HTTPSPDYHeader.HOST.name(version)); + if (host != null) + headers.put("host", host.value()); + + HttpFields fields = new HttpFields(); + for (Headers.Header header : headers) + { + String name = camelize(header.name()); + fields.put(name, header.value()); + } + generator.completeHeader(fields, replyInfo.isClose()); + + if (replyInfo.isClose()) + complete(); + + handler.completed(null); + } + catch (IOException x) + { + handler.failed(null, x); + } + } + + private String camelize(String name) + { + char[] chars = name.toCharArray(); + chars[0] = Character.toUpperCase(chars[0]); + + for (int i = 0; i < chars.length; ++i) + { + char c = chars[i]; + int j = i + 1; + if (c == '-' && j < chars.length) + chars[j] = Character.toUpperCase(chars[j]); + } + return new String(chars); + } + + @Override + public void data(DataInfo dataInfo, long timeout, TimeUnit unit, Handler handler) + { + try + { + // Data buffer must be copied, as the ByteBuffer is pooled + ByteBuffer byteBuffer = dataInfo.asByteBuffer(false); + + Buffer buffer = byteBuffer.isDirect() ? + new DirectNIOBuffer(byteBuffer, false) : + new IndirectNIOBuffer(byteBuffer, false); + + generator.addContent(buffer, dataInfo.isClose()); + generator.flush(unit.toMillis(timeout)); + + if (dataInfo.isClose()) + complete(); + + handler.completed(null); + } + catch (IOException x) + { + handler.failed(null, x); + } + } + + private void complete() throws IOException + { + generator.complete(); + // We need to call asyncDispatch() as if the HTTP request + // has been suspended and now we complete the response + getEndPoint().asyncDispatch(); + } + } + + private class HTTPPushStream extends StandardStream + { + private HTTPPushStream(int id, byte priority, ISession session, IStream associatedStream) + { + super(id, priority, session, associatedStream); + } + + @Override + public void headers(HeadersInfo headersInfo, long timeout, TimeUnit unit, Handler handler) + { + // Ignore pushed headers + handler.completed(null); + } + + @Override + public void data(DataInfo dataInfo, long timeout, TimeUnit unit, Handler handler) + { + // Ignore pushed data + handler.completed(null); + } + } +} diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/SPDYProxyEngine.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/SPDYProxyEngine.java new file mode 100644 index 00000000000..c01af3ef0f8 --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/proxy/SPDYProxyEngine.java @@ -0,0 +1,514 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + + +package org.eclipse.jetty.spdy.proxy; + +import java.net.InetSocketAddress; +import java.util.LinkedList; +import java.util.Queue; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; + +import org.eclipse.jetty.spdy.SPDYClient; +import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; +import org.eclipse.jetty.spdy.api.DataInfo; +import org.eclipse.jetty.spdy.api.GoAwayInfo; +import org.eclipse.jetty.spdy.api.Handler; +import org.eclipse.jetty.spdy.api.Headers; +import org.eclipse.jetty.spdy.api.HeadersInfo; +import org.eclipse.jetty.spdy.api.ReplyInfo; +import org.eclipse.jetty.spdy.api.RstInfo; +import org.eclipse.jetty.spdy.api.SPDY; +import org.eclipse.jetty.spdy.api.Session; +import org.eclipse.jetty.spdy.api.SessionFrameListener; +import org.eclipse.jetty.spdy.api.Stream; +import org.eclipse.jetty.spdy.api.StreamFrameListener; +import org.eclipse.jetty.spdy.api.StreamStatus; +import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.spdy.http.HTTPSPDYHeader; + +/** + *

    {@link SPDYProxyEngine} implements a SPDY to SPDY proxy, that is, converts SPDY events received by + * clients into SPDY events for the servers.

    + */ +public class SPDYProxyEngine extends ProxyEngine implements StreamFrameListener +{ + private static final String STREAM_HANDLER_ATTRIBUTE = "org.eclipse.jetty.spdy.http.proxy.streamHandler"; + private static final String CLIENT_STREAM_ATTRIBUTE = "org.eclipse.jetty.spdy.http.proxy.clientStream"; + + private final ConcurrentMap serverSessions = new ConcurrentHashMap<>(); + private final SessionFrameListener sessionListener = new ProxySessionFrameListener(); + private final SPDYClient.Factory factory; + private volatile long connectTimeout = 15000; + private volatile long timeout = 60000; + + public SPDYProxyEngine(SPDYClient.Factory factory) + { + this.factory = factory; + } + + public long getConnectTimeout() + { + return connectTimeout; + } + + public void setConnectTimeout(long connectTimeout) + { + this.connectTimeout = connectTimeout; + } + + public long getTimeout() + { + return timeout; + } + + public void setTimeout(long timeout) + { + this.timeout = timeout; + } + + public StreamFrameListener proxy(final Stream clientStream, SynInfo clientSynInfo, ProxyEngineSelector.ProxyServerInfo proxyServerInfo) + { + Headers headers = new Headers(clientSynInfo.getHeaders(), false); + + short serverVersion = getVersion(proxyServerInfo.getProtocol()); + InetSocketAddress address = proxyServerInfo.getAddress(); + Session serverSession = produceSession(proxyServerInfo.getHost(), serverVersion, address); + if (serverSession == null) + { + rst(clientStream); + return null; + } + + final Session clientSession = clientStream.getSession(); + + addRequestProxyHeaders(clientStream, headers); + customizeRequestHeaders(clientStream, headers); + convert(clientSession.getVersion(), serverVersion, headers); + + SynInfo serverSynInfo = new SynInfo(headers, clientSynInfo.isClose()); + StreamFrameListener listener = new ProxyStreamFrameListener(clientStream); + StreamHandler handler = new StreamHandler(clientStream, serverSynInfo); + clientStream.setAttribute(STREAM_HANDLER_ATTRIBUTE, handler); + serverSession.syn(serverSynInfo, listener, timeout, TimeUnit.MILLISECONDS, handler); + return this; + } + + private static short getVersion(String protocol) + { + switch (protocol) + { + case "spdy/2": + return SPDY.V2; + case "spdy/3": + return SPDY.V3; + default: + throw new IllegalArgumentException("Procotol: " + protocol + " is not a known SPDY protocol"); + } + } + + @Override + public void onReply(Stream stream, ReplyInfo replyInfo) + { + // Servers do not receive replies + } + + @Override + public void onHeaders(Stream stream, HeadersInfo headersInfo) + { + // TODO + throw new UnsupportedOperationException("Not Yet Implemented"); + } + + @Override + public void onData(Stream clientStream, final DataInfo clientDataInfo) + { + logger.debug("C -> P {} on {}", clientDataInfo, clientStream); + + ByteBufferDataInfo serverDataInfo = new ByteBufferDataInfo(clientDataInfo.asByteBuffer(false), clientDataInfo.isClose()) + { + @Override + public void consume(int delta) + { + super.consume(delta); + clientDataInfo.consume(delta); + } + }; + + StreamHandler streamHandler = (StreamHandler)clientStream.getAttribute(STREAM_HANDLER_ATTRIBUTE); + streamHandler.data(serverDataInfo); + } + + private Session produceSession(String host, short version, InetSocketAddress address) + { + try + { + Session session = serverSessions.get(host); + if (session == null) + { + SPDYClient client = factory.newSPDYClient(version); + session = client.connect(address, sessionListener).get(getConnectTimeout(), TimeUnit.MILLISECONDS); + logger.debug("Proxy session connected to {}", address); + Session existing = serverSessions.putIfAbsent(host, session); + if (existing != null) + { + session.goAway(getTimeout(), TimeUnit.MILLISECONDS, new Handler.Adapter()); + session = existing; + } + } + return session; + } + catch (Exception x) + { + logger.debug(x); + return null; + } + } + + private void convert(short fromVersion, short toVersion, Headers headers) + { + if (fromVersion != toVersion) + { + for (HTTPSPDYHeader httpHeader : HTTPSPDYHeader.values()) + { + Headers.Header header = headers.remove(httpHeader.name(fromVersion)); + if (header != null) + { + String toName = httpHeader.name(toVersion); + for (String value : header.values()) + headers.add(toName, value); + } + } + } + } + + private void rst(Stream stream) + { + RstInfo rstInfo = new RstInfo(stream.getId(), StreamStatus.REFUSED_STREAM); + stream.getSession().rst(rstInfo, getTimeout(), TimeUnit.MILLISECONDS, new Handler.Adapter()); + } + + private class ProxyStreamFrameListener extends StreamFrameListener.Adapter + { + private final Stream clientStream; + private volatile ReplyInfo replyInfo; + + public ProxyStreamFrameListener(Stream clientStream) + { + this.clientStream = clientStream; + } + + @Override + public void onReply(final Stream stream, ReplyInfo replyInfo) + { + logger.debug("S -> P {} on {}", replyInfo, stream); + + short serverVersion = stream.getSession().getVersion(); + Headers headers = new Headers(replyInfo.getHeaders(), false); + + addResponseProxyHeaders(stream, headers); + customizeResponseHeaders(stream, headers); + short clientVersion = this.clientStream.getSession().getVersion(); + convert(serverVersion, clientVersion, headers); + + this.replyInfo = new ReplyInfo(headers, replyInfo.isClose()); + if (replyInfo.isClose()) + reply(stream); + } + + @Override + public void onHeaders(Stream stream, HeadersInfo headersInfo) + { + // TODO + throw new UnsupportedOperationException("Not Yet Implemented"); + } + + @Override + public void onData(final Stream stream, final DataInfo dataInfo) + { + logger.debug("S -> P {} on {}", dataInfo, stream); + + if (replyInfo != null) + { + if (dataInfo.isClose()) + replyInfo.getHeaders().put("content-length", String.valueOf(dataInfo.available())); + reply(stream); + } + data(stream, dataInfo); + } + + private void reply(final Stream stream) + { + final ReplyInfo replyInfo = this.replyInfo; + this.replyInfo = null; + clientStream.reply(replyInfo, getTimeout(), TimeUnit.MILLISECONDS, new Handler() + { + @Override + public void completed(Void context) + { + logger.debug("P -> C {} from {} to {}", replyInfo, stream, clientStream); + } + + @Override + public void failed(Void context, Throwable x) + { + logger.debug(x); + rst(clientStream); + } + }); + } + + private void data(final Stream stream, final DataInfo dataInfo) + { + clientStream.data(dataInfo, getTimeout(), TimeUnit.MILLISECONDS, new Handler() + { + @Override + public void completed(Void context) + { + dataInfo.consume(dataInfo.length()); + logger.debug("P -> C {} from {} to {}", dataInfo, stream, clientStream); + } + + @Override + public void failed(Void context, Throwable x) + { + logger.debug(x); + rst(clientStream); + } + }); + } + } + + /** + *

    {@link StreamHandler} implements the forwarding of DATA frames from the client to the server.

    + *

    Instances of this class buffer DATA frames sent by clients and send them to the server. + * The buffering happens between the send of the SYN_STREAM to the server (where DATA frames may arrive + * from the client before the SYN_STREAM has been fully sent), and between DATA frames, if the client + * is a fast producer and the server a slow consumer, or if the client is a SPDY v2 client (and hence + * without flow control) while the server is a SPDY v3 server (and hence with flow control).

    + */ + private class StreamHandler implements Handler + { + private final Queue queue = new LinkedList<>(); + private final Stream clientStream; + private final SynInfo serverSynInfo; + private Stream serverStream; + + private StreamHandler(Stream clientStream, SynInfo serverSynInfo) + { + this.clientStream = clientStream; + this.serverSynInfo = serverSynInfo; + } + + @Override + public void completed(Stream serverStream) + { + logger.debug("P -> S {} from {} to {}", serverSynInfo, clientStream, serverStream); + + serverStream.setAttribute(CLIENT_STREAM_ATTRIBUTE, clientStream); + + DataInfoHandler dataInfoHandler; + synchronized (queue) + { + this.serverStream = serverStream; + dataInfoHandler = queue.peek(); + if (dataInfoHandler != null) + { + if (dataInfoHandler.flushing) + { + logger.debug("SYN completed, flushing {}, queue size {}", dataInfoHandler.dataInfo, queue.size()); + dataInfoHandler = null; + } + else + { + dataInfoHandler.flushing = true; + logger.debug("SYN completed, queue size {}", queue.size()); + } + } + else + { + logger.debug("SYN completed, queue empty"); + } + } + if (dataInfoHandler != null) + flush(serverStream, dataInfoHandler); + } + + @Override + public void failed(Stream serverStream, Throwable x) + { + logger.debug(x); + rst(clientStream); + } + + public void data(DataInfo dataInfo) + { + Stream serverStream; + DataInfoHandler dataInfoHandler = null; + DataInfoHandler item = new DataInfoHandler(dataInfo); + synchronized (queue) + { + queue.offer(item); + serverStream = this.serverStream; + if (serverStream != null) + { + dataInfoHandler = queue.peek(); + if (dataInfoHandler.flushing) + { + logger.debug("Queued {}, flushing {}, queue size {}", dataInfo, dataInfoHandler.dataInfo, queue.size()); + serverStream = null; + } + else + { + dataInfoHandler.flushing = true; + logger.debug("Queued {}, queue size {}", dataInfo, queue.size()); + } + } + else + { + logger.debug("Queued {}, SYN incomplete, queue size {}", dataInfo, queue.size()); + } + } + if (serverStream != null) + flush(serverStream, dataInfoHandler); + } + + private void flush(Stream serverStream, DataInfoHandler dataInfoHandler) + { + logger.debug("P -> S {} on {}", dataInfoHandler.dataInfo, serverStream); + serverStream.data(dataInfoHandler.dataInfo, getTimeout(), TimeUnit.MILLISECONDS, dataInfoHandler); + } + + private class DataInfoHandler implements Handler + { + private final DataInfo dataInfo; + private boolean flushing; + + private DataInfoHandler(DataInfo dataInfo) + { + this.dataInfo = dataInfo; + } + + @Override + public void completed(Void context) + { + Stream serverStream; + DataInfoHandler dataInfoHandler; + synchronized (queue) + { + serverStream = StreamHandler.this.serverStream; + assert serverStream != null; + dataInfoHandler = queue.poll(); + assert dataInfoHandler == this; + dataInfoHandler = queue.peek(); + if (dataInfoHandler != null) + { + assert !dataInfoHandler.flushing; + dataInfoHandler.flushing = true; + logger.debug("Completed {}, queue size {}", dataInfo, queue.size()); + } + else + { + logger.debug("Completed {}, queue empty", dataInfo); + } + } + if (dataInfoHandler != null) + flush(serverStream, dataInfoHandler); + } + + @Override + public void failed(Void context, Throwable x) + { + logger.debug(x); + rst(clientStream); + } + } + } + + private class ProxySessionFrameListener extends SessionFrameListener.Adapter implements StreamFrameListener + { + @Override + public StreamFrameListener onSyn(Stream serverStream, SynInfo serverSynInfo) + { + logger.debug("S -> P pushed {} on {}", serverSynInfo, serverStream); + + Headers headers = new Headers(serverSynInfo.getHeaders(), false); + + addResponseProxyHeaders(serverStream, headers); + customizeResponseHeaders(serverStream, headers); + Stream clientStream = (Stream)serverStream.getAssociatedStream().getAttribute(CLIENT_STREAM_ATTRIBUTE); + convert(serverStream.getSession().getVersion(), clientStream.getSession().getVersion(), headers); + + StreamHandler handler = new StreamHandler(clientStream, serverSynInfo); + serverStream.setAttribute(STREAM_HANDLER_ATTRIBUTE, handler); + clientStream.syn(new SynInfo(headers, serverSynInfo.isClose()), getTimeout(), TimeUnit.MILLISECONDS, handler); + + return this; + } + + @Override + public void onRst(Session serverSession, RstInfo serverRstInfo) + { + Stream serverStream = serverSession.getStream(serverRstInfo.getStreamId()); + if (serverStream != null) + { + Stream clientStream = (Stream)serverStream.getAttribute(CLIENT_STREAM_ATTRIBUTE); + if (clientStream != null) + { + Session clientSession = clientStream.getSession(); + RstInfo clientRstInfo = new RstInfo(clientStream.getId(), serverRstInfo.getStreamStatus()); + clientSession.rst(clientRstInfo, getTimeout(), TimeUnit.MILLISECONDS, new Handler.Adapter()); + } + } + } + + @Override + public void onGoAway(Session serverSession, GoAwayInfo goAwayInfo) + { + serverSessions.values().remove(serverSession); + } + + @Override + public void onReply(Stream stream, ReplyInfo replyInfo) + { + // Push streams never send a reply + } + + @Override + public void onHeaders(Stream stream, HeadersInfo headersInfo) + { + throw new UnsupportedOperationException(); //TODO + } + + @Override + public void onData(Stream serverStream, final DataInfo serverDataInfo) + { + logger.debug("S -> P pushed {} on {}", serverDataInfo, serverStream); + + ByteBufferDataInfo clientDataInfo = new ByteBufferDataInfo(serverDataInfo.asByteBuffer(false), serverDataInfo.isClose()) + { + @Override + public void consume(int delta) + { + super.consume(delta); + serverDataInfo.consume(delta); + } + }; + + StreamHandler handler = (StreamHandler)serverStream.getAttribute(STREAM_HANDLER_ATTRIBUTE); + handler.data(clientDataInfo); + } + } +} diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/AbstractHTTPSPDYTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/AbstractHTTPSPDYTest.java index f6f41776d24..a5c4c280439 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/AbstractHTTPSPDYTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/AbstractHTTPSPDYTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ConcurrentStreamsTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ConcurrentStreamsTest.java index 0bbf0e68ff3..56cb5ef7c75 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ConcurrentStreamsTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ConcurrentStreamsTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ProtocolNegotiationTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ProtocolNegotiationTest.java index 97f550d551c..5de439b2066 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ProtocolNegotiationTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ProtocolNegotiationTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/PushStrategyBenchmarkTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/PushStrategyBenchmarkTest.java index 29b5952d4e5..9486157de24 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/PushStrategyBenchmarkTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/PushStrategyBenchmarkTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; @@ -24,6 +22,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -38,6 +38,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.spdy.AsyncConnectionFactory; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.Headers; +import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.SessionFrameListener; import org.eclipse.jetty.spdy.api.Stream; @@ -137,39 +138,21 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest for (int i = 0; i < cssResources.length; ++i) { String path = "/" + i + ".css"; - exchange = new TestExchange(); - exchange.setMethod("GET"); - exchange.setRequestURI(path); - exchange.setVersion("HTTP/1.1"); - exchange.setAddress(new Address("localhost", connector.getLocalPort())); - exchange.setRequestHeader("Host", "localhost:" + connector.getLocalPort()); - exchange.setRequestHeader("referer", referrer); + exchange = createExchangeWithReferrer(referrer, path); ++result; httpClient.send(exchange); } for (int i = 0; i < jsResources.length; ++i) { String path = "/" + i + ".js"; - exchange = new TestExchange(); - exchange.setMethod("GET"); - exchange.setRequestURI(path); - exchange.setVersion("HTTP/1.1"); - exchange.setAddress(new Address("localhost", connector.getLocalPort())); - exchange.setRequestHeader("Host", "localhost:" + connector.getLocalPort()); - exchange.setRequestHeader("referer", referrer); + exchange = createExchangeWithReferrer(referrer, path); ++result; httpClient.send(exchange); } for (int i = 0; i < pngResources.length; ++i) { String path = "/" + i + ".png"; - exchange = new TestExchange(); - exchange.setMethod("GET"); - exchange.setRequestURI(path); - exchange.setVersion("HTTP/1.1"); - exchange.setAddress(new Address("localhost", connector.getLocalPort())); - exchange.setRequestHeader("Host", "localhost:" + connector.getLocalPort()); - exchange.setRequestHeader("referer", referrer); + exchange = createExchangeWithReferrer(referrer, path); ++result; httpClient.send(exchange); } @@ -180,6 +163,19 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest return result; } + private ContentExchange createExchangeWithReferrer(String referrer, String path) + { + ContentExchange exchange; + exchange = new TestExchange(); + exchange.setMethod("GET"); + exchange.setRequestURI(path); + exchange.setVersion("HTTP/1.1"); + exchange.setAddress(new Address("localhost", connector.getLocalPort())); + exchange.setRequestHeader("Host", "localhost:" + connector.getLocalPort()); + exchange.setRequestHeader("referer", referrer); + return exchange; + } + private void benchmarkSPDY(PushStrategy pushStrategy, Session session) throws Exception { @@ -238,13 +234,7 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest String path = "/" + i + ".css"; if (pushedResources.contains(path)) continue; - headers = new Headers(); - headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - headers.put(HTTPSPDYHeader.URI.name(version()), path); - headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - headers.put("referer", referrer); + headers = createRequestHeaders(referrer, path); ++result; session.syn(new SynInfo(headers, true), new DataListener()); } @@ -253,13 +243,7 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest String path = "/" + i + ".js"; if (pushedResources.contains(path)) continue; - headers = new Headers(); - headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - headers.put(HTTPSPDYHeader.URI.name(version()), path); - headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - headers.put("referer", referrer); + headers = createRequestHeaders(referrer, path); ++result; session.syn(new SynInfo(headers, true), new DataListener()); } @@ -268,13 +252,7 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest String path = "/" + i + ".png"; if (pushedResources.contains(path)) continue; - headers = new Headers(); - headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - headers.put(HTTPSPDYHeader.URI.name(version()), path); - headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - headers.put("referer", referrer); + headers = createRequestHeaders(referrer, path); ++result; session.syn(new SynInfo(headers, true), new DataListener()); } @@ -285,6 +263,19 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest return result; } + private Headers createRequestHeaders(String referrer, String path) + { + Headers headers; + headers = new Headers(); + headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); + headers.put(HTTPSPDYHeader.URI.name(version()), path); + headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); + headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); + headers.put("referer", referrer); + return headers; + } + private void sleep(long delay) throws ServletException { try @@ -343,13 +334,36 @@ public class PushStrategyBenchmarkTest extends AbstractHTTPSPDYTest } } + private void addPushedResource(String pushedURI) + { + switch (version()) + { + case SPDY.V2: + { + Matcher matcher = Pattern.compile("https?://[^:]+:\\d+(/.*)").matcher(pushedURI); + Assert.assertTrue(matcher.matches()); + pushedResources.add(matcher.group(1)); + break; + } + case SPDY.V3: + { + pushedResources.add(pushedURI); + break; + } + default: + { + throw new IllegalStateException(); + } + } + } + private class ClientSessionFrameListener extends SessionFrameListener.Adapter { @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { String path = synInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version())).value(); - pushedResources.add(path); + addPushedResource(path); return new DataListener(); } } diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyUnitTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyUnitTest.java new file mode 100644 index 00000000000..0edbcf8a333 --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyUnitTest.java @@ -0,0 +1,119 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + +package org.eclipse.jetty.spdy.http; + +import java.util.Set; + +import org.eclipse.jetty.spdy.api.Headers; +import org.eclipse.jetty.spdy.api.SPDY; +import org.eclipse.jetty.spdy.api.Session; +import org.eclipse.jetty.spdy.api.Stream; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class ReferrerPushStrategyUnitTest +{ + public static final short VERSION = SPDY.V3; + public static final String SCHEME = "http"; + public static final String HOST = "localhost"; + public static final String MAIN_URI = "/index.html"; + public static final String METHOD = "GET"; + + // class under test + private ReferrerPushStrategy referrerPushStrategy; + + @Mock + Stream stream; + @Mock + Session session; + + + @Before + public void setup() + { + referrerPushStrategy = new ReferrerPushStrategy(); + } + + @Test + public void testReferrerCallsAfterTimeoutAreNotAddedAsPushResources() throws InterruptedException + { + Headers requestHeaders = getBaseHeaders(VERSION); + int referrerCallTimeout = 1000; + referrerPushStrategy.setReferrerPushPeriod(referrerCallTimeout); + setMockExpectations(); + + String referrerUrl = fillPushStrategyCache(requestHeaders); + Set pushResources; + + // sleep to pretend that the user manually clicked on a linked resource instead the browser requesting subresources immediately + Thread.sleep(referrerCallTimeout + 1); + + requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), "image2.jpg"); + requestHeaders.put("referer", referrerUrl); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + assertThat("pushResources is empty", pushResources.size(), is(0)); + + requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), MAIN_URI); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + // as the image2.jpg request has been a link and not a subresource, we expect that pushResources.size() is still 2 + assertThat("pushResources contains two elements image.jpg and style.css", pushResources.size(), is(2)); + } + + private Headers getBaseHeaders(short version) + { + Headers requestHeaders = new Headers(); + requestHeaders.put(HTTPSPDYHeader.SCHEME.name(version), SCHEME); + requestHeaders.put(HTTPSPDYHeader.HOST.name(version), HOST); + requestHeaders.put(HTTPSPDYHeader.URI.name(version), MAIN_URI); + requestHeaders.put(HTTPSPDYHeader.METHOD.name(version), METHOD); + return requestHeaders; + } + + private void setMockExpectations() + { + when(stream.getSession()).thenReturn(session); + when(session.getVersion()).thenReturn(VERSION); + } + + private String fillPushStrategyCache(Headers requestHeaders) + { + Set pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + assertThat("pushResources is empty", pushResources.size(), is(0)); + + String origin = SCHEME + "://" + HOST; + String referrerUrl = origin + MAIN_URI; + + requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), "image.jpg"); + requestHeaders.put("referer", referrerUrl); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + assertThat("pushResources is empty", pushResources.size(), is(0)); + + requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), "style.css"); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + assertThat("pushResources is empty", pushResources.size(), is(0)); + + requestHeaders.put(HTTPSPDYHeader.URI.name(VERSION), MAIN_URI); + pushResources = referrerPushStrategy.apply(stream, requestHeaders, new Headers()); + assertThat("pushResources contains two elements image.jpg and style.css", pushResources.size(), is(2)); + return referrerUrl; + } +} diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyV2Test.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyV2Test.java index ce88e712c74..8bc79c3f586 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyV2Test.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyV2Test.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; @@ -32,6 +30,7 @@ import org.eclipse.jetty.spdy.SPDYServerConnector; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; +import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.SessionFrameListener; import org.eclipse.jetty.spdy.api.Stream; @@ -42,6 +41,10 @@ import org.junit.Test; public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest { + + private final String mainResource = "/index.html"; + private final String cssResource = "/style.css"; + @Override protected SPDYServerConnector newHTTPSPDYServerConnector(short version) { @@ -51,10 +54,71 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest return connector; } + @Test + public void testPushHeadersAreValid() throws Exception + { + InetSocketAddress address = createServer(); + + ReferrerPushStrategy pushStrategy = new ReferrerPushStrategy(); + int referrerPushPeriod = 1000; + pushStrategy.setReferrerPushPeriod(referrerPushPeriod); + AsyncConnectionFactory defaultFactory = new ServerHTTPSPDYAsyncConnectionFactory(version(), connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, pushStrategy); + connector.setDefaultAsyncConnectionFactory(defaultFactory); + + Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Session session1 = sendMainRequestAndCSSRequest(address, mainRequestHeaders); + + // Sleep for pushPeriod This should prevent application.js from being mapped as pushResource + Thread.sleep(referrerPushPeriod + 1); + + sendJSRequest(session1); + + run2ndClientRequests(address, mainRequestHeaders, true); + } + + @Test + public void testReferrerPushPeriod() throws Exception + { + InetSocketAddress address = createServer(); + + ReferrerPushStrategy pushStrategy = new ReferrerPushStrategy(); + int referrerPushPeriod = 1000; + pushStrategy.setReferrerPushPeriod(referrerPushPeriod); + AsyncConnectionFactory defaultFactory = new ServerHTTPSPDYAsyncConnectionFactory(version(), connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, pushStrategy); + connector.setDefaultAsyncConnectionFactory(defaultFactory); + + Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Session session1 = sendMainRequestAndCSSRequest(address, mainRequestHeaders); + + // Sleep for pushPeriod This should prevent application.js from being mapped as pushResource + Thread.sleep(referrerPushPeriod+1); + + sendJSRequest(session1); + + run2ndClientRequests(address, mainRequestHeaders, false); + } + @Test public void testMaxAssociatedResources() throws Exception { - InetSocketAddress address = startHTTPServer(version(), new AbstractHandler() + InetSocketAddress address = createServer(); + + ReferrerPushStrategy pushStrategy = new ReferrerPushStrategy(); + pushStrategy.setMaxAssociatedResources(1); + AsyncConnectionFactory defaultFactory = new ServerHTTPSPDYAsyncConnectionFactory(version(), connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, pushStrategy); + connector.setDefaultAsyncConnectionFactory(defaultFactory); + + Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + Session session1 = sendMainRequestAndCSSRequest(address, mainRequestHeaders); + + sendJSRequest(session1); + + run2ndClientRequests(address, mainRequestHeaders, false); + } + + private InetSocketAddress createServer() throws Exception + { + return startHTTPServer(version(), new AbstractHandler() { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException @@ -70,21 +134,13 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest baseRequest.setHandled(true); } }); - ReferrerPushStrategy pushStrategy = new ReferrerPushStrategy(); - pushStrategy.setMaxAssociatedResources(1); - AsyncConnectionFactory defaultFactory = new ServerHTTPSPDYAsyncConnectionFactory(version(), connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), connector, pushStrategy); - connector.setDefaultAsyncConnectionFactory(defaultFactory); + } + private Session sendMainRequestAndCSSRequest(InetSocketAddress address, Headers mainRequestHeaders) throws Exception + { Session session1 = startClient(version(), address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = new Headers(); - mainRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - String mainResource = "/index.html"; - mainRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), mainResource); - mainRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - mainRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - mainRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -98,13 +154,7 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch1 = new CountDownLatch(1); - Headers associatedRequestHeaders1 = new Headers(); - associatedRequestHeaders1.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - associatedRequestHeaders1.put(HTTPSPDYHeader.URI.name(version()), "/style.css"); - associatedRequestHeaders1.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - associatedRequestHeaders1.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - associatedRequestHeaders1.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - associatedRequestHeaders1.put("referer", "http://localhost:" + connector.getLocalPort() + mainResource); + Headers associatedRequestHeaders1 = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders1, true), new StreamFrameListener.Adapter() { @Override @@ -116,15 +166,15 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest } }); Assert.assertTrue(associatedResourceLatch1.await(5, TimeUnit.SECONDS)); + return session1; + } + + private void sendJSRequest(Session session1) throws InterruptedException + { final CountDownLatch associatedResourceLatch2 = new CountDownLatch(1); - Headers associatedRequestHeaders2 = new Headers(); - associatedRequestHeaders2.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - associatedRequestHeaders2.put(HTTPSPDYHeader.URI.name(version()), "/application.js"); - associatedRequestHeaders2.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - associatedRequestHeaders2.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - associatedRequestHeaders2.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - associatedRequestHeaders2.put("referer", "http://localhost:" + connector.getLocalPort() + mainResource); + String jsResource = "/application.js"; + Headers associatedRequestHeaders2 = createHeaders(jsResource); session1.syn(new SynInfo(associatedRequestHeaders2, true), new StreamFrameListener.Adapter() { @Override @@ -136,17 +186,24 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest } }); Assert.assertTrue(associatedResourceLatch2.await(5, TimeUnit.SECONDS)); + } + private void run2ndClientRequests(InetSocketAddress address, Headers mainRequestHeaders, final boolean validateHeaders) throws Exception + { // Create another client, and perform the same request for the main resource, // we expect the css being pushed, but not the js final CountDownLatch mainStreamLatch = new CountDownLatch(2); final CountDownLatch pushDataLatch = new CountDownLatch(1); + final CountDownLatch pushSynHeadersValid = new CountDownLatch(1); Session session2 = startClient(version(), address, new SessionFrameListener.Adapter() { @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { + if(validateHeaders) + validateHeaders(synInfo.getHeaders(), pushSynHeadersValid); + Assert.assertTrue(stream.isUnidirectional()); Assert.assertTrue(synInfo.getHeaders().get(HTTPSPDYHeader.URI.name(version())).value().endsWith(".css")); return new StreamFrameListener.Adapter() @@ -180,8 +237,10 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest } }); - Assert.assertTrue(mainStreamLatch.await(5, TimeUnit.SECONDS)); - Assert.assertTrue(pushDataLatch.await(5, TimeUnit.SECONDS)); + Assert.assertTrue("Main request reply and/or data not received", mainStreamLatch.await(5, TimeUnit.SECONDS)); + Assert.assertTrue("Pushed data not received", pushDataLatch.await(5, TimeUnit.SECONDS)); + if(validateHeaders) + Assert.assertTrue("Push syn headers not valid", pushSynHeadersValid.await(5, TimeUnit.SECONDS)); } @Test @@ -204,13 +263,8 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Session session1 = startClient(version(), address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = new Headers(); - mainRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - String mainResource = "/index.html"; - mainRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), mainResource); - mainRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - mainRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - mainRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); + Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -224,13 +278,7 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch = new CountDownLatch(1); - Headers associatedRequestHeaders = new Headers(); - associatedRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - associatedRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), "/style.css"); - associatedRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - associatedRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - associatedRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - associatedRequestHeaders.put("referer", "http://localhost:" + connector.getLocalPort() + mainResource); + Headers associatedRequestHeaders = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -290,6 +338,7 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest @Test public void testAssociatedResourceWithWrongContentTypeIsNotPushed() throws Exception { + final String fakeResource = "/fake.png"; InetSocketAddress address = startHTTPServer(version(), new AbstractHandler() { @Override @@ -302,7 +351,7 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest response.setContentType("text/html"); output.print("HELLO"); } - else if (url.equals("/fake.png")) + else if (url.equals(fakeResource)) { response.setContentType("text/html"); output.print("IMAGE"); @@ -318,13 +367,8 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Session session1 = startClient(version(), address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = new Headers(); - mainRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - String mainResource = "/index.html"; - mainRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), mainResource); - mainRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - mainRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - mainRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); + Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -338,13 +382,8 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch = new CountDownLatch(1); - Headers associatedRequestHeaders = new Headers(); - associatedRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - associatedRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), "/stylesheet.css"); - associatedRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - associatedRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - associatedRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - associatedRequestHeaders.put("referer", "http://localhost:" + connector.getLocalPort() + mainResource); + String cssResource = "/stylesheet.css"; + Headers associatedRequestHeaders = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -358,13 +397,7 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Assert.assertTrue(associatedResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch fakeAssociatedResourceLatch = new CountDownLatch(1); - Headers fakeAssociatedRequestHeaders = new Headers(); - fakeAssociatedRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - fakeAssociatedRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), "/fake.png"); - fakeAssociatedRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - fakeAssociatedRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - fakeAssociatedRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - fakeAssociatedRequestHeaders.put("referer", "http://localhost:" + connector.getLocalPort() + mainResource); + Headers fakeAssociatedRequestHeaders = createHeaders(fakeResource); session1.syn(new SynInfo(fakeAssociatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -445,13 +478,8 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Session session1 = startClient(version(), address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = new Headers(); - mainRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - String mainResource = "/index.html"; - mainRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), mainResource); - mainRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - mainRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - mainRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); + Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -465,14 +493,7 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch = new CountDownLatch(1); - Headers associatedRequestHeaders = new Headers(); - associatedRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - String associatedResource = "/style.css"; - associatedRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), associatedResource); - associatedRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - associatedRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - associatedRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - associatedRequestHeaders.put("referer", "http://localhost:" + connector.getLocalPort() + mainResource); + Headers associatedRequestHeaders = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -486,13 +507,9 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Assert.assertTrue(associatedResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch nestedResourceLatch = new CountDownLatch(1); - Headers nestedRequestHeaders = new Headers(); - nestedRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - nestedRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), "/image.gif"); - nestedRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - nestedRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - nestedRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - nestedRequestHeaders.put("referer", "http://localhost:" + connector.getLocalPort() + associatedResource); + String imageUrl = "/image.gif"; + Headers nestedRequestHeaders = createHeaders(imageUrl, cssResource); + session1.syn(new SynInfo(nestedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -567,13 +584,8 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Session session1 = startClient(version(), address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = new Headers(); - mainRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - String mainResource = "/index.html"; - mainRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), mainResource); - mainRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - mainRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - mainRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); + Headers mainRequestHeaders = createHeadersWithoutReferrer(mainResource); + session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -587,13 +599,9 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch = new CountDownLatch(1); - Headers associatedRequestHeaders = new Headers(); - associatedRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - associatedRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), "/home.html"); - associatedRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - associatedRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - associatedRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - associatedRequestHeaders.put("referer", "http://localhost:" + connector.getLocalPort() + mainResource); + String associatedResource = "/home.html"; + Headers associatedRequestHeaders = createHeaders(associatedResource); + session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -661,13 +669,7 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Session session1 = startClient(version(), address, null); final CountDownLatch mainResourceLatch = new CountDownLatch(1); - Headers mainRequestHeaders = new Headers(); - mainRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - String mainResource = "/index.html"; - mainRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), mainResource); - mainRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - mainRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - mainRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); + Headers mainRequestHeaders = createHeaders(mainResource); mainRequestHeaders.put("If-Modified-Since", "Tue, 27 Mar 2012 16:36:52 GMT"); session1.syn(new SynInfo(mainRequestHeaders, true), new StreamFrameListener.Adapter() { @@ -682,13 +684,7 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Assert.assertTrue(mainResourceLatch.await(5, TimeUnit.SECONDS)); final CountDownLatch associatedResourceLatch = new CountDownLatch(1); - Headers associatedRequestHeaders = new Headers(); - associatedRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); - associatedRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), "/style.css"); - associatedRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); - associatedRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); - associatedRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); - associatedRequestHeaders.put("referer", "http://localhost:" + connector.getLocalPort() + mainResource); + Headers associatedRequestHeaders = createHeaders(cssResource); session1.syn(new SynInfo(associatedRequestHeaders, true), new StreamFrameListener.Adapter() { @Override @@ -745,4 +741,57 @@ public class ReferrerPushStrategyV2Test extends AbstractHTTPSPDYTest Assert.assertTrue(mainStreamLatch.await(5, TimeUnit.SECONDS)); Assert.assertFalse("We don't expect data to be pushed as the main request contained an if-modified-since header",pushDataLatch.await(1, TimeUnit.SECONDS)); } + + private void validateHeaders(Headers headers, CountDownLatch pushSynHeadersValid) + { + if (validateHeader(headers, HTTPSPDYHeader.STATUS.name(version()), "200") + && validateHeader(headers, HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1") + && validateUriHeader(headers)) + pushSynHeadersValid.countDown(); + } + + private boolean validateHeader(Headers headers, String name, String expectedValue) + { + Headers.Header header = headers.get(name); + if (header != null && expectedValue.equals(header.value())) + return true; + System.out.println(name + " not valid! " + headers); + return false; + } + + private boolean validateUriHeader(Headers headers) + { + Headers.Header uriHeader = headers.get(HTTPSPDYHeader.URI.name(version())); + if (uriHeader != null) + if (version() == SPDY.V2 && uriHeader.value().startsWith("http://")) + return true; + else if (version() == SPDY.V3 && uriHeader.value().startsWith("/") + && headers.get(HTTPSPDYHeader.HOST.name(version())) != null && headers.get(HTTPSPDYHeader.SCHEME.name(version())) != null) + return true; + System.out.println(HTTPSPDYHeader.URI.name(version()) + " not valid!"); + return false; + } + + private Headers createHeaders(String resource) + { + return createHeaders(resource, mainResource); + } + + private Headers createHeaders(String resource, String referrer) + { + Headers associatedRequestHeaders = createHeadersWithoutReferrer(resource); + associatedRequestHeaders.put("referer", "http://localhost:" + connector.getLocalPort() + referrer); + return associatedRequestHeaders; + } + + private Headers createHeadersWithoutReferrer(String resource) + { + Headers associatedRequestHeaders = new Headers(); + associatedRequestHeaders.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); + associatedRequestHeaders.put(HTTPSPDYHeader.URI.name(version()), resource); + associatedRequestHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + associatedRequestHeaders.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); + associatedRequestHeaders.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); + return associatedRequestHeaders; + } } diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyV3Test.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyV3Test.java index a722fde9f46..2b637cb2cdb 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyV3Test.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategyV3Test.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/SSLExternalServerTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/SSLExternalServerTest.java new file mode 100644 index 00000000000..42bd5be8fd0 --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/SSLExternalServerTest.java @@ -0,0 +1,94 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + +package org.eclipse.jetty.spdy.http; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executor; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.jetty.spdy.SPDYClient; +import org.eclipse.jetty.spdy.api.Headers; +import org.eclipse.jetty.spdy.api.ReplyInfo; +import org.eclipse.jetty.spdy.api.SPDY; +import org.eclipse.jetty.spdy.api.Session; +import org.eclipse.jetty.spdy.api.Stream; +import org.eclipse.jetty.spdy.api.StreamFrameListener; +import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; + +public class SSLExternalServerTest extends AbstractHTTPSPDYTest +{ + @Override + protected SPDYClient.Factory newSPDYClientFactory(Executor threadPool) + { + SslContextFactory sslContextFactory = new SslContextFactory(); + // Force TLSv1 + sslContextFactory.setIncludeProtocols("TLSv1"); + return new SPDYClient.Factory(threadPool, sslContextFactory); + } + + @Test + public void testExternalServer() throws Exception + { + String host = "encrypted.google.com"; + int port = 443; + InetSocketAddress address = new InetSocketAddress(host, port); + + try + { + // Test whether there is connectivity to avoid fail the test when offline + Socket socket = new Socket(); + socket.connect(address, 5000); + socket.close(); + } + catch (IOException x) + { + Assume.assumeNoException(x); + } + + final short version = SPDY.V2; + Session session = startClient(version, address, null); + Headers headers = new Headers(); + headers.put(HTTPSPDYHeader.SCHEME.name(version), "https"); + headers.put(HTTPSPDYHeader.HOST.name(version), host + ":" + port); + headers.put(HTTPSPDYHeader.METHOD.name(version), "GET"); + headers.put(HTTPSPDYHeader.URI.name(version), "/"); + headers.put(HTTPSPDYHeader.VERSION.name(version), "HTTP/1.1"); + final CountDownLatch latch = new CountDownLatch(1); + session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter() + { + @Override + public void onReply(Stream stream, ReplyInfo replyInfo) + { + Headers headers = replyInfo.getHeaders(); + Headers.Header versionHeader = headers.get(HTTPSPDYHeader.STATUS.name(version)); + if (versionHeader != null) + { + Matcher matcher = Pattern.compile("(\\d{3}).*").matcher(versionHeader.value()); + if (matcher.matches() && Integer.parseInt(matcher.group(1)) < 400) + latch.countDown(); + } + } + }); + Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); + } +} diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYv2Test.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYv2Test.java index 61ebfd127d9..5bab1f512e3 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYv2Test.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYv2Test.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; @@ -1011,6 +1009,61 @@ public class ServerHTTPSPDYv2Test extends AbstractHTTPSPDYTest Assert.assertTrue(dataLatch.await(5, TimeUnit.SECONDS)); } + @Test + public void testGETWithMultipleMediumContentByPassed() throws Exception + { + final byte[] data = new byte[2048]; + Session session = startClient(version(), startHTTPServer(version(), new AbstractHandler() + { + @Override + public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) + throws IOException, ServletException + { + // The sequence of write/flush/write/write below triggers a condition where + // HttpGenerator._bypass is set to true on the second write(), and the + // third write causes an infinite spin loop on the third write(). + request.setHandled(true); + OutputStream output = httpResponse.getOutputStream(); + output.write(data); + output.flush(); + output.write(data); + output.write(data); + } + }), null); + + Headers headers = new Headers(); + headers.put(HTTPSPDYHeader.METHOD.name(version()), "GET"); + headers.put(HTTPSPDYHeader.URI.name(version()), "/foo"); + headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + headers.put(HTTPSPDYHeader.SCHEME.name(version()), "http"); + headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + connector.getLocalPort()); + final CountDownLatch replyLatch = new CountDownLatch(1); + final CountDownLatch dataLatch = new CountDownLatch(1); + final AtomicInteger contentLength = new AtomicInteger(); + session.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter() + { + @Override + public void onReply(Stream stream, ReplyInfo replyInfo) + { + Assert.assertFalse(replyInfo.isClose()); + Headers replyHeaders = replyInfo.getHeaders(); + Assert.assertTrue(replyHeaders.get(HTTPSPDYHeader.STATUS.name(version())).value().contains("200")); + replyLatch.countDown(); + } + + @Override + public void onData(Stream stream, DataInfo dataInfo) + { + dataInfo.consume(dataInfo.available()); + contentLength.addAndGet(dataInfo.length()); + if (dataInfo.isClose()) + dataLatch.countDown(); + } + }); + Assert.assertTrue(dataLatch.await(5, TimeUnit.SECONDS)); + Assert.assertEquals(3 * data.length, contentLength.get()); + } + @Test public void testPOSTThenSuspendRequestThenReadOneChunkThenComplete() throws Exception { diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYv3Test.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYv3Test.java index bd7ee068850..e6c4de2ac30 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYv3Test.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYv3Test.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy.http; diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYv2Test.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYv2Test.java new file mode 100644 index 00000000000..6c2c89bc874 --- /dev/null +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/proxy/ProxyHTTPSPDYv2Test.java @@ -0,0 +1,764 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + +package org.eclipse.jetty.spdy.proxy; + +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.spdy.SPDYClient; +import org.eclipse.jetty.spdy.SPDYServerConnector; +import org.eclipse.jetty.spdy.ServerSPDYAsyncConnectionFactory; +import org.eclipse.jetty.spdy.api.BytesDataInfo; +import org.eclipse.jetty.spdy.api.DataInfo; +import org.eclipse.jetty.spdy.api.GoAwayInfo; +import org.eclipse.jetty.spdy.api.Handler; +import org.eclipse.jetty.spdy.api.Headers; +import org.eclipse.jetty.spdy.api.PingInfo; +import org.eclipse.jetty.spdy.api.ReplyInfo; +import org.eclipse.jetty.spdy.api.RstInfo; +import org.eclipse.jetty.spdy.api.SPDY; +import org.eclipse.jetty.spdy.api.Session; +import org.eclipse.jetty.spdy.api.SessionFrameListener; +import org.eclipse.jetty.spdy.api.Stream; +import org.eclipse.jetty.spdy.api.StreamFrameListener; +import org.eclipse.jetty.spdy.api.StreamStatus; +import org.eclipse.jetty.spdy.api.SynInfo; +import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.spdy.http.HTTPSPDYHeader; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestWatchman; +import org.junit.runners.model.FrameworkMethod; + +public class ProxyHTTPSPDYv2Test +{ + @Rule + public final TestWatchman testName = new TestWatchman() + { + @Override + public void starting(FrameworkMethod method) + { + super.starting(method); + System.err.printf("Running %s.%s()%n", + method.getMethod().getDeclaringClass().getName(), + method.getName()); + } + }; + + private SPDYClient.Factory factory; + private Server server; + private Server proxy; + private SPDYServerConnector proxyConnector; + + protected short version() + { + return SPDY.V2; + } + + protected InetSocketAddress startServer(ServerSessionFrameListener listener) throws Exception + { + server = new Server(); + SPDYServerConnector serverConnector = new SPDYServerConnector(listener); + serverConnector.setDefaultAsyncConnectionFactory(new ServerSPDYAsyncConnectionFactory(version(), serverConnector.getByteBufferPool(), serverConnector.getExecutor(), serverConnector.getScheduler(), listener)); + serverConnector.setPort(0); + server.addConnector(serverConnector); + server.start(); + return new InetSocketAddress("localhost", serverConnector.getLocalPort()); + } + + protected InetSocketAddress startProxy(InetSocketAddress address) throws Exception + { + proxy = new Server(); + ProxyEngineSelector proxyEngineSelector = new ProxyEngineSelector(); + SPDYProxyEngine spdyProxyEngine = new SPDYProxyEngine(factory); + proxyEngineSelector.putProxyEngine("spdy/" + version(), spdyProxyEngine); + proxyEngineSelector.putProxyServerInfo("localhost", new ProxyEngineSelector.ProxyServerInfo("spdy/" + version(), address.getHostName(), address.getPort())); + proxyConnector = new HTTPSPDYProxyConnector(proxyEngineSelector); + proxyConnector.setPort(0); + proxy.addConnector(proxyConnector); + proxy.start(); + return new InetSocketAddress("localhost", proxyConnector.getLocalPort()); + } + + @Before + public void init() throws Exception + { + factory = new SPDYClient.Factory(); + factory.start(); + } + + @After + public void destroy() throws Exception + { + if (server != null) + { + server.stop(); + server.join(); + } + if (proxy != null) + { + proxy.stop(); + proxy.join(); + } + factory.stop(); + } + + @Test + public void testClosingClientDoesNotCloseServer() throws Exception + { + final CountDownLatch closeLatch = new CountDownLatch(1); + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + Headers responseHeaders = new Headers(); + responseHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + responseHeaders.put(HTTPSPDYHeader.STATUS.name(version()), "200 OK"); + stream.reply(new ReplyInfo(responseHeaders, true)); + return null; + } + + @Override + public void onGoAway(Session session, GoAwayInfo goAwayInfo) + { + closeLatch.countDown(); + } + })); + + Socket client = new Socket(); + client.connect(proxyAddress); + OutputStream output = client.getOutputStream(); + + String request = "" + + "GET / HTTP/1.1\r\n" + + "Host: localhost:" + proxyAddress.getPort() + "\r\n" + + "\r\n"; + output.write(request.getBytes("UTF-8")); + output.flush(); + + InputStream input = client.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); + String line = reader.readLine(); + Assert.assertTrue(line.contains(" 200")); + while (line.length() > 0) + line = reader.readLine(); + Assert.assertFalse(reader.ready()); + + client.close(); + + // Must not close, other clients may still be connected + Assert.assertFalse(closeLatch.await(1, TimeUnit.SECONDS)); + } + + @Test + public void testGETThenNoContentFromTwoClients() throws Exception + { + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + Assert.assertTrue(synInfo.isClose()); + Headers requestHeaders = synInfo.getHeaders(); + Assert.assertNotNull(requestHeaders.get("via")); + + Headers responseHeaders = new Headers(); + responseHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + responseHeaders.put(HTTPSPDYHeader.STATUS.name(version()), "200 OK"); + ReplyInfo replyInfo = new ReplyInfo(responseHeaders, true); + stream.reply(replyInfo); + return null; + } + })); + + Socket client1 = new Socket(); + client1.connect(proxyAddress); + OutputStream output1 = client1.getOutputStream(); + + String request = "" + + "GET / HTTP/1.1\r\n" + + "Host: localhost:" + proxyAddress.getPort() + "\r\n" + + "\r\n"; + output1.write(request.getBytes("UTF-8")); + output1.flush(); + + InputStream input1 = client1.getInputStream(); + BufferedReader reader1 = new BufferedReader(new InputStreamReader(input1, "UTF-8")); + String line = reader1.readLine(); + Assert.assertTrue(line.contains(" 200")); + while (line.length() > 0) + line = reader1.readLine(); + Assert.assertFalse(reader1.ready()); + + // Perform another request with another client + Socket client2 = new Socket(); + client2.connect(proxyAddress); + OutputStream output2 = client2.getOutputStream(); + + output2.write(request.getBytes("UTF-8")); + output2.flush(); + + InputStream input2 = client2.getInputStream(); + BufferedReader reader2 = new BufferedReader(new InputStreamReader(input2, "UTF-8")); + line = reader2.readLine(); + Assert.assertTrue(line.contains(" 200")); + while (line.length() > 0) + line = reader2.readLine(); + Assert.assertFalse(reader2.ready()); + + client1.close(); + client2.close(); + } + + @Test + public void testGETThenSmallResponseContent() throws Exception + { + final byte[] data = "0123456789ABCDEF".getBytes("UTF-8"); + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + Assert.assertTrue(synInfo.isClose()); + Headers requestHeaders = synInfo.getHeaders(); + Assert.assertNotNull(requestHeaders.get("via")); + + Headers responseHeaders = new Headers(); + responseHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + responseHeaders.put(HTTPSPDYHeader.STATUS.name(version()), "200 OK"); + ReplyInfo replyInfo = new ReplyInfo(responseHeaders, false); + stream.reply(replyInfo); + stream.data(new BytesDataInfo(data, true)); + + return null; + } + })); + + Socket client = new Socket(); + client.connect(proxyAddress); + OutputStream output = client.getOutputStream(); + + String request = "" + + "GET / HTTP/1.1\r\n" + + "Host: localhost:" + proxyAddress.getPort() + "\r\n" + + "\r\n"; + output.write(request.getBytes("UTF-8")); + output.flush(); + + InputStream input = client.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); + String line = reader.readLine(); + Assert.assertTrue(line.contains(" 200")); + while (line.length() > 0) + line = reader.readLine(); + for (byte datum : data) + Assert.assertEquals(datum, reader.read()); + Assert.assertFalse(reader.ready()); + + // Perform another request so that we are sure we reset the states of parsers and generators + output.write(request.getBytes("UTF-8")); + output.flush(); + + line = reader.readLine(); + Assert.assertTrue(line.contains(" 200")); + while (line.length() > 0) + line = reader.readLine(); + for (byte datum : data) + Assert.assertEquals(datum, reader.read()); + Assert.assertFalse(reader.ready()); + + client.close(); + } + + @Test + public void testPOSTWithSmallRequestContentThenRedirect() throws Exception + { + final byte[] data = "0123456789ABCDEF".getBytes("UTF-8"); + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + return new StreamFrameListener.Adapter() + { + @Override + public void onData(Stream stream, DataInfo dataInfo) + { + dataInfo.consume(dataInfo.length()); + if (dataInfo.isClose()) + { + Headers headers = new Headers(); + headers.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + headers.put(HTTPSPDYHeader.STATUS.name(version()), "303 See Other"); + stream.reply(new ReplyInfo(headers, true)); + } + } + }; + } + })); + + Socket client = new Socket(); + client.connect(proxyAddress); + OutputStream output = client.getOutputStream(); + + String request = "" + + "POST / HTTP/1.1\r\n" + + "Host: localhost:" + proxyAddress.getPort() + "\r\n" + + "Content-Length: " + data.length + "\r\n" + + "Content-Type: application/octet-stream\r\n" + + "\r\n"; + output.write(request.getBytes("UTF-8")); + output.write(data); + output.flush(); + + InputStream input = client.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); + String line = reader.readLine(); + Assert.assertTrue(line.contains(" 303")); + while (line.length() > 0) + line = reader.readLine(); + Assert.assertFalse(reader.ready()); + + // Perform another request so that we are sure we reset the states of parsers and generators + output.write(request.getBytes("UTF-8")); + output.write(data); + output.flush(); + + line = reader.readLine(); + Assert.assertTrue(line.contains(" 303")); + while (line.length() > 0) + line = reader.readLine(); + Assert.assertFalse(reader.ready()); + + client.close(); + } + + @Test + public void testPOSTWithSmallRequestContentThenSmallResponseContent() throws Exception + { + final byte[] data = "0123456789ABCDEF".getBytes("UTF-8"); + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + return new StreamFrameListener.Adapter() + { + @Override + public void onData(Stream stream, DataInfo dataInfo) + { + dataInfo.consume(dataInfo.length()); + if (dataInfo.isClose()) + { + Headers responseHeaders = new Headers(); + responseHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + responseHeaders.put(HTTPSPDYHeader.STATUS.name(version()), "200 OK"); + ReplyInfo replyInfo = new ReplyInfo(responseHeaders, false); + stream.reply(replyInfo); + stream.data(new BytesDataInfo(data, true)); + } + } + }; + } + })); + + Socket client = new Socket(); + client.connect(proxyAddress); + OutputStream output = client.getOutputStream(); + + String request = "" + + "POST / HTTP/1.1\r\n" + + "Host: localhost:" + proxyAddress.getPort() + "\r\n" + + "Content-Length: " + data.length + "\r\n" + + "Content-Type: application/octet-stream\r\n" + + "\r\n"; + output.write(request.getBytes("UTF-8")); + output.write(data); + output.flush(); + + InputStream input = client.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); + String line = reader.readLine(); + Assert.assertTrue(line.contains(" 200")); + while (line.length() > 0) + line = reader.readLine(); + for (byte datum : data) + Assert.assertEquals(datum, reader.read()); + Assert.assertFalse(reader.ready()); + + // Perform another request so that we are sure we reset the states of parsers and generators + output.write(request.getBytes("UTF-8")); + output.write(data); + output.flush(); + + line = reader.readLine(); + Assert.assertTrue(line.contains(" 200")); + while (line.length() > 0) + line = reader.readLine(); + for (byte datum : data) + Assert.assertEquals(datum, reader.read()); + Assert.assertFalse(reader.ready()); + + client.close(); + } + + @Test + public void testSYNThenREPLY() throws Exception + { + final String header = "foo"; + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + Headers requestHeaders = synInfo.getHeaders(); + Assert.assertNotNull(requestHeaders.get("via")); + Assert.assertNotNull(requestHeaders.get(header)); + + Headers responseHeaders = new Headers(); + responseHeaders.put(header, "baz"); + stream.reply(new ReplyInfo(responseHeaders, true)); + return null; + } + })); + proxyConnector.setDefaultAsyncConnectionFactory(proxyConnector.getAsyncConnectionFactory("spdy/" + version())); + + Session client = factory.newSPDYClient(version()).connect(proxyAddress, null).get(5, TimeUnit.SECONDS); + + final CountDownLatch replyLatch = new CountDownLatch(1); + Headers headers = new Headers(); + headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + proxyAddress.getPort()); + headers.put(header, "bar"); + client.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter() + { + @Override + public void onReply(Stream stream, ReplyInfo replyInfo) + { + Headers headers = replyInfo.getHeaders(); + Assert.assertNotNull(headers.get(header)); + replyLatch.countDown(); + } + }); + + Assert.assertTrue(replyLatch.await(5, TimeUnit.SECONDS)); + + client.goAway().get(5, TimeUnit.SECONDS); + } + + @Test + public void testSYNThenREPLYAndDATA() throws Exception + { + final byte[] data = "0123456789ABCDEF".getBytes("UTF-8"); + final String header = "foo"; + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + Headers requestHeaders = synInfo.getHeaders(); + Assert.assertNotNull(requestHeaders.get("via")); + Assert.assertNotNull(requestHeaders.get(header)); + + Headers responseHeaders = new Headers(); + responseHeaders.put(header, "baz"); + stream.reply(new ReplyInfo(responseHeaders, false)); + stream.data(new BytesDataInfo(data, true)); + return null; + } + })); + proxyConnector.setDefaultAsyncConnectionFactory(proxyConnector.getAsyncConnectionFactory("spdy/" + version())); + + Session client = factory.newSPDYClient(version()).connect(proxyAddress, null).get(5, TimeUnit.SECONDS); + + final CountDownLatch replyLatch = new CountDownLatch(1); + final CountDownLatch dataLatch = new CountDownLatch(1); + Headers headers = new Headers(); + headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + proxyAddress.getPort()); + headers.put(header, "bar"); + client.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter() + { + private final ByteArrayOutputStream result = new ByteArrayOutputStream(); + + @Override + public void onReply(Stream stream, ReplyInfo replyInfo) + { + Headers headers = replyInfo.getHeaders(); + Assert.assertNotNull(headers.get(header)); + replyLatch.countDown(); + } + + @Override + public void onData(Stream stream, DataInfo dataInfo) + { + result.write(dataInfo.asBytes(true), 0, dataInfo.length()); + if (dataInfo.isClose()) + { + Assert.assertArrayEquals(data, result.toByteArray()); + dataLatch.countDown(); + } + } + }); + + Assert.assertTrue(replyLatch.await(5, TimeUnit.SECONDS)); + Assert.assertTrue(dataLatch.await(5, TimeUnit.SECONDS)); + + client.goAway().get(5, TimeUnit.SECONDS); + } + + @Test + public void testGETThenSPDYPushIsIgnored() throws Exception + { + final byte[] data = "0123456789ABCDEF".getBytes("UTF-8"); + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + Headers responseHeaders = new Headers(); + responseHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + responseHeaders.put(HTTPSPDYHeader.STATUS.name(version()), "200 OK"); + + Headers pushHeaders = new Headers(); + pushHeaders.put(HTTPSPDYHeader.URI.name(version()), "/push"); + stream.syn(new SynInfo(pushHeaders, false), 5, TimeUnit.SECONDS, new Handler.Adapter() + { + @Override + public void completed(Stream pushStream) + { + pushStream.data(new BytesDataInfo(data, true)); + } + }); + + stream.reply(new ReplyInfo(responseHeaders, true)); + return null; + } + })); + + Socket client = new Socket(); + client.connect(proxyAddress); + OutputStream output = client.getOutputStream(); + + String request = "" + + "GET / HTTP/1.1\r\n" + + "Host: localhost:" + proxyAddress.getPort() + "\r\n" + + "\r\n"; + output.write(request.getBytes("UTF-8")); + output.flush(); + + client.setSoTimeout(1000); + InputStream input = client.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); + String line = reader.readLine(); + Assert.assertTrue(line.contains(" 200")); + while (line.length() > 0) + line = reader.readLine(); + Assert.assertFalse(reader.ready()); + + client.close(); + } + + @Test + public void testSYNThenSPDYPushIsReceived() throws Exception + { + final byte[] data = "0123456789ABCDEF".getBytes("UTF-8"); + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + Headers responseHeaders = new Headers(); + responseHeaders.put(HTTPSPDYHeader.VERSION.name(version()), "HTTP/1.1"); + responseHeaders.put(HTTPSPDYHeader.STATUS.name(version()), "200 OK"); + stream.reply(new ReplyInfo(responseHeaders, false)); + + Headers pushHeaders = new Headers(); + pushHeaders.put(HTTPSPDYHeader.URI.name(version()), "/push"); + stream.syn(new SynInfo(pushHeaders, false), 5, TimeUnit.SECONDS, new Handler.Adapter() + { + @Override + public void completed(Stream pushStream) + { + pushStream.data(new BytesDataInfo(data, true)); + } + }); + + stream.data(new BytesDataInfo(data, true)); + + return null; + } + })); + proxyConnector.setDefaultAsyncConnectionFactory(proxyConnector.getAsyncConnectionFactory("spdy/" + version())); + + final CountDownLatch pushSynLatch = new CountDownLatch(1); + final CountDownLatch pushDataLatch = new CountDownLatch(1); + Session client = factory.newSPDYClient(version()).connect(proxyAddress, new SessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + pushSynLatch.countDown(); + return new StreamFrameListener.Adapter() + { + @Override + public void onData(Stream stream, DataInfo dataInfo) + { + dataInfo.consume(dataInfo.length()); + if (dataInfo.isClose()) + pushDataLatch.countDown(); + } + }; + } + }).get(5, TimeUnit.SECONDS); + + Headers headers = new Headers(); + headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + proxyAddress.getPort()); + final CountDownLatch replyLatch = new CountDownLatch(1); + final CountDownLatch dataLatch = new CountDownLatch(1); + client.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter() + { + @Override + public void onReply(Stream stream, ReplyInfo replyInfo) + { + replyLatch.countDown(); + } + + @Override + public void onData(Stream stream, DataInfo dataInfo) + { + dataInfo.consume(dataInfo.length()); + if (dataInfo.isClose()) + dataLatch.countDown(); + } + }); + + Assert.assertTrue(replyLatch.await(5, TimeUnit.SECONDS)); + Assert.assertTrue(pushSynLatch.await(5, TimeUnit.SECONDS)); + Assert.assertTrue(pushDataLatch.await(5, TimeUnit.SECONDS)); + Assert.assertTrue(dataLatch.await(5, TimeUnit.SECONDS)); + + client.goAway().get(5, TimeUnit.SECONDS); + } + + @Test + public void testPING() throws Exception + { + // PING is per hop, and it does not carry the information to which server to ping to + // We just verify that it works + + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter())); + proxyConnector.setDefaultAsyncConnectionFactory(proxyConnector.getAsyncConnectionFactory("spdy/" + version())); + + final CountDownLatch pingLatch = new CountDownLatch(1); + Session client = factory.newSPDYClient(version()).connect(proxyAddress, new SessionFrameListener.Adapter() + { + @Override + public void onPing(Session session, PingInfo pingInfo) + { + pingLatch.countDown(); + } + }).get(5, TimeUnit.SECONDS); + + client.ping().get(5, TimeUnit.SECONDS); + + Assert.assertTrue(pingLatch.await(5, TimeUnit.SECONDS)); + + client.goAway().get(5, TimeUnit.SECONDS); + } + + @Test + public void testGETThenReset() throws Exception + { + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + Assert.assertTrue(synInfo.isClose()); + Headers requestHeaders = synInfo.getHeaders(); + Assert.assertNotNull(requestHeaders.get("via")); + + stream.getSession().rst(new RstInfo(stream.getId(), StreamStatus.REFUSED_STREAM)); + + return null; + } + })); + + Socket client = new Socket(); + client.connect(proxyAddress); + OutputStream output = client.getOutputStream(); + + String request = "" + + "GET / HTTP/1.1\r\n" + + "Host: localhost:" + proxyAddress.getPort() + "\r\n" + + "\r\n"; + output.write(request.getBytes("UTF-8")); + output.flush(); + + InputStream input = client.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); + Assert.assertNull(reader.readLine()); + + client.close(); + } + + @Test + public void testSYNThenReset() throws Exception + { + InetSocketAddress proxyAddress = startProxy(startServer(new ServerSessionFrameListener.Adapter() + { + @Override + public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) + { + Assert.assertTrue(synInfo.isClose()); + Headers requestHeaders = synInfo.getHeaders(); + Assert.assertNotNull(requestHeaders.get("via")); + + stream.getSession().rst(new RstInfo(stream.getId(), StreamStatus.REFUSED_STREAM)); + + return null; + } + })); + proxyConnector.setDefaultAsyncConnectionFactory(proxyConnector.getAsyncConnectionFactory("spdy/" + version())); + + final CountDownLatch resetLatch = new CountDownLatch(1); + Session client = factory.newSPDYClient(version()).connect(proxyAddress, new SessionFrameListener.Adapter() + { + @Override + public void onRst(Session session, RstInfo rstInfo) + { + resetLatch.countDown(); + } + }).get(5, TimeUnit.SECONDS); + + Headers headers = new Headers(); + headers.put(HTTPSPDYHeader.HOST.name(version()), "localhost:" + proxyAddress.getPort()); + client.syn(new SynInfo(headers, true), null); + + Assert.assertTrue(resetLatch.await(5, TimeUnit.SECONDS)); + + client.goAway().get(5, TimeUnit.SECONDS); + } +} diff --git a/jetty-spdy/spdy-jetty/pom.xml b/jetty-spdy/spdy-jetty/pom.xml index 31a7790f7ea..17266443839 100644 --- a/jetty-spdy/spdy-jetty/pom.xml +++ b/jetty-spdy/spdy-jetty/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.spdy spdy-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 spdy-jetty diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java index 37077870474..97f9db59c40 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncConnection.java index 70a9ac146af..a2888ce88e5 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncConnection.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncConnection.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java index c1fd5e2e251..58dbc8a9aa2 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/FlowControlStrategyFactory.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/FlowControlStrategyFactory.java index baa0cb99d45..a668f2f2f07 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/FlowControlStrategyFactory.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/FlowControlStrategyFactory.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java index e6df8fd3fde..bb6b45cd5ec 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; @@ -236,4 +234,9 @@ public class SPDYAsyncConnection extends AbstractConnection implements AsyncConn { this.session = session; } + + public String toString() + { + return String.format("%s@%x{endp=%s@%x}",getClass().getSimpleName(),hashCode(),getEndPoint().getClass().getSimpleName(),getEndPoint().hashCode()); + } } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java index 071ed8ea022..65ecc2f53a5 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java @@ -1,23 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package org.eclipse.jetty.spdy; @@ -101,7 +94,7 @@ public class SPDYClient channel.socket().setTcpNoDelay(true); channel.configureBlocking(false); - SessionPromise result = new SessionPromise(this, listener); + SessionPromise result = new SessionPromise(channel, this, listener); channel.connect(address); factory.selector.register(channel, result); @@ -419,14 +412,31 @@ public class SPDYClient private static class SessionPromise extends Promise { + private final SocketChannel channel; private final SPDYClient client; private final SessionFrameListener listener; - private SessionPromise(SPDYClient client, SessionFrameListener listener) + private SessionPromise(SocketChannel channel, SPDYClient client, SessionFrameListener listener) { + this.channel = channel; this.client = client; this.listener = listener; } + + @Override + public boolean cancel(boolean mayInterruptIfRunning) + { + try + { + super.cancel(mayInterruptIfRunning); + channel.close(); + return true; + } + catch (IOException x) + { + return true; + } + } } private static class ClientSPDYAsyncConnectionFactory implements AsyncConnectionFactory diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java index 65ada1e7165..f85327189e2 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java @@ -1,21 +1,20 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; +import java.io.IOException; import java.nio.channels.SocketChannel; import java.util.ArrayList; import java.util.Collection; @@ -41,6 +40,7 @@ import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.util.component.AggregateLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.ssl.SslContextFactory; @@ -156,6 +156,14 @@ public class SPDYServerConnector extends SelectChannelConnector } } + public void clearAsyncConnectionFactories() + { + synchronized (factories) + { + factories.clear(); + } + } + protected List provideProtocols() { synchronized (factories) @@ -304,4 +312,14 @@ public class SPDYServerConnector extends SelectChannelConnector threadPool.dispatch(command); } } + + + @Override + public void dump(Appendable out, String indent) throws IOException + { + super.dump(out,indent); + AggregateLifeCycle.dump(out, indent, new ArrayList(sessions)); + } + + } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java index 507600e1e3c..4e45eedf74e 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; @@ -71,6 +69,7 @@ public class ServerSPDYAsyncConnectionFactory implements AsyncConnectionFactory FlowControlStrategy flowControlStrategy = connector.newFlowControlStrategy(version); StandardSession session = new StandardSession(version, bufferPool, threadPool, scheduler, connection, connection, 2, listener, generator, flowControlStrategy); + session.setAttribute("org.eclipse.jetty.spdy.remoteAddress", endPoint.getRemoteAddr()); session.setWindowSize(connector.getInitialWindowSize()); parser.addListener(session); connection.setSession(session); diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java index 04bf0f6987b..ea99abd3e22 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java index 0d51b27c910..a6108a3aa69 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/FlowControlTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/FlowControlTest.java index 54be2633c96..00c624fc5f4 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/FlowControlTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/FlowControlTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/GoAwayTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/GoAwayTest.java index ec2a0f6f672..3f6be74c2d4 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/GoAwayTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/GoAwayTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; @@ -219,10 +216,10 @@ public class GoAwayTest extends AbstractTest Assert.assertThat(x.getCause(), CoreMatchers.instanceOf(ClosedChannelException.class)); } - // Be sure the last good stream is the first + // The last good stream is the second, because it was received by the server Assert.assertTrue(goAwayLatch.await(5, TimeUnit.SECONDS)); GoAwayInfo goAway = goAwayRef.get(); Assert.assertNotNull(goAway); - Assert.assertEquals(stream1.getId(), goAway.getLastStreamId()); + Assert.assertEquals(stream2.getId(), goAway.getLastStreamId()); } } diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/HeadersTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/HeadersTest.java index 154909b00e1..20f8a2af523 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/HeadersTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/HeadersTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java index 69cec29b6d6..2611bf28c9b 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PingTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PingTest.java index aca05954d17..9229e7e8830 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PingTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PingTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java index 791b6906770..b0c19f7fe54 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java @@ -1,3 +1,16 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; import static org.junit.Assert.*; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java index d9073fd2270..cd21fe5fc5f 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ResetStreamTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ResetStreamTest.java index 990614e33e3..3430ff441c7 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ResetStreamTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ResetStreamTest.java @@ -1,3 +1,16 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; import java.util.concurrent.CountDownLatch; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SPDYClientFactoryTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SPDYClientFactoryTest.java index 8124d674a8e..84e571b312d 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SPDYClientFactoryTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SPDYClientFactoryTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SPDYServerConnectorTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SPDYServerConnectorTest.java index d168b11d783..0b46d750ca2 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SPDYServerConnectorTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SPDYServerConnectorTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLEngineLeakTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLEngineLeakTest.java index 2e5855118cd..d6c4b600f72 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLEngineLeakTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLEngineLeakTest.java @@ -1,3 +1,16 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; import java.lang.reflect.Field; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLSynReplyTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLSynReplyTest.java index ee8ecdf70c4..aa398e0073c 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLSynReplyTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLSynReplyTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SettingsTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SettingsTest.java index 9ac5f678c44..8a7731d267f 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SettingsTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SettingsTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java index 129ddd86acd..fe9d070add2 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java @@ -1,18 +1,16 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java index 207e1335b03..7d5db72cb07 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java @@ -1,18 +1,15 @@ -/* - * Copyright (c) 2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.spdy; diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java index 0dbef02f2a3..0f996bb9e6f 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java @@ -1,3 +1,16 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty.spdy; import java.net.InetSocketAddress; diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index 662273d6b68..3092c5c88d8 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-start diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/CommandLineBuilder.java b/jetty-start/src/main/java/org/eclipse/jetty/start/CommandLineBuilder.java index 7d2eb7d3e18..ba2e8b9dc83 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/CommandLineBuilder.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/CommandLineBuilder.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.start; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.ArrayList; import java.util.List; diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Monitor.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Monitor.java index 40322680086..4cc367736c9 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Monitor.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Monitor.java @@ -111,7 +111,18 @@ public class Monitor extends Thread try {socket.close();}catch(Exception e){e.printStackTrace();} try {_socket.close();}catch(Exception e){e.printStackTrace();} if (_process!=null) + { + //if we have a child process, wait for it to finish before we stop + try + { _process.destroy(); + _process.waitFor(); + } + catch (InterruptedException e) + { + System.err.println("Interrupted waiting for child to terminate"); + } + } System.exit(0); } else if ("status".equals(cmd)) diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/CommandLineBuilderTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/CommandLineBuilderTest.java index 089ed135c2f..c4ff43e326d 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/CommandLineBuilderTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/CommandLineBuilderTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.start; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.*; import org.junit.Assert; diff --git a/jetty-util/pom.xml b/jetty-util/pom.xml index 4bfb39db734..4a475c023be 100644 --- a/jetty-util/pom.xml +++ b/jetty-util/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-util diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Atomics.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Atomics.java new file mode 100644 index 00000000000..97a3e1be52e --- /dev/null +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Atomics.java @@ -0,0 +1,68 @@ +// ======================================================================== +// Copyright (c) 2012 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== + +package org.eclipse.jetty.util; + +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + +public class Atomics +{ + private Atomics() + { + } + + public static void updateMin(AtomicLong currentMin, long newValue) + { + long oldValue = currentMin.get(); + while (newValue < oldValue) + { + if (currentMin.compareAndSet(oldValue, newValue)) + break; + oldValue = currentMin.get(); + } + } + + public static void updateMax(AtomicLong currentMax, long newValue) + { + long oldValue = currentMax.get(); + while (newValue > oldValue) + { + if (currentMax.compareAndSet(oldValue, newValue)) + break; + oldValue = currentMax.get(); + } + } + + public static void updateMin(AtomicInteger currentMin, int newValue) + { + int oldValue = currentMin.get(); + while (newValue < oldValue) + { + if (currentMin.compareAndSet(oldValue, newValue)) + break; + oldValue = currentMin.get(); + } + } + + public static void updateMax(AtomicInteger currentMax, int newValue) + { + int oldValue = currentMax.get(); + while (newValue > oldValue) + { + if (currentMax.compareAndSet(oldValue, newValue)) + break; + oldValue = currentMax.get(); + } + } +} diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ConcurrentHashSet.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ConcurrentHashSet.java index 844db3a7d51..1aa79efcc45 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ConcurrentHashSet.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ConcurrentHashSet.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.AbstractSet; import java.util.Collection; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java index 6ede17ad732..b02b6cf1fd9 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java @@ -13,11 +13,15 @@ package org.eclipse.jetty.util; +import java.io.File; import java.net.URL; +import java.net.URLClassLoader; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; +import org.eclipse.jetty.util.resource.Resource; + /* ------------------------------------------------------------ */ /** ClassLoader Helper. * This helper class allows classes to be loaded either from the @@ -112,7 +116,10 @@ public class Loader return c; throw ex; } - + + + + /* ------------------------------------------------------------ */ public static ResourceBundle getResourceBundle(Class loadClass,String name,boolean checkParents, Locale locale) throws MissingResourceException { @@ -145,6 +152,38 @@ public class Loader throw ex; } - + + /* ------------------------------------------------------------ */ + /** + * Generate the classpath (as a string) of all classloaders + * above the given classloader. + * + * This is primarily used for jasper. + * @return the system class path + */ + public static String getClassPath(ClassLoader loader) throws Exception + { + StringBuilder classpath=new StringBuilder(); + while (loader != null && (loader instanceof URLClassLoader)) + { + URL[] urls = ((URLClassLoader)loader).getURLs(); + if (urls != null) + { + for (int i=0;i0) + classpath.append(File.pathSeparatorChar); + classpath.append(file.getAbsolutePath()); + } + } + } + loader = loader.getParent(); + } + return classpath.toString(); + } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/PatternMatcher.java b/jetty-util/src/main/java/org/eclipse/jetty/util/PatternMatcher.java index d5739069798..12ceff01162 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/PatternMatcher.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/PatternMatcher.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.net.URI; import java.util.ArrayList; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/RunningStats.java b/jetty-util/src/main/java/org/eclipse/jetty/util/RunningStats.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/SimpleStats.java b/jetty-util/src/main/java/org/eclipse/jetty/util/SimpleStats.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java index 6a4c066a3f5..d18d9a3f727 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java @@ -252,7 +252,7 @@ public class URIUtil } /* ------------------------------------------------------------ */ - /* Decode a URI path. + /* Decode a URI path and strip parameters * @param path The path the encode * @param buf StringBuilder to encode path into */ @@ -260,8 +260,10 @@ public class URIUtil { if (path==null) return null; + // Array to hold all converted characters char[] chars=null; int n=0; + // Array to hold a sequence of %encodings byte[] bytes=null; int b=0; @@ -283,14 +285,26 @@ public class URIUtil i+=2; continue; } + else if (c==';') + { + if (chars==null) + { + chars=new char[len]; + path.getChars(0,i,chars,0); + n=i; + } + break; + } else if (bytes==null) { n++; continue; } + // Do we have some bytes to convert? if (b>0) { + // convert series of bytes and add to chars String s; try { @@ -311,8 +325,10 @@ public class URIUtil if (chars==null) return path; + // if we have a remaining sequence of bytes if (b>0) { + // convert series of bytes and add to chars String s; try { @@ -330,7 +346,7 @@ public class URIUtil } /* ------------------------------------------------------------ */ - /* Decode a URI path. + /* Decode a URI path and strip parameters. * @param path The path the encode * @param buf StringBuilder to encode path into */ @@ -348,6 +364,11 @@ public class URIUtil b=(byte)(0xff&TypeUtil.parseInt(buf,i+offset+1,2,16)); i+=2; } + else if (b==';') + { + length=i; + break; + } else if (bytes==null) { n++; @@ -438,20 +459,6 @@ public class URIUtil return null; } - /* ------------------------------------------------------------ */ - /** Strip parameters from a path. - * Return path upto any semicolon parameters. - */ - public static String stripPath(String path) - { - if (path==null) - return null; - int semi=path.indexOf(';'); - if (semi<0) - return path; - return path.substring(0,semi); - } - /* ------------------------------------------------------------ */ /** Convert a path to a cananonical form. * All instances of "." and ".." are factored out. Null is returned diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AggregateLifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AggregateLifeCycle.java index 917d9ddfc71..55b38fb6328 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AggregateLifeCycle.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AggregateLifeCycle.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.component; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; import java.util.ArrayList; @@ -374,10 +386,10 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable for (Bean b : _beans) { i++; - + + out.append(indent).append(" +- "); if (b._managed) { - out.append(indent).append(" +- "); if (b._bean instanceof Dumpable) ((Dumpable)b._bean).dump(out,indent+(i==size?" ":" | ")); else diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Destroyable.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Destroyable.java index 2a541ac4d5f..62b4c05f532 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Destroyable.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Destroyable.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.component; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Dumpable.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Dumpable.java index 061d29225ca..429a040ec49 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Dumpable.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Dumpable.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.component; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/FileDestroyable.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/FileDestroyable.java index 4f5b7b1d0a8..566a4b37485 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/FileDestroyable.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/FileDestroyable.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.component; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.IOException; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/AbstractLogger.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/AbstractLogger.java index 1320a9fc426..eafbf2bf3ce 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/AbstractLogger.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/AbstractLogger.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.log; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== /* ------------------------------------------------------------ */ diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/security/Constraint.java b/jetty-util/src/main/java/org/eclipse/jetty/util/security/Constraint.java index 320625ca96c..ef353c7669a 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/security/Constraint.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/security/Constraint.java @@ -37,6 +37,8 @@ public class Constraint implements Cloneable, Serializable public final static String __SPNEGO_AUTH = "SPNEGO"; + public final static String __NEGOTIATE_AUTH = "NEGOTIATE"; + public static boolean validateMethod (String method) { if (method == null) @@ -47,7 +49,8 @@ public class Constraint implements Cloneable, Serializable || method.equals (__DIGEST_AUTH) || method.equals (__CERT_AUTH) || method.equals(__CERT_AUTH2) - || method.equals(__SPNEGO_AUTH)); + || method.equals(__SPNEGO_AUTH) + || method.equals(__NEGOTIATE_AUTH)); } /* ------------------------------------------------------------ */ diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/statistic/CounterStatistic.java b/jetty-util/src/main/java/org/eclipse/jetty/util/statistic/CounterStatistic.java index 8c9b33d3105..79ec208289d 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/statistic/CounterStatistic.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/statistic/CounterStatistic.java @@ -4,17 +4,19 @@ // 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 +// 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. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.util.statistic; import java.util.concurrent.atomic.AtomicLong; +import org.eclipse.jetty.util.Atomics; + /* ------------------------------------------------------------ */ /** Statistics on a counter value. @@ -22,9 +24,9 @@ import java.util.concurrent.atomic.AtomicLong; * Keep total, current and maximum values of a counter that * can be incremented and decremented. The total refers only * to increments. - * + * */ -public class CounterStatistic +public class CounterStatistic { protected final AtomicLong _max = new AtomicLong(); protected final AtomicLong _curr = new AtomicLong(); @@ -39,11 +41,11 @@ public class CounterStatistic /* ------------------------------------------------------------ */ public void reset(final long value) { - _max.set(value); + _max.set(value); _curr.set(value); _total.set(0); // total always set to 0 to properly calculate cumulative total } - + /* ------------------------------------------------------------ */ /** * @param delta the amount to add to the count @@ -53,15 +55,9 @@ public class CounterStatistic long value=_curr.addAndGet(delta); if (delta > 0) _total.addAndGet(delta); - long oldValue = _max.get(); - while (value > oldValue) - { - if (_max.compareAndSet(oldValue, value)) - break; - oldValue = _max.get(); - } + Atomics.updateMax(_max,value); } - + /* ------------------------------------------------------------ */ /** * @param delta the amount to subtract the count by. @@ -70,7 +66,7 @@ public class CounterStatistic { add(-delta); } - + /* ------------------------------------------------------------ */ /** */ @@ -78,7 +74,7 @@ public class CounterStatistic { add(1); } - + /* ------------------------------------------------------------ */ /** */ @@ -95,7 +91,7 @@ public class CounterStatistic { return _max.get(); } - + /* ------------------------------------------------------------ */ /** * @return current value @@ -104,7 +100,7 @@ public class CounterStatistic { return _curr.get(); } - + /* ------------------------------------------------------------ */ /** * @return total value @@ -113,9 +109,4 @@ public class CounterStatistic { return _total.get(); } - - /* ------------------------------------------------------------ */ - protected void upxdateMax(long value) - { - } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/statistic/SampleStatistic.java b/jetty-util/src/main/java/org/eclipse/jetty/util/statistic/SampleStatistic.java index fbdb422b0b3..b887588cc1b 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/statistic/SampleStatistic.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/statistic/SampleStatistic.java @@ -4,23 +4,25 @@ // 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 +// 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. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.util.statistic; import java.util.concurrent.atomic.AtomicLong; +import org.eclipse.jetty.util.Atomics; + /* ------------------------------------------------------------ */ /** * SampledStatistics *

    - * Provides max, total, mean, count, variance, and standard + * Provides max, total, mean, count, variance, and standard * deviation of continuous sequence of samples. *

    * Calculates estimates of mean, variance, and standard deviation @@ -53,25 +55,17 @@ public class SampleStatistic { long total = _total.addAndGet(sample); long count = _count.incrementAndGet(); - + if (count>1) { long mean10 = total*10/count; long delta10 = sample*10 - mean10; _totalVariance100.addAndGet(delta10*delta10); - } - - long oldMax = _max.get(); - while (sample > oldMax) - { - if (_max.compareAndSet(oldMax, sample)) - break; - oldMax = _max.get(); } - + + Atomics.updateMax(_max, sample); } - /* ------------------------------------------------------------ */ /** * @return the max value */ @@ -80,37 +74,31 @@ public class SampleStatistic return _max.get(); } - /* ------------------------------------------------------------ */ public long getTotal() { return _total.get(); } - /* ------------------------------------------------------------ */ public long getCount() { return _count.get(); } - /* ------------------------------------------------------------ */ public double getMean() { return (double)_total.get()/_count.get(); } - /* ------------------------------------------------------------ */ public double getVariance() { final long variance100 = _totalVariance100.get(); final long count = _count.get(); - + return count>1?((double)variance100)/100.0/(count-1):0.0; } - /* ------------------------------------------------------------ */ public double getStdDev() { return Math.sqrt(getVariance()); } - } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiExceptionTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiExceptionTest.java index c6427bc4054..51d7b2f8d2d 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiExceptionTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiExceptionTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiMapTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiMapTest.java index fe0522021d5..dbf221980d0 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiMapTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiMapTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.util.ArrayList; import java.util.HashMap; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java index a7992b533ec..08011517c5c 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.FileOutputStream; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/URITest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/URITest.java index 79f350ff1c1..b0e8fc8fa79 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/URITest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/URITest.java @@ -51,8 +51,8 @@ public class URITest @Test public void testDecodePath() { - assertEquals("foo%23;,:=b a r",URIUtil.decodePath("foo%2523%3b%2c:%3db%20a%20r")); - assertEquals("foo%23;,:=b a r=",URIUtil.decodePath("xxxfoo%2523%3b%2c:%3db%20a%20r%3Dxxx".getBytes(),3,30)); + assertEquals("foo%23;,:=b a r",URIUtil.decodePath("foo%2523%3b%2c:%3db%20a%20r;rubbish")); + assertEquals("foo%23;,:=b a r=",URIUtil.decodePath("xxxfoo%2523%3b%2c:%3db%20a%20r%3Dxxx;rubbish".getBytes(),3,30)); assertEquals("fää%23;,:=b a r=",URIUtil.decodePath("fää%2523%3b%2c:%3db%20a%20r%3D")); assertEquals("f\u0629\u0629%23;,:=b a r",URIUtil.decodePath("f%d8%a9%d8%a9%2523%3b%2c:%3db%20a%20r")); } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/component/AggregateLifeCycleTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/component/AggregateLifeCycleTest.java index 495c6fd587f..ded0981170b 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/component/AggregateLifeCycleTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/component/AggregateLifeCycleTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.component; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/Blue.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/Blue.java index 37e91fa9191..0fe0cfe5309 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/Blue.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/Blue.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.log; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public class Blue { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/CapturingJULHandler.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/CapturingJULHandler.java index 1ec646e669c..d38b052e4c9 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/CapturingJULHandler.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/CapturingJULHandler.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.log; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.containsString; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/Green.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/Green.java index 5b4bae7d8de..e5241ebce18 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/Green.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/Green.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.log; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public class Green { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/JavaUtilLogTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/JavaUtilLogTest.java index 244b1e1306e..468de4fdb4f 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/JavaUtilLogTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/JavaUtilLogTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.log; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.is; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/NamedLogTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/NamedLogTest.java index 4377d5feaf5..a1ac4a1c5e2 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/NamedLogTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/NamedLogTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.log; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.junit.Test; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/Red.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/Red.java index a0c89b45f2a..338f63809cc 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/Red.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/Red.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.log; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public class Red { diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/Slf4jHelper.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/Slf4jHelper.java index 10b2d02c205..d4ce0a88f00 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/Slf4jHelper.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/Slf4jHelper.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.log; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.FileFilter; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrCapture.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrCapture.java index cd55fc125a9..f84b06e1a8a 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrCapture.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrCapture.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.log; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java index 4e2c7e1861d..9779486eeae 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.ssl; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static junit.framework.Assert.assertTrue; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/statistic/SampleStatisticTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/statistic/SampleStatisticTest.java index 14be1dd65fc..3c784ac7237 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/statistic/SampleStatisticTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/statistic/SampleStatisticTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.util.statistic; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/jetty-webapp/pom.xml b/jetty-webapp/pom.xml index b677ea55562..9a0b22a82f2 100644 --- a/jetty-webapp/pom.xml +++ b/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-webapp diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/AbstractConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/AbstractConfiguration.java index 8a5d35d37ac..90b97392060 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/AbstractConfiguration.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/AbstractConfiguration.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.webapp; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public class AbstractConfiguration implements Configuration { diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CloneConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CloneConfiguration.java index d5c06ae93e8..23288bfcdaa 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CloneConfiguration.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CloneConfiguration.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.webapp; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public class CloneConfiguration extends AbstractConfiguration diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaDataComplete.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaDataComplete.java index 7b14925f4fe..86867c98a5b 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaDataComplete.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaDataComplete.java @@ -1,3 +1,15 @@ package org.eclipse.jetty.webapp; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public enum MetaDataComplete {NotSet, True, False} \ No newline at end of file diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/Origin.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/Origin.java index 496de7f854f..55c2dada209 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/Origin.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/Origin.java @@ -1,3 +1,15 @@ package org.eclipse.jetty.webapp; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public enum Origin {NotSet, WebXml, WebDefaults, WebOverride, WebFragment, Annotation} \ No newline at end of file diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java index 51800f4d7c6..aac9f2e7ca3 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java @@ -248,6 +248,15 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor try { Loader.loadClass(this.getClass(), servlet_class); + + //Ensure there is a scratch dir + if (holder.getInitParameter("scratchdir") == null) + { + File tmp = context.getTempDirectory(); + File scratch = new File(tmp, "jsp"); + if (!scratch.exists()) scratch.mkdir(); + holder.setInitParameter("scratchdir", scratch.getAbsolutePath()); + } } catch (ClassNotFoundException e) { @@ -256,32 +265,7 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor } } - //could be more than 1 declaration of the jsp servlet, so configure them all - if (servlet_class != null && "org.apache.jasper.servlet.JspServlet".equals(servlet_class)) - { - if (holder.getInitParameter("scratchdir") == null) - { - File tmp = context.getTempDirectory(); - File scratch = new File(tmp, "jsp"); - if (!scratch.exists()) scratch.mkdir(); - holder.setInitParameter("scratchdir", scratch.getAbsolutePath()); - - if ("?".equals(holder.getInitParameter("classpath"))) - { - String classpath = context.getClassPath(); - LOG.debug("classpath=" + classpath); - if (classpath != null) - holder.setInitParameter("classpath", classpath); - } - } - - /* Set the webapp's classpath for Jasper */ - context.setAttribute("org.apache.catalina.jsp_classpath", context.getClassPath()); - - /* Set the system classpath for Jasper */ - holder.setInitParameter("com.sun.appserv.jsp.classpath", getSystemClassPath(context)); - } - + //Set the servlet-class if (servlet_class != null) { @@ -325,8 +309,6 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor { holder.setForcedPath(jsp_file); holder.setClassName(jspServletClass); //only use our default instance - //set the system classpath explicitly for the holder that will represent the JspServlet instance - holder.setInitParameter("com.sun.appserv.jsp.classpath", getSystemClassPath(context)); } // handle load-on-startup @@ -1434,46 +1416,5 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor return p; } - /** - * Generate the classpath (as a string) of all classloaders - * above the webapp's classloader. - * - * This is primarily used for jasper. - * @return the system class path - */ - protected String getSystemClassPath(WebAppContext context) - { - ClassLoader loader = context.getClassLoader(); - if (loader.getParent() != null) - loader = loader.getParent(); - - StringBuilder classpath=new StringBuilder(); - while (loader != null && (loader instanceof URLClassLoader)) - { - URL[] urls = ((URLClassLoader)loader).getURLs(); - if (urls != null) - { - for (int i=0;i0) - classpath.append(File.pathSeparatorChar); - classpath.append(file.getAbsolutePath()); - } - } - catch (IOException e) - { - LOG.debug(e); - } - } - } - loader = loader.getParent(); - } - return classpath.toString(); - } + } diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java index ba48c12f4df..53bc8b05571 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.webapp; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.IOException; diff --git a/jetty-webapp/src/test/java/org/acme/webapp/ClassInJarA.java b/jetty-webapp/src/test/java/org/acme/webapp/ClassInJarA.java index 1d8d3a79f20..6fe83162b3e 100644 --- a/jetty-webapp/src/test/java/org/acme/webapp/ClassInJarA.java +++ b/jetty-webapp/src/test/java/org/acme/webapp/ClassInJarA.java @@ -1,4 +1,16 @@ package org.acme.webapp; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== public class ClassInJarA { diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java index ba572a6de54..4e2de068c76 100644 --- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java +++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.webapp; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index b9126299afe..2ce8c718824 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 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 d90780f5c3d..5e4bc38582f 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 @@ -51,7 +51,10 @@ public abstract class WebSocketHandler extends HandlerWrapper implements WebSock public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (_webSocketFactory.acceptWebSocket(request,response) || response.isCommitted()) + { + baseRequest.setHandled(true); return; + } super.handle(target,baseRequest,request,response); } 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 fcde6e3135e..06e30783905 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 @@ -1,4 +1,16 @@ package org.eclipse.jetty.websocket; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.hamcrest.Matchers.*; diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index d173f2eb55f..015df99d5c5 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 jetty-xml diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index 292294d6d9a..cee3c27cb0a 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -71,11 +71,10 @@ public class XmlConfiguration private static final Class[] __primitiveHolders = { Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, Void.class }; - private static final Integer ZERO = new Integer(0); - + private static final Class[] __supportedCollections = { ArrayList.class,ArrayQueue.class,HashSet.class,Queue.class,List.class,Set.class,Collection.class,}; - + private static final Iterable __factoryLoader; private static final XmlParser __parser = initParser(); @@ -141,9 +140,11 @@ public class XmlConfiguration /* ------------------------------------------------------------ */ /** - * Constructor. Reads the XML configuration file. + * Reads and parses the XML configuration file. * - * @param configuration + * @param configuration the URL of the XML configuration + * @throws IOException if the configuration could not be read + * @throws SAXException if the configuration could not be parsed */ public XmlConfiguration(URL configuration) throws SAXException, IOException { @@ -157,12 +158,12 @@ public class XmlConfiguration /* ------------------------------------------------------------ */ /** - * Constructor. + * Reads and parses the XML configuration string. * - * @param configuration - * String of XML configuration commands excluding the normal XML preamble. The String should start with a " Apply the XML configuration script to the passed object.

    - * - * @param obj - * The object to be configured, which must be of a type or super type of the class attribute of the Configure element. - * @exception Exception + * @param obj The object to be configured, which must be of a type or super type + * of the class attribute of the <Configure> element. + * @throws Exception if the configuration fails + * @return the configured object */ public Object configure(Object obj) throws Exception { @@ -283,10 +284,13 @@ public class XmlConfiguration /* ------------------------------------------------------------ */ /** - * Configure an object. If the configuration has an ID, an object is looked up by ID and it's type check. Otherwise a new object is created. + * Applies the XML configuration script. + * If the root element of the configuration has an ID, an object is looked up by ID and its type checked + * against the root element's type. + * Otherwise a new object of the type specified by the root element is created. * * @return The newly created configured object. - * @exception Exception + * @throws Exception if the configuration fails */ public Object configure() throws Exception { @@ -353,12 +357,13 @@ public class XmlConfiguration /* ------------------------------------------------------------ */ /** - * Recursive configuration step. This method applies the remaining Set, Put and Call elements to the current object. + * Recursive configuration routine. + * This method applies the nested Set, Put, Call, etc. elements to the given object. * - * @param obj - * @param cfg - * @param i - * @exception Exception + * @param obj the object to configure + * @param cfg the XML nodes of the configuration + * @param i the index of the XML nodes + * @throws Exception if the configuration fails */ public void configure(Object obj, XmlParser.Node cfg, int i) throws Exception { @@ -576,7 +581,9 @@ public class XmlConfiguration } /** - * @return a collection if compareValueToClass is a Set or List. null if that's not the case or value can't be converted to a Collection + * @param array the array to convert + * @param collectionType the desired collection type + * @return a collection of the desired type if the array can be converted */ private static Collection convertArrayToCollection(Object array, Class collectionType) { @@ -862,7 +869,7 @@ public class XmlConfiguration XmlParser.Node item = (Node)nodeObject; String nid = item.getAttribute("id"); Object v = value(obj,item); - al = LazyList.add(al,(v == null && aClass.isPrimitive())?ZERO:v); + al = LazyList.add(al,(v == null && aClass.isPrimitive())?0:v); if (nid != null) _idMap.put(nid,v); } @@ -896,7 +903,7 @@ public class XmlConfiguration XmlParser.Node key = null; XmlParser.Node value = null; - for (Object object : node) + for (Object object : entry) { if (object instanceof String) continue; @@ -932,26 +939,26 @@ public class XmlConfiguration * Get a Property. * * @param node - * @return + * @return * @exception Exception */ private Object propertyObj(XmlParser.Node node) throws Exception { String id = node.getAttribute("id"); String name = node.getAttribute("name"); - String defval = node.getAttribute("default"); - Object prop = null; + String defaultValue = node.getAttribute("default"); + Object prop; if (_propertyMap != null && _propertyMap.containsKey(name)) prop = _propertyMap.get(name); else - prop = defval; + prop = defaultValue; if (id != null) _idMap.put(id,prop); if (prop != null) configure(prop,node,0); return prop; } - + /* ------------------------------------------------------------ */ /* @@ -960,7 +967,7 @@ public class XmlConfiguration */ private Object value(Object obj, XmlParser.Node node) throws Exception { - Object value = null; + Object value; // Get the type String type = node.getAttribute("type"); @@ -989,7 +996,7 @@ public class XmlConfiguration if (type == null || !"String".equals(type)) { // Skip leading white - Object item = null; + Object item; while (first <= last) { item = node.get(first); @@ -1084,7 +1091,7 @@ public class XmlConfiguration throw new InvocationTargetException(e); } } - + for (Class collectionClass : __supportedCollections) { if (isTypeMatchingClass(type,collectionClass)) @@ -1093,12 +1100,11 @@ public class XmlConfiguration throw new IllegalStateException("Unknown type " + type); } - + /* ------------------------------------------------------------ */ private static boolean isTypeMatchingClass(String type, Class classToMatch) { - boolean match = classToMatch.getSimpleName().equalsIgnoreCase(type) || classToMatch.getName().equals(type); - return match; + return classToMatch.getSimpleName().equalsIgnoreCase(type) || classToMatch.getName().equals(type); } /* ------------------------------------------------------------ */ @@ -1134,7 +1140,7 @@ public class XmlConfiguration String defaultValue = node.getAttribute("default"); return System.getProperty(name,defaultValue); } - + if ("Env".equals(tag)) { String name = node.getAttribute("name"); @@ -1167,6 +1173,7 @@ public class XmlConfiguration * * @param args * array of property and xml configuration filenames or {@link Resource}s. + * @throws Exception if the XML configurations cannot be run */ public static void main(final String[] args) throws Exception { diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/TestConfiguration.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/TestConfiguration.java index e87e71060f2..8c35a8e8e26 100644 --- a/jetty-xml/src/test/java/org/eclipse/jetty/xml/TestConfiguration.java +++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/TestConfiguration.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Set; import org.junit.Ignore; @@ -42,6 +43,7 @@ public class TestConfiguration extends HashMap @SuppressWarnings("rawtypes") private Set set; private ConstructorArgTestClass constructorArgTestClass; + public Map map; public void setTest(Object value) { @@ -52,7 +54,7 @@ public class TestConfiguration extends HashMap { testInt=value; } - + public void setPropertyTest(int value) { propValue=value; @@ -141,4 +143,9 @@ public class TestConfiguration extends HashMap { this.constructorArgTestClass = constructorArgTestClass; } + + public void setMap(Map map) + { + this.map = map; + } } diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java index 79b4038400a..49cb229254b 100644 --- a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java +++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java @@ -13,20 +13,24 @@ package org.eclipse.jetty.xml; -import static junit.framework.Assert.assertEquals; -import static org.junit.Assert.*; -import static org.hamcrest.CoreMatchers.*; - import java.net.URL; import java.util.HashMap; import java.util.Map; +import org.junit.Assert; import org.junit.Test; +import static junit.framework.Assert.assertEquals; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + public class XmlConfigurationTest { protected String _configure="org/eclipse/jetty/xml/configure.xml"; - + private static final String STRING_ARRAY_XML = "String1String2"; private static final String INT_ARRAY_XML = "12"; @@ -37,7 +41,7 @@ public class XmlConfigurationTest XmlConfiguration configuration = new XmlConfiguration(url); configuration.configure(); } - + @Test public void testPassedObject() throws Exception { @@ -53,7 +57,7 @@ public class XmlConfigurationTest assertEquals("Set String","SetValue",tc.testObject); assertEquals("Set Type",2,tc.testInt); - + assertEquals(18080, tc.propValue); assertEquals("Put","PutValue",tc.get("Test")); @@ -76,7 +80,7 @@ public class XmlConfigurationTest assertEquals( "SystemProperty", System.getProperty("user.dir")+"/stuff",tc.get("SystemProperty")); assertEquals( "Env", System.getenv("HOME"),tc.get("Env")); - + assertEquals( "Property", "xxx", tc.get("Property")); @@ -104,12 +108,12 @@ public class XmlConfigurationTest assertEquals("nested config","Call1",tc2.testObject); assertEquals("nested config",4,tc2.testInt); assertEquals( "nested call", "http://www.eclipse.com/",tc2.url.toString()); - + assertEquals("static to field",tc.testField1,77); assertEquals("field to field",tc.testField2,2); assertEquals("literal to static",TestConfiguration.VALUE,42); } - + @Test public void testNewObject() throws Exception { @@ -124,7 +128,7 @@ public class XmlConfigurationTest assertEquals("Set String","SetValue",tc.testObject); assertEquals("Set Type",2,tc.testInt); - + assertEquals(18080, tc.propValue); assertEquals("Put","PutValue",tc.get("Test")); @@ -173,13 +177,13 @@ public class XmlConfigurationTest assertEquals("nested config","Call1",tc2.testObject); assertEquals("nested config",4,tc2.testInt); assertEquals( "nested call", "http://www.eclipse.com/",tc2.url.toString()); - + assertEquals("static to field",71,tc.testField1); assertEquals("field to field",2,tc.testField2); assertEquals("literal to static",42,TestConfiguration.VALUE); } - - + + @Test public void testStringConfiguration() throws Exception { @@ -314,4 +318,28 @@ public class XmlConfigurationTest xmlConfiguration.configure(tc); assertThat("tc.getSet() has two entries as specified in the xml",tc.getSet().size(),is(2)); } + + @Test + public void testMap() throws Exception + { + XmlConfiguration xmlConfiguration = new XmlConfiguration("" + + "" + + " " + + " " + + " " + + " key1" + + " value1" + + " " + + " " + + " key2" + + " value2" + + " " + + " " + + " " + + ""); + TestConfiguration tc = new TestConfiguration(); + Assert.assertNull("tc.map is null as it's not configured yet", tc.map); + xmlConfiguration.configure(tc); + Assert.assertEquals("tc.map is has two entries as specified in the XML", 2, tc.map.size()); + } } diff --git a/pom.xml b/pom.xml index 7332c8ac979..a926dd6ab0b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,11 +6,10 @@ 19 jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT Jetty :: Project ${jetty.url} pom - UTF-8 http://www.eclipse.org/jetty diff --git a/test-continuation-jetty6/src/test/java/org/eclipse/jetty/continuation/TestProxyServer.java b/test-continuation-jetty6/src/test/java/org/eclipse/jetty/continuation/TestProxyServer.java index 2f4410ca8b5..8f2087aa5b2 100644 --- a/test-continuation-jetty6/src/test/java/org/eclipse/jetty/continuation/TestProxyServer.java +++ b/test-continuation-jetty6/src/test/java/org/eclipse/jetty/continuation/TestProxyServer.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.continuation; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.eclipse.jetty.servlets.ProxyServlet; import org.junit.Ignore; diff --git a/test-continuation/pom.xml b/test-continuation/pom.xml index 0d274cca9d4..c6ad38d3259 100644 --- a/test-continuation/pom.xml +++ b/test-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 test-continuation diff --git a/test-jetty-nested/pom.xml b/test-jetty-nested/pom.xml index d9310261821..7eb9fa42769 100644 --- a/test-jetty-nested/pom.xml +++ b/test-jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT test-jetty-nested Jetty :: Nested Test diff --git a/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java b/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java index b8b5fc9c972..9c0068104ba 100644 --- a/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java +++ b/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.nested; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.File; import java.io.IOException; diff --git a/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/TestServlet.java b/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/TestServlet.java index 42222e66b4c..dbaaa608a9d 100644 --- a/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/TestServlet.java +++ b/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/TestServlet.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.nested; +//======================================================================== +//Copyright (c) 2006-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.BufferedInputStream; import java.io.BufferedReader; diff --git a/test-jetty-servlet/pom.xml b/test-jetty-servlet/pom.xml index 69f8ee0b335..01372f36509 100644 --- a/test-jetty-servlet/pom.xml +++ b/test-jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 test-jetty-servlet diff --git a/test-jetty-servlet/src/main/java/Jetty400Repro.java b/test-jetty-servlet/src/main/java/Jetty400Repro.java index 1bdd320c6da..bbb3d72550f 100644 --- a/test-jetty-servlet/src/main/java/Jetty400Repro.java +++ b/test-jetty-servlet/src/main/java/Jetty400Repro.java @@ -1,3 +1,16 @@ +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + import java.io.IOException; import java.net.MalformedURLException; import java.net.Socket; diff --git a/test-jetty-webapp/pom.xml b/test-jetty-webapp/pom.xml index e244453ee03..9e87418beec 100644 --- a/test-jetty-webapp/pom.xml +++ b/test-jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 test-jetty-webapp diff --git a/test-jetty-webapp/src/main/java/com/acme/Counter.java b/test-jetty-webapp/src/main/java/com/acme/Counter.java index d5546e5be98..d830d515a8f 100644 --- a/test-jetty-webapp/src/main/java/com/acme/Counter.java +++ b/test-jetty-webapp/src/main/java/com/acme/Counter.java @@ -1,15 +1,14 @@ //======================================================================== -//Copyright 2004-2008 Mort Bay Consulting Pty. Ltd. +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. //------------------------------------------------------------------------ -//Licensed under the Apache License, Version 2.0 (the "License"); -//you may not use this file except in compliance with the License. -//You may obtain a copy of the License at -//http://www.apache.org/licenses/LICENSE-2.0 -//Unless required by applicable law or agreed to in writing, software -//distributed under the License is distributed on an "AS IS" BASIS, -//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//See the License for the specific language governing permissions and -//limitations under the License. +//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 com.acme; diff --git a/test-jetty-webapp/src/main/java/com/acme/Date2Tag.java b/test-jetty-webapp/src/main/java/com/acme/Date2Tag.java index de9c9f49b61..9b7a1b32372 100644 --- a/test-jetty-webapp/src/main/java/com/acme/Date2Tag.java +++ b/test-jetty-webapp/src/main/java/com/acme/Date2Tag.java @@ -1,15 +1,14 @@ //======================================================================== -//Copyright 2004-2008 Mort Bay Consulting Pty. Ltd. +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. //------------------------------------------------------------------------ -//Licensed under the Apache License, Version 2.0 (the "License"); -//you may not use this file except in compliance with the License. -//You may obtain a copy of the License at -//http://www.apache.org/licenses/LICENSE-2.0 -//Unless required by applicable law or agreed to in writing, software -//distributed under the License is distributed on an "AS IS" BASIS, -//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//See the License for the specific language governing permissions and -//limitations under the License. +//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 com.acme; diff --git a/test-jetty-webapp/src/main/java/com/acme/DateTag.java b/test-jetty-webapp/src/main/java/com/acme/DateTag.java index a54c72dda7e..0ba8ad6e4a5 100644 --- a/test-jetty-webapp/src/main/java/com/acme/DateTag.java +++ b/test-jetty-webapp/src/main/java/com/acme/DateTag.java @@ -1,15 +1,14 @@ //======================================================================== -//Copyright 2004-2008 Mort Bay Consulting Pty. Ltd. +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. //------------------------------------------------------------------------ -//Licensed under the Apache License, Version 2.0 (the "License"); -//you may not use this file except in compliance with the License. -//You may obtain a copy of the License at -//http://www.apache.org/licenses/LICENSE-2.0 -//Unless required by applicable law or agreed to in writing, software -//distributed under the License is distributed on an "AS IS" BASIS, -//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//See the License for the specific language governing permissions and -//limitations under the License. +//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 com.acme; diff --git a/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java b/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java index 378a6c56aa0..6aec62c6867 100644 --- a/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java +++ b/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java @@ -1,4 +1,16 @@ package com.acme; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.IOException; import java.util.Set; diff --git a/test-jetty-webapp/src/test/java/org/eclipse/jetty/DispatchServletTest.java b/test-jetty-webapp/src/test/java/org/eclipse/jetty/DispatchServletTest.java index 113b07e86e9..9d2f469cad0 100644 --- a/test-jetty-webapp/src/test/java/org/eclipse/jetty/DispatchServletTest.java +++ b/test-jetty-webapp/src/test/java/org/eclipse/jetty/DispatchServletTest.java @@ -1,16 +1,16 @@ -// ======================================================================== -// Copyright 2009 Webtide LLC -// ------------------------------------------------------------------------ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ======================================================================== +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== + package org.eclipse.jetty; import junit.framework.TestCase; diff --git a/tests/pom.xml b/tests/pom.xml index 8a0876d42e5..c885f2e0d4e 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty jetty-project - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT org.eclipse.jetty.tests tests-parent diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml index de349e50135..9c7fdeb2e8f 100644 --- a/tests/test-integration/pom.xml +++ b/tests/test-integration/pom.xml @@ -20,7 +20,7 @@ org.eclipse.jetty.tests tests-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT 4.0.0 test-integration diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java index bb491353fc1..870aa3e9f1d 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.test; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import java.io.BufferedInputStream; import java.io.FileInputStream; diff --git a/tests/test-loginservice/pom.xml b/tests/test-loginservice/pom.xml index 7aaffe15f8d..f673b515405 100644 --- a/tests/test-loginservice/pom.xml +++ b/tests/test-loginservice/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT test-loginservice Jetty Tests :: Login Service diff --git a/tests/test-sessions/pom.xml b/tests/test-sessions/pom.xml index 6375c7c2b1e..f20e7dddf93 100644 --- a/tests/test-sessions/pom.xml +++ b/tests/test-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT test-sessions-parent Jetty Tests :: Sessions :: Parent diff --git a/tests/test-sessions/test-hash-sessions/pom.xml b/tests/test-sessions/test-hash-sessions/pom.xml index 36ba5ff1954..5d9603fdba0 100644 --- a/tests/test-sessions/test-hash-sessions/pom.xml +++ b/tests/test-sessions/test-hash-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT test-hash-sessions Jetty Tests :: Sessions :: Hash diff --git a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/HashTestServer.java b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/HashTestServer.java index 720d90f3562..05e11f3d54b 100644 --- a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/HashTestServer.java +++ b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/HashTestServer.java @@ -1,16 +1,15 @@ -// ======================================================================== -// Copyright 2004-2005 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ======================================================================== +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== package org.eclipse.jetty.server.session; diff --git a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java index 6663343ef16..17d68132b2b 100644 --- a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java +++ b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.session; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.junit.Test; diff --git a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java index 67b56ee7cec..df347d85358 100644 --- a/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java +++ b/tests/test-sessions/test-hash-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.session; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import org.junit.Test; diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index caa2092dba1..a217c029cd9 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT test-jdbc-sessions Jetty Tests :: Sessions :: JDBC diff --git a/tests/test-sessions/test-mongodb-sessions/pom.xml b/tests/test-sessions/test-mongodb-sessions/pom.xml index fecbbb21c60..e1f93c64de9 100644 --- a/tests/test-sessions/test-mongodb-sessions/pom.xml +++ b/tests/test-sessions/test-mongodb-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT test-mongodb-sessions Jetty Tests :: Sessions :: Mongo diff --git a/tests/test-sessions/test-sessions-common/pom.xml b/tests/test-sessions/test-sessions-common/pom.xml index 3c9282b55bd..5faf98cfb0b 100644 --- a/tests/test-sessions/test-sessions-common/pom.xml +++ b/tests/test-sessions/test-sessions-common/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT test-sessions-common Jetty Tests :: Sessions :: Common diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java index 7742d16d411..f19646b5e1c 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java @@ -1,4 +1,16 @@ package org.eclipse.jetty.server.session; +//======================================================================== +//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== import static org.junit.Assert.*; diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index e276950c007..6cb0f981203 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT test-webapps-parent Jetty Tests :: WebApps :: Parent diff --git a/tests/test-webapps/test-webapp-rfc2616/pom.xml b/tests/test-webapps/test-webapp-rfc2616/pom.xml index 15a04594ff4..08cbe3124c8 100644 --- a/tests/test-webapps/test-webapp-rfc2616/pom.xml +++ b/tests/test-webapps/test-webapp-rfc2616/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-webapps-parent - 7.6.5-SNAPSHOT + 7.6.6-SNAPSHOT test-webapp-rfc2616 Jetty Tests :: WebApp :: RFC2616