[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[jetty-commit] r1472 - in jetty/branches/jetty-8: . example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded jetty-aggregate/jetty-plus jetty-ajp jetty-ajp/src/main/java/org/eclipse/jetty/ajp jetty-annotations jetty-annotations/src/main/java/org/eclipse/jetty/annotations jetty-client jetty-client/src/main/java/org/eclipse/jetty/client jetty-client/src/test/java/org/eclipse/jetty/client jetty-continuation jetty-continuation/src/main/java/org/eclipse/jetty/continuation jetty-deploy jetty-deploy/src/main/java/org/eclipse/jetty/deploy jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers jetty-distribution/src/main/resources jetty-distribution/src/main/resources/javadoc jetty-http jetty-http/src/main/java/org/eclipse/jetty/http jetty-http/src/test/java/org/eclipse/jetty/http jetty-io jetty-io/src/main/java/org/eclipse/jetty/io jetty-io/src/main/java/org/eclipse/jetty/io/nio jetty-jaspi jetty-jmx jetty-jmx/src/main/resources/org/eclipse/jetty/server/session/jmx jetty-jndi jetty-osgi jetty-osgi/jetty-osgi-boot jetty-osgi/jetty-osgi-boot/META-INF jetty-osgi/jetty-osgi-boot/jettyhome/etc jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal jetty-osgi/jetty-osgi-boot-jsp jetty-osgi/jetty-osgi-boot-jsp/META-INF jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp jetty-osgi/jetty-osgi-boot-logback jetty-osgi/jetty-osgi-boot-warurl jetty-osgi/jetty-osgi-httpservice jetty-plus jetty-policy jetty-rewrite jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler jetty-security jetty-security/src/main/java/org/eclipse/jetty/security/authentication jetty-security/src/test/java/org/eclipse/jetty/security jetty-server jetty-server/src/main/config/etc jetty-server/src/main/java/org/eclipse/jetty/server jetty-server/src/main/java/org/eclipse/jetty/server/handler jetty-server/src/main/java/org/eclipse/jetty/server/session jetty-server/src/main/java/org/eclipse/jetty/server/ssl jetty-server/src/test/java/org/eclipse/jetty/server jetty-server/src/test/java/org/eclipse/jetty/server/handler jetty-server/src/test/java/org/eclipse/jetty/server/session jetty-server/src/test/java/org/eclipse/jetty/server/ssl jetty-servlet jetty-servlet/src/main/java/org/eclipse/jetty/servlet jetty-servlet/src/test/java/org/eclipse/jetty/servlet jetty-servlets jetty-servlets/src/main/java/org/eclipse/jetty/servlets jetty-servlets/src/test/java/org/eclipse/jetty/servlets jetty-start/src/main/java/org/eclipse/jetty/start jetty-util jetty-util/src/main/java/org/eclipse/jetty/util jetty-util/src/main/java/org/eclipse/jetty/util/component jetty-util/src/main/java/org/eclipse/jetty/util/log jetty-util/src/main/java/org/eclipse/jetty/util/thread jetty-util/src/test/java/org/eclipse/jetty/util/component jetty-util/src/test/java/org/eclipse/jetty/util/log jetty-util/src/test/java/org/eclipse/jetty/util/thread jetty-webapp jetty-webapp/src/main/java/org/eclipse/jetty/webapp jetty-websocket jetty-websocket/src/main/java/org/eclipse/jetty/websocket jetty-websocket/src/test/java/org/eclipse/jetty/websocket jetty-xml test-jetty-servlet/src/main/java test-jetty-webapp/src/main/java/com/acme test-jetty-webapp/src/main/webapp/ws tests/test-integration tests/test-integration/src/test/java/org/eclipse/jetty/test tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs tests/test-integration/src/test/resources
|
- From: genie@xxxxxxxxxxx
- Date: Tue, 6 Apr 2010 14:18:05 -0400 (EDT)
- Delivered-to: jetty-commit@eclipse.org
Author: jbartel
Date: 2010-04-06 14:17:57 -0400 (Tue, 06 Apr 2010)
New Revision: 1472
Added:
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/HttpHeadersTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SecuredErrorStatusTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslContentExchangeTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredContentExchangeTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredErrorStatusTest.java
jetty/branches/jetty-8/jetty-distribution/src/main/resources/javadoc/contents.html
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/PluggableWebAppRegistrationCustomizerImpl.java
jetty/branches/jetty-8/jetty-server/src/main/config/etc/jetty-ipaccess.xml
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslCertificates.java
jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionHandlerTest.java
jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java
jetty/branches/jetty-8/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageTest.java
jetty/branches/jetty-8/test-jetty-servlet/src/main/java/Jetty400Repro.java
jetty/branches/jetty-8/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java
jetty/branches/jetty-8/tests/test-integration/src/test/resources/message.txt
Removed:
jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AbstractSessionTest.java
jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/SessionTestClient.java
jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/SessionTestServer.java
Modified:
jetty/branches/jetty-8/VERSION.txt
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/HelloHandler.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/HelloServlet.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyServletContexts.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/MinimalServlets.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneContext.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneHandler.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneServletContext.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ProxyServer.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java
jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SimplestServer.java
jetty/branches/jetty-8/jetty-aggregate/jetty-plus/pom.xml
jetty/branches/jetty-8/jetty-ajp/pom.xml
jetty/branches/jetty-8/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java
jetty/branches/jetty-8/jetty-annotations/pom.xml
jetty/branches/jetty-8/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AbstractConfiguration.java
jetty/branches/jetty-8/jetty-client/pom.xml
jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java
jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java
jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java
jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ContentExchangeTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ErrorStatusTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SecuredContentExchangeTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java
jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecurityListenerTest.java
jetty/branches/jetty-8/jetty-continuation/pom.xml
jetty/branches/jetty-8/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Continuation.java
jetty/branches/jetty-8/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java
jetty/branches/jetty-8/jetty-deploy/pom.xml
jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java
jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/WebAppDeployer.java
jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/MonitoredDirAppProvider.java
jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
jetty/branches/jetty-8/jetty-distribution/src/main/resources/start.ini
jetty/branches/jetty-8/jetty-http/pom.xml
jetty/branches/jetty-8/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java
jetty/branches/jetty-8/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java
jetty/branches/jetty-8/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java
jetty/branches/jetty-8/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorTest.java
jetty/branches/jetty-8/jetty-io/pom.xml
jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java
jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java
jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java
jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java
jetty/branches/jetty-8/jetty-jaspi/pom.xml
jetty/branches/jetty-8/jetty-jmx/pom.xml
jetty/branches/jetty-8/jetty-jmx/src/main/resources/org/eclipse/jetty/server/session/jmx/AbstractSessionManager-mbean.properties
jetty/branches/jetty-8/jetty-jndi/pom.xml
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/META-INF/MANIFEST.MF
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp/FragmentActivator.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-logback/pom.xml
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-warurl/pom.xml
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/META-INF/MANIFEST.MF
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/pom.xml
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiAppProvider.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/OSGiWebappClassLoader.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebappRegistrationHelper.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/BundleClassLoaderHelper.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/BundleFileLocatorHelper.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/WebappRegistrationCustomizer.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/PackageAdminServiceTracker.java
jetty/branches/jetty-8/jetty-osgi/jetty-osgi-httpservice/pom.xml
jetty/branches/jetty-8/jetty-osgi/pom.xml
jetty/branches/jetty-8/jetty-plus/pom.xml
jetty/branches/jetty-8/jetty-policy/pom.xml
jetty/branches/jetty-8/jetty-rewrite/pom.xml
jetty/branches/jetty-8/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RedirectPatternRule.java
jetty/branches/jetty-8/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RedirectRegexRule.java
jetty/branches/jetty-8/jetty-security/pom.xml
jetty/branches/jetty-8/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java
jetty/branches/jetty-8/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java
jetty/branches/jetty-8/jetty-security/src/test/java/org/eclipse/jetty/security/ConstraintTest.java
jetty/branches/jetty-8/jetty-server/pom.xml
jetty/branches/jetty-8/jetty-server/src/main/config/etc/jetty.xml
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/MovedContextHandler.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionManager.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java
jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java
jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncContextTest.java
jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/handler/StatisticsHandlerTest.java
jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java
jetty/branches/jetty-8/jetty-servlet/pom.xml
jetty/branches/jetty-8/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
jetty/branches/jetty-8/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
jetty/branches/jetty-8/jetty-servlets/pom.xml
jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CGI.java
jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java
jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java
jetty/branches/jetty-8/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java
jetty/branches/jetty-8/jetty-start/src/main/java/org/eclipse/jetty/start/README.txt
jetty/branches/jetty-8/jetty-util/pom.xml
jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java
jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java
jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java
jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java
jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Timeout.java
jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java
jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java
jetty/branches/jetty-8/jetty-webapp/pom.xml
jetty/branches/jetty-8/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
jetty/branches/jetty-8/jetty-websocket/pom.xml
jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocket.java
jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketBuffers.java
jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java
jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java
jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGenerator.java
jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketHandler.java
jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParser.java
jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java
jetty/branches/jetty-8/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorTest.java
jetty/branches/jetty-8/jetty-xml/pom.xml
jetty/branches/jetty-8/pom.xml
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/ChatServlet.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/CookieDump.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/Counter.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/DispatchServlet.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/Dump.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/HelloWorld.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/RewriteServlet.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/SecureModeServlet.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/SessionDump.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/TestFilter.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/TestListener.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java
jetty/branches/jetty-8/test-jetty-webapp/src/main/webapp/ws/index.html
jetty/branches/jetty-8/tests/test-integration/pom.xml
jetty/branches/jetty-8/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java
Log:
Merge 7.0.2.v20100331, including all changes up to Apr 6 2010 (see tag jetty-7-to-jetty-8-base-20100406-1/)
Modified: jetty/branches/jetty-8/VERSION.txt
===================================================================
--- jetty/branches/jetty-8/VERSION.txt 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/VERSION.txt 2010-04-06 18:17:57 UTC (rev 1472)
@@ -3,8 +3,136 @@
+ Ensure <absolute-ordering> in web.xml overrides relative <ordering> in fragments
+ Ensure empty <absolute-ordering> implies exclusion of all fragments
+ Ensure servlet-api jar class inheritance hierarchy is scanned
+ + 307847 Fixed combining mime type parameters
+ + 307898 Handle large/async websocket messages
+ + JETTY-1202 Use platform default algorithm for SecureRandom
+ + Merged 7.0.2.v20100331
+jetty-7.0.2.v20100331
+ + 297552 Don't call Continuation timeouts from acceptor tick
+ + 298236 Additional unit tests for jetty-client
+ + 306783 NPE in StdErrLog when Throwable is null
+ + 306840 Suppress content-length in requests with no content
+ + 306880 Support for UPGRADE in HttpClient
+ + 306884 Suspend with timeout <=0 never expires
+ + 306782 httpbis interpretation of 100 continues. Body never skipped
+ + 307589 updated servlet 3.0 continuations for final API
+ + Take excess logging statements out of startup
+ + Ensure webapps with no WEB-INF don't scan WEB-INF/lib
+ + Allow Configuration array to be set on Server instance for all web apps
+
+jetty-6.1.23 2 April 2010
+ + JSON parses NaN as null
+ + Updated JSP to 2.1.v20091210
+ + COMETD-28 Improved concurrency usage in Bayeux and channel handling
+ + COMETD-46 reset ContentExchange content on resend
+ + COMETD-58 Extension.rcv() return null causes NPE in AbstractBayeux.PublishHandler.publish
+ + COMETD-59 AcknowledgeExtension does not handle null channel in Message
+ + COMETD-62 Delay add listeners until after client construction
+ + 296569 removeLifeCycleListener() has no effect
+ + 292800 ContextDeployer - recursive setting is undone by FilenameFilter
+ + 300178 HttpClients opens too many connections that are immediately closed
+ + 304658 Inconsistent Expires date format in Set-Cookie headers with maxAge=0
+ + 304698 org.eclipse.jetty.http.HttpFields$DateGenerator.formatCookieDate() uses wrong (?) date format
+ + 306331 Session manager is kept after call to doScope
+ + 306840 suppress content-length in requests without content
+ + Remove references to old content in HttpClient client tests for www.sun.com
+ + JETTY-875 Allow setting of advice field in response to Handshake
+ + JETTY-983 Range handling cleanup
+ + JETTY-1133 Handle multiple URL ; parameters
+ + JETTY-1134 BayeuxClient: Connect msg should be sent as array
+ + JETTY-1149 transient should be volatile in AbstractLifeCycle
+ + JETTY-1153 System property for UrlEncoded charset
+ + JETTY-1155 HttpConnection.close notifies HttpExchange
+ + JETTY-1156 SSL blocking close with JVM Bug busy key fix
+ + JETTY-1157 Don't hold array passed in write(byte[])
+ + JETTY-1158 NPE in StdErrLog when Throwable is null
+ + JETTY-1161 An Extension that measures round-trip delay for cometd messages.
+ + JETTY-1162 Add support for async/sync message delivery to BayeuxClient
+ + JETTY-1163 AJP13 forces 8859-1 encoding
+ + JETTY-1168 Don't hold sessionIdManager lock when invalidating sessions
+ + JETTY-1170 NPE on client when server-side extension returns null
+ + JETTY-1174 Close rather than finish Gzipstreams to avoid JVM leak
+ + JETTY-1174 Memory leak in ChannelImpl/ContinuationClient
+ + JETTY-1175 NPE in TimesyncExtension
+ + JETTY-1176 NPE in StatisticsExtension if client is null
+ + JETTY-1177 Allow error handler to set cacheControl
+ + JETTY-1178 Make continuation servlet to log the incoming JSON in case of parsing errors
+ + JETTY-1180 Extension methods are wrongly called
+ + JETTY-1182 COMETD-76 do not lock client while sending messages.
+ + JETTY-1182 Reduce synchronization in ContinuationCometdServlet
+ + JETTY-1183 AcknowledgedMessagesClientExtension does not handle correctly message resend when client long polls again
+ + JETTY-1186 Better document JMX setup in jetty-jmx.xml
+ + JETTY-1188 Null old jobs in QueuedThreadPool
+ + JETTY-1191 Limit size of ChannelId cache
+ + JETTY-1192 Fixed Digested POST and HttpExchange onRetry
+ + JETTY-1193 Exception details are lost in AbstractCometdServlet.getMessages
+ + JETTY-1195 Coalesce buffers in ChannelEndPoint.flush()
+ + JETTY-1196 Enable TCP_NODELAY by default in client connectors
+ + JETTY-1197 SetUID module test fails when using Java 1.6 to build
+ + JETTY-1199 FindBugs cleanups
+ + JETTY-1205 Memory leak in browser-to-client mapping
+ + JETTY-1207 NPE protection in FormAuthenticator
+ + JETTY-1202 Use platfrom default algorithm for SecureRandom
+
+jetty-7.0.2.RC0
+ + JSON parses NaN as null
+ + 290765 Reset input for HttpExchange retry.
+ + 292799 WebAppDeployer - start a started context?
+ + 292800 ContextDeployer - recursive setting is undone by FilenameFilter
+ + 294799 when configuring a webapp, don't look for WEB-INF/jetty6-web.xml
+ + 296569 removeLifeCycleListener() has no effect
+ + 296765 JMX Connector Server and ShutdownThread
+ + 297421 Hide server/system classes from WebAppClassLoader.getResources
+ + 297783 Handle HEAD reponses in HttpClient
+ + 298144 Unit test for jetty-client connecting to a server that uses Basic Auth
+ + 298145 Reorganized test harness to separate the HTTP PUT and HTTP GET test URLs
+ + 298234 Unit test for jetty-client handling different HTTP error codes
+ + 298667 DeploymentManager uses ContextProvider and WebAppProvider
+ + 299455 Enum support in JSONPojoConvertor
+ + 300178 HttpClients opens too many connections that are immediately closed
+ + 300733 Jars from lib/ext are not visible for my web application
+ + 300933 AbstractConnector uses concurrent objects for stats
+ + 301089 Improve statistics available in StatisticsHandler and AbstractConnector
+ + 302018 Improve statistics available in AbstractSessionHandler
+ + 302198 Rename HttpClient authorization classes to Authentication
+ + 302244 invalid configuration boolean conversion in FormAuthenticator
+ + 302246 redirect loop using form authenticator
+ + 302556 CrossOriginFilter does not work correctly when Access-Control-Request-Headers header is not present
+ + 302669 WebInfConfiguration.unpack() unpacks WEB-INF/* from a ResourceCollection, breaking JSP reloading with ResourceCollections
+ + 303526 Added include cyphers
+ + 304307 Handle ;jsessionid in FROM Auth
+ + 304532 Skip some tests on IBM JVMs until resolved
+ + 304658 Inconsistent Expires date format in Set-Cookie headers with maxAge=0
+ + 304698 org.eclipse.jetty.http.HttpFields$DateGenerator.formatCookieDate() uses wrong (?) date format
+ + 304781 Reset HttpExchange timeout on slow request content.
+ + 304801 SSL connections FULL fix
+ + 306330 Flush filter chain cache after Invoker servlet
+ + 306331 Session manager is kept after call to doScope
+ + JETTY-776 Make new session-tests module to concentrate all reusable session clustering test code
+ + JETTY-910 Allow request listeners to access session
+ + JETTY-983 Range handling cleanup
+ + JETTY-1151 JETTY-1098 allow UTF-8 with 0 carry bits
+ + JETTY-1153 System property for UrlEncoded charset
+ + JETTY-1155 HttpConnection.close notifies HttpExchange
+ + JETTY-1156 SSL blocking close with JVM Bug busy key fix
+ + JETTY-1157 Don't hold array passed in write(byte[])
+ + JETTY-1163 AJP13 forces 8859-1 encoding
+ + JETTY-1177 Allow error handler to set cacheControl
+ + JETTY-1179 Persistant session tables created on MySQL use wrong datatype
+ + JETTY-1184 shrink thread pool even with frequent small jobs
+ + JETTY-1133 Handle multiple URL ; parameters
+ + JETTY-1174 Close rather than finish Gzipstreams to avoid JVM leak
+ + JETTY-1192 Fixed Digested POST
+ + JETTY-1199 FindBugs cleanups
+ + COMETD-46 reset ContentExchange response content on resend
+ + Added IPAccessHandler
+ + Updated Servlet3Continuation to final 3.0.20100224
+ + 305997 Coalesce buffers in ChannelEndPoint.flush()
+ + 306028 Enable TCP_NODELAY by default in client connectors
+
+
jetty-8.0.0.M0 28 February 2010
+ Updated servlet 3.0 spec 20100224
+ Merged 7.0.1.v20091116
@@ -4330,7 +4458,3 @@
-
-
-
-
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/HelloHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/HelloServlet.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyServletContexts.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/MinimalServlets.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneContext.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneServletContext.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ProxyServer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SimplestServer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: jetty/branches/jetty-8/jetty-aggregate/jetty-plus/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-aggregate/jetty-plus/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-aggregate/jetty-plus/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -86,12 +86,13 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>${servlet.spec.groupId}</groupId>
- <artifactId>${servlet.spec.artifactId}</artifactId>
- <scope>compile</scope>
- </dependency>
<dependency>
+ <groupId>${servlet.spec.groupId}</groupId>
+ <artifactId>${servlet.spec.artifactId}</artifactId>
+ <version>${servlet.spec.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<scope>compile</scope>
Modified: jetty/branches/jetty-8/jetty-ajp/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-ajp/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-ajp/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -7,6 +7,9 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-ajp</artifactId>
<name>Jetty :: AJP</name>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.ajp</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -51,6 +54,14 @@
</execution>
</executions>
</plugin>
+
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java
===================================================================
--- jetty/branches/jetty-8/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -14,6 +14,7 @@
package org.eclipse.jetty.ajp;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import org.eclipse.jetty.http.AbstractGenerator;
@@ -26,6 +27,7 @@
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.EofException;
+import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
@@ -736,7 +738,7 @@
}
/* ------------------------------------------------------------ */
- private void addString(String str)
+ private void addString(String str) throws UnsupportedEncodingException
{
if (str == null)
{
@@ -746,7 +748,7 @@
// TODO - need to use a writer to convert, to avoid this hacky
// conversion and temp buffer
- byte[] b = str.getBytes();
+ byte[] b = str.getBytes(StringUtil.__ISO_8859_1);
addInt(b.length);
Modified: jetty/branches/jetty-8/jetty-annotations/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-annotations/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-annotations/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-annotations</artifactId>
<name>Jetty :: Servlet Annotations</name>
<description>Annotation support for deploying servlets in jetty.</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.annotations</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -35,6 +38,14 @@
</archive>
</configuration>
</plugin>
+
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AbstractConfiguration.java
===================================================================
--- jetty/branches/jetty-8/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AbstractConfiguration.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AbstractConfiguration.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -130,24 +130,31 @@
throws Exception
{
Log.debug("Scanning classes in WEB-INF/classes");
- parser.parse(context.getWebInf().addPath("classes/"),
- new ClassNameResolver()
+ if (context.getWebInf() != null)
{
- public boolean isExcluded (String name)
+ Resource classesDir = context.getWebInf().addPath("classes/");
+ if (classesDir.exists())
{
- if (context.isSystemClass(name)) return true;
- if (context.isServerClass(name)) return false;
- return false;
- }
+ parser.parse(classesDir,
+ new ClassNameResolver()
+ {
+ public boolean isExcluded (String name)
+ {
+ if (context.isSystemClass(name)) return true;
+ if (context.isServerClass(name)) return false;
+ return false;
+ }
- public boolean shouldOverride (String name)
- {
- //looking at webapp classpath, found already-parsed class of same name - did it come from system or duplicate in webapp?
- if (context.isParentLoaderPriority())
- return false;
- return true;
+ public boolean shouldOverride (String name)
+ {
+ //looking at webapp classpath, found already-parsed class of same name - did it come from system or duplicate in webapp?
+ if (context.isParentLoaderPriority())
+ return false;
+ return true;
+ }
+ });
}
- });
+ }
}
public void parse25Classes (final WebAppContext context, final AnnotationParser parser)
Modified: jetty/branches/jetty-8/jetty-client/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-client/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-client</artifactId>
<name>Jetty :: Asynchronous HTTP Client</name>
<url>{$jetty.url}</url>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.client</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -35,6 +38,13 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -26,13 +26,16 @@
import org.eclipse.jetty.http.HttpMethods;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpSchemes;
+import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersions;
import org.eclipse.jetty.http.ssl.SslSelectChannelEndPoint;
+import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.Buffers;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
+import org.eclipse.jetty.io.View;
import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.thread.Timeout;
@@ -48,6 +51,7 @@
private HttpGenerator _generator;
private HttpParser _parser;
private boolean _http11 = true;
+ private int _status;
private Buffer _connectionHeader;
private Buffer _requestContentChunk;
private boolean _requestComplete;
@@ -124,7 +128,7 @@
}
else
{
- SelectChannelEndPoint scep = (SelectChannelEndPoint)_endp;
+ AsyncEndPoint scep = (AsyncEndPoint)_endp;
scep.scheduleWrite();
}
_destination.getHttpClient().schedule(_timeout);
@@ -141,7 +145,6 @@
try
{
int no_progress = 0;
- long flushed = 0;
boolean failed = false;
while (_endp.isBufferingInput() || _endp.isOpen())
@@ -204,9 +207,10 @@
{
if (_exchange == null)
continue;
- flushed = _generator.flushBuffer();
- io += flushed;
}
+
+ long flushed = _generator.flushBuffer();
+ io += flushed;
if (!_generator.isComplete())
{
@@ -216,11 +220,15 @@
if (_requestContentChunk == null || _requestContentChunk.length() == 0)
{
_requestContentChunk = _exchange.getRequestContentChunk();
+ _destination.getHttpClient().schedule(_timeout);
+
if (_requestContentChunk != null)
_generator.addContent(_requestContentChunk,false);
else
_generator.complete();
- io += _generator.flushBuffer();
+
+ flushed = _generator.flushBuffer();
+ io += flushed;
}
}
else
@@ -235,12 +243,12 @@
}
// If we are not ended then parse available
- if (!_parser.isComplete() && _generator.isCommitted())
+ if (!_parser.isComplete() && (_generator.isComplete() || _generator.isCommitted() && !_endp.isBlocking()))
{
long filled = _parser.parseAvailable();
io += filled;
}
-
+
if (io > 0)
no_progress = 0;
else if (no_progress++ >= 2 && !_endp.isBlocking())
@@ -248,7 +256,8 @@
// SSL may need an extra flush as it may have made "no progress" while actually doing a handshake.
if (_endp instanceof SslSelectChannelEndPoint && !_generator.isComplete() && !_generator.isEmpty())
{
- if (_generator.flushBuffer()>0)
+ long flushed = _generator.flushBuffer();
+ if (flushed>0)
continue;
}
return this;
@@ -326,7 +335,23 @@
{
_exchange.disassociate();
_exchange = null;
+
+ if (_status==HttpStatus.SWITCHING_PROTOCOLS_101)
+ {
+ HttpConnection switched=_exchange.onSwitchProtocol(_endp);
+ if (switched!=null)
+ {
+ // switched protocol!
+ HttpExchange exchange = _pipeline;
+ _pipeline = null;
+ if (exchange!=null)
+ _destination.send(exchange);
+ return switched;
+ }
+ }
+
+
if (_pipeline == null)
{
if (!isReserved())
@@ -350,6 +375,7 @@
send(exchange);
}
}
+
}
}
}
@@ -392,6 +418,7 @@
{
synchronized (this)
{
+ _status=0;
if (_exchange.getStatus() != HttpExchange.STATUS_WAITING_FOR_COMMIT)
throw new IllegalStateException();
@@ -425,7 +452,7 @@
{
requestHeaders.putLongField(HttpHeaders.CONTENT_LENGTH, requestContent.length());
_generator.completeHeader(requestHeaders,false);
- _generator.addContent(requestContent,true);
+ _generator.addContent(new View(requestContent),true);
}
else
{
@@ -494,6 +521,7 @@
if (exchange!=null)
{
_http11 = HttpVersions.HTTP_1_1_BUFFER.equals(version);
+ _status=status;
exchange.getEventListener().onResponseStatus(version,status,reason);
exchange.setStatus(HttpExchange.STATUS_PARSING_HEADERS);
}
@@ -551,20 +579,7 @@
public void close() throws IOException
{
- try
- {
- _endp.close();
- }
- finally
- {
- HttpExchange exchange=_exchange;
- if (exchange!=null)
- {
- int status = exchange.getStatus();
- if (status>HttpExchange.STATUS_START && status<HttpExchange.STATUS_COMPLETED)
- System.err.println("\nCLOSE "+exchange);
- }
- }
+ _endp.close();
}
public void setIdleTimeout()
Modified: jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -25,6 +25,7 @@
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.HttpVersions;
import org.eclipse.jetty.io.Buffer;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.util.log.Log;
@@ -518,7 +519,6 @@
public void setRequestContent(Buffer requestContent)
{
_requestContent = requestContent;
- _requestContent.mark(_requestContent.getIndex());
}
/**
@@ -528,9 +528,7 @@
{
_requestContentSource = stream;
if (_requestContentSource.markSupported())
- {
_requestContentSource.mark(Integer.MAX_VALUE);
- }
}
/**
@@ -660,6 +658,13 @@
}
/**
+ */
+ protected HttpConnection onSwitchProtocol(EndPoint enpd) throws IOException
+ {
+ return null;
+ }
+
+ /**
* Callback called when the request headers have been sent to the server.
* This implementation does nothing.
* @throws IOException allowed to be thrown by overriding code
@@ -777,13 +782,6 @@
throw new IOException("Unsupported retry attempt");
}
}
- else
- {
- if (_requestContent != null)
- {
- _requestContent.reset();
- }
- }
}
/**
Modified: jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -162,6 +162,7 @@
SocketChannel channel = SocketChannel.open();
Address address = destination.isProxied() ? destination.getProxy() : destination.getAddress();
channel.configureBlocking( false );
+ channel.socket().setTcpNoDelay(true);
channel.connect(address.toSocketAddress());
_selectorManager.register( channel, destination );
ConnectTimeout connectTimeout = new ConnectTimeout(channel, destination);
@@ -211,7 +212,7 @@
protected void endPointClosed(SelectChannelEndPoint endpoint)
{
}
-
+
@Override
protected void endPointUpgraded(ConnectedEndPoint endpoint, Connection oldConnection)
{
@@ -304,7 +305,7 @@
}
@Override
- protected void expired()
+ public void expired()
{
_connectingChannels.remove(channel);
if (channel.isConnectionPending())
Modified: jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -54,6 +54,9 @@
socket = SocketFactory.getDefault().createSocket();
}
+ socket.setSoTimeout(_httpClient.getSoTimeout());
+ socket.setTcpNoDelay(true);
+
Address address = destination.isProxied() ? destination.getProxy() : destination.getAddress();
socket.connect(address.toSocketAddress(), _httpClient.getConnectTimeout());
@@ -73,7 +76,7 @@
{
final Connection next = con.handle();
if (next!=con)
- {
+ {
con=next;
continue;
}
Modified: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -312,7 +312,7 @@
{
HttpClient httpClient = getHttpClient();
httpClient.stop();
- httpClient.setTimeout(2000);
+ httpClient.setTimeout(1000);
httpClient.start();
TestHttpExchange exchange = new TestHttpExchange();
@@ -395,6 +395,7 @@
@Override
protected void onException(Throwable ex)
{
+ // ex.printStackTrace();
this.failed = true;
}
Modified: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ConnectionTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -70,7 +70,7 @@
CountDownLatch latch = new CountDownLatch(1);
HttpExchange exchange = new ConnectionExchange(latch);
// Using a IP address has a different behavior than using a host name
- exchange.setAddress(new Address("1.2.3.4", 8080));
+ exchange.setAddress(new Address("127.0.0.1", 1));
exchange.setURI("/");
httpClient.send(exchange);
@@ -99,7 +99,7 @@
CountDownLatch latch = new CountDownLatch(1);
HttpExchange exchange = new ConnectionExchange(latch);
// Using a IP address has a different behavior than using a host name
- exchange.setAddress(new Address("1.2.3.4", 8080));
+ exchange.setAddress(new Address("127.0.0.1", 1));
exchange.setURI("/");
httpClient.send(exchange);
@@ -187,5 +187,12 @@
if (latch!=null)
latch.countDown();
}
+
+ @Override
+ protected void onException(Throwable x)
+ {
+ if (latch!=null)
+ latch.countDown();
+ }
}
}
Modified: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ContentExchangeTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ContentExchangeTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ContentExchangeTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -13,6 +13,7 @@
package org.eclipse.jetty.client;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -68,6 +69,7 @@
private Realm _realm;
private String _protocol;
private String _baseUrl;
+ private String _requestContent;
public void setUp()
throws Exception
@@ -164,6 +166,26 @@
assertEquals(HttpStatus.OK_200,responseStatus);
}
+ public void testPost() throws Exception
+ {
+ startClient(_realm);
+
+ ContentExchange postExchange = new ContentExchange();
+ postExchange.setURL(getBaseUrl() + "test");
+ postExchange.setMethod(HttpMethods.POST);
+ postExchange.setRequestContent(new ByteArrayBuffer(_content.getBytes()));
+
+ _client.send(postExchange);
+ int state = postExchange.waitForDone();
+
+ int responseStatus = postExchange.getResponseStatus();
+
+ stopClient();
+
+ assertEquals(HttpStatus.OK_200,responseStatus);
+ assertEquals(_content,_requestContent);
+ }
+
protected void configureServer(Server server)
throws Exception
{
@@ -172,7 +194,7 @@
SelectChannelConnector connector = new SelectChannelConnector();
server.addConnector(connector);
- Handler handler = new PutHandler(getBasePath());
+ Handler handler = new TestHandler(getBasePath());
ServletContextHandler root = new ServletContextHandler();
root.setContextPath("/");
@@ -263,10 +285,10 @@
}
}
- protected static class PutHandler extends AbstractHandler {
+ protected class TestHandler extends AbstractHandler {
private final String resourcePath;
- public PutHandler(String repositoryPath) {
+ public TestHandler(String repositoryPath) {
this.resourcePath = repositoryPath;
}
@@ -274,29 +296,51 @@
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
- if (baseRequest.isHandled() || !baseRequest.getMethod().equals("PUT")) {
+ if (baseRequest.isHandled())
+ {
return;
}
- baseRequest.setHandled(true);
+ OutputStream out = null;
+
+ if (baseRequest.getMethod().equals("PUT"))
+ {
+ baseRequest.setHandled(true);
- File file = new File(resourcePath, URLDecoder.decode(request.getPathInfo()));
- file.getParentFile().mkdirs();
- file.deleteOnExit();
+ File file = new File(resourcePath, URLDecoder.decode(request.getPathInfo()));
+ file.getParentFile().mkdirs();
+ file.deleteOnExit();
- FileOutputStream out = new FileOutputStream(file);
- ServletInputStream in = request.getInputStream();
- try
+ out = new FileOutputStream(file);
+
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ }
+
+ if (baseRequest.getMethod().equals("POST"))
{
- copyStream( in, out );
+ baseRequest.setHandled(true);
+ out = new ByteArrayOutputStream();
+
+ response.setStatus(HttpServletResponse.SC_OK);
}
- finally
+
+ if (out != null)
{
- in.close();
- out.close();
+ ServletInputStream in = request.getInputStream();
+ try
+ {
+ copyStream( in, out );
+ }
+ finally
+ {
+ in.close();
+ out.close();
+ }
+
+ if (!(out instanceof FileOutputStream))
+ _requestContent = out.toString();
}
-
- response.setStatus(HttpServletResponse.SC_CREATED);
+
}
}
}
Modified: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ErrorStatusTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ErrorStatusTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/ErrorStatusTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -89,11 +89,39 @@
doGetFail(HttpStatus.INTERNAL_SERVER_ERROR_500);
}
+ public void testPostBadRequest()
+ throws Exception
+ {
+ doPostFail(HttpStatus.BAD_REQUEST_400);
+ }
+
+ public void testPostUnauthorized()
+ throws Exception
+ {
+ doPostFail(HttpStatus.UNAUTHORIZED_401);
+ }
+
+ public void testPostForbidden()
+ throws Exception
+ {
+ doPostFail(HttpStatus.FORBIDDEN_403);
+ }
+
+ public void testPostNotFound()
+ throws Exception
+ {
+ doPostFail(HttpStatus.NOT_FOUND_404);
+ }
+
+ public void testPostServerError()
+ throws Exception
+ {
+ doPostFail(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ }
+
protected void doPutFail(int status)
throws Exception
{
- System.err.println(getName());
-
startClient(getRealm());
ContentExchange putExchange = new ContentExchange();
@@ -115,8 +143,6 @@
protected void doGetFail(int status)
throws Exception
{
- System.err.println(getName());
-
startClient(getRealm());
ContentExchange getExchange = new ContentExchange();
@@ -138,6 +164,27 @@
assertEquals(status, responseStatus);
}
+ protected void doPostFail(int status)
+ throws Exception
+ {
+ startClient(getRealm());
+
+ ContentExchange postExchange = new ContentExchange();
+ postExchange.setURL(getBaseUrl() + "test");
+ postExchange.setMethod(HttpMethods.POST);
+ postExchange.setRequestHeader("X-Response-Status",Integer.toString(status));
+ postExchange.setRequestContent(new ByteArrayBuffer(getContent().getBytes()));
+
+ getClient().send(postExchange);
+ int state = postExchange.waitForDone();
+
+ int responseStatus = postExchange.getResponseStatus();
+
+ stopClient();
+
+ assertEquals(status, responseStatus);
+ }
+
protected void configureServer(Server server)
throws Exception
{
@@ -154,10 +201,10 @@
root.addServlet( servletHolder, "/*" );
Handler status = new StatusHandler();
- Handler puthdl = new PutHandler(getBasePath());
+ Handler test = new TestHandler(getBasePath());
HandlerCollection handlers = new HandlerCollection();
- handlers.setHandlers(new Handler[]{status, puthdl, root});
+ handlers.setHandlers(new Handler[]{status, test, root});
server.setHandler( handlers );
}
Modified: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -27,7 +27,6 @@
import org.eclipse.jetty.client.security.ProxyAuthorization;
import org.eclipse.jetty.http.HttpHeaders;
import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.EofException;
@@ -56,6 +55,9 @@
{
startServer();
_httpClient=new HttpClient();
+ _httpClient.setIdleTimeout(2000);
+ _httpClient.setTimeout(2500);
+ _httpClient.setConnectTimeout(1000);
_httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
_httpClient.setMaxConnectionsPerAddress(_maxConnectionsPerAddress);
_httpClient.start();
@@ -256,7 +258,68 @@
Thread.sleep(5);
}
}
+
+ public void testSlowPost() throws Exception
+ {
+ ContentExchange httpExchange=new ContentExchange()
+ {
+ };
+ //httpExchange.setURL(_scheme+"localhost:"+_port+"/");
+ httpExchange.setURL(_scheme+"localhost:"+_port);
+ httpExchange.setMethod(HttpMethods.POST);
+ final String data="012345678901234567890123456789012345678901234567890123456789";
+
+ InputStream content = new InputStream()
+ {
+ int _index=0;
+
+ @Override
+ public int read() throws IOException
+ {
+ if (_index>=data.length())
+ return -1;
+
+ return data.charAt(_index++);
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException
+ {
+ if (_index>=data.length())
+ return -1;
+
+ //System.err.println("sleep "+_index);
+ try
+ {
+ Thread.sleep(250);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+
+ int l=0;
+
+ while (l<5 && _index<data.length() && l<len)
+ b[off+l++]=(byte)data.charAt(_index++);
+ return l;
+ }
+
+ };
+
+ httpExchange.setRequestContentSource(content);
+ //httpExchange.setRequestContent(new ByteArrayBuffer(data));
+
+ _httpClient.send(httpExchange);
+
+ int status = httpExchange.waitForDone();
+ //httpExchange.waitForStatus(HttpExchange.STATUS_COMPLETED);
+ String result=httpExchange.getResponseContent();
+ assertEquals(HttpExchange.STATUS_COMPLETED, status);
+ assertEquals(data,result);
+ }
+
public void testProxy() throws Exception
{
if (_scheme.equals("https://"))
@@ -327,7 +390,7 @@
}
catch (EofException e)
{
- System.err.println(e);
+ System.err.println("HttpExchangeTest#copyStream: "+e);
}
catch (IOException e)
{
Copied: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/HttpHeadersTest.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-client/src/test/java/org/eclipse/jetty/client/HttpHeadersTest.java)
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/HttpHeadersTest.java (rev 0)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/HttpHeadersTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,147 @@
+// ========================================================================
+// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+package org.eclipse.jetty.client;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jetty.http.HttpMethods;
+import org.eclipse.jetty.http.HttpStatus;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+
+public class HttpHeadersTest extends TestCase
+{
+ private static String _content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In quis felis nunc. "
+ + "Quisque suscipit mauris et ante auctor ornare rhoncus lacus aliquet. Pellentesque "
+ + "habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. "
+ + "Vestibulum sit amet felis augue, vel convallis dolor. Cras accumsan vehicula diam "
+ + "at faucibus. Etiam in urna turpis, sed congue mi. Morbi et lorem eros. Donec vulputate "
+ + "velit in risus suscipit lobortis. Aliquam id urna orci, nec sollicitudin ipsum. "
+ + "Cras a orci turpis. Donec suscipit vulputate cursus. Mauris nunc tellus, fermentum "
+ + "eu auctor ut, mollis at diam. Quisque porttitor ultrices metus, vitae tincidunt massa "
+ + "sollicitudin a. Vivamus porttitor libero eget purus hendrerit cursus. Integer aliquam "
+ + "consequat mauris quis luctus. Cras enim nibh, dignissim eu faucibus ac, mollis nec neque. "
+ + "Aliquam purus mauris, consectetur nec convallis lacinia, porta sed ante. Suspendisse "
+ + "et cursus magna. Donec orci enim, molestie a lobortis eu, imperdiet vitae neque.";
+
+ private File _docRoot;
+ private Server _server;
+ private Connector _connector;
+ private TestHeaderHandler _handler;
+ private int _port;
+
+ public void setUp() throws Exception
+ {
+ _docRoot = new File("target/test-output/docroot/");
+ _docRoot.mkdirs();
+ _docRoot.deleteOnExit();
+
+ startServer();
+ }
+
+ public void tearDown() throws Exception
+ {
+ stopServer();
+ }
+
+ public void testHttpHeaders() throws Exception
+ {
+ HttpClient client = new HttpClient();
+ client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
+ client.start();
+
+ String requestUrl = "http://localhost:" + _port + "/header";
+
+ ContentExchange exchange = new ContentExchange();
+ exchange.setURL(requestUrl);
+ exchange.setMethod(HttpMethods.GET);
+ exchange.addRequestHeader("User-Agent","Jetty-Client/7.0");
+
+ client.send(exchange);
+ int state = exchange.waitForDone();
+
+ String content = "";
+ int responseStatus = exchange.getResponseStatus();
+ if (responseStatus == HttpStatus.OK_200)
+ {
+ content = exchange.getResponseContent();
+ }
+
+ assertEquals(HttpStatus.OK_200,responseStatus);
+ assertEquals(_content,content);
+ assertEquals("Jetty-Client/7.0",_handler.headers.get("User-Agent"));
+ }
+
+ protected void startServer() throws Exception
+ {
+ _server = new Server(0);
+
+ _connector = new SelectChannelConnector();
+ _server.addConnector(_connector);
+
+ _handler = new TestHeaderHandler();
+ _server.setHandler(_handler);
+
+ _server.start();
+
+ _port = _connector.getLocalPort();
+ }
+
+ protected void stopServer() throws Exception
+ {
+ if (_server != null)
+ {
+ _server.stop();
+ _server = null;
+ }
+ }
+
+ private static class TestHeaderHandler extends AbstractHandler
+ {
+ protected Map<String, String> headers;
+
+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ if (baseRequest.isHandled())
+ return;
+
+ headers = new HashMap<String, String>();
+ for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();)
+ {
+ String name = (String)e.nextElement();
+ headers.put(name,request.getHeader(name));
+ }
+
+ response.setContentType("text/plain");
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.getWriter().print(_content);
+
+ baseRequest.setHandled(true);
+ }
+
+ }
+}
Modified: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SecuredContentExchangeTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SecuredContentExchangeTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SecuredContentExchangeTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -90,7 +90,7 @@
servletHolder.setInitParameter( "gzip", "true" );
root.addServlet( servletHolder, "/*" );
- Handler handler = new PutHandler(getBasePath());
+ Handler handler = new TestHandler(getBasePath());
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[]{handler, root});
Copied: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SecuredErrorStatusTest.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-client/src/test/java/org/eclipse/jetty/client/SecuredErrorStatusTest.java)
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SecuredErrorStatusTest.java (rev 0)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SecuredErrorStatusTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,166 @@
+// ========================================================================
+// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+package org.eclipse.jetty.client;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jetty.client.ContentExchangeTest.TestHandler;
+import org.eclipse.jetty.client.security.Realm;
+import org.eclipse.jetty.http.HttpStatus;
+import org.eclipse.jetty.http.security.Constraint;
+import org.eclipse.jetty.security.ConstraintMapping;
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.security.HashLoginService;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.security.authentication.BasicAuthenticator;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.servlet.DefaultServlet;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+public class SecuredErrorStatusTest
+ extends ErrorStatusTest
+{
+ private Realm _testRealm;
+ private Realm _dummyRealm;
+
+ public void testPutUnauthorized()
+ throws Exception
+ {
+ setRealm(null);
+
+ doPutFail(HttpStatus.UNAUTHORIZED_401);
+
+ setRealm(_testRealm);
+ }
+
+ public void testPutWrongPassword()
+ throws Exception
+ {
+ setRealm(_dummyRealm);
+
+ doPutFail(HttpStatus.UNAUTHORIZED_401);
+
+ setRealm(_testRealm);
+ }
+
+ public void testGetUnauthorized()
+ throws Exception
+ {
+ setRealm(null);
+
+ doGetFail(HttpStatus.UNAUTHORIZED_401);
+
+ setRealm(_testRealm);
+ }
+
+ public void testGetWrongPassword()
+ throws Exception
+ {
+ setRealm(_dummyRealm);
+
+ doGetFail(HttpStatus.UNAUTHORIZED_401);
+
+ setRealm(_testRealm);
+ }
+
+ protected void configureServer(Server server)
+ throws Exception
+ {
+ setProtocol("http");
+
+ _testRealm = new Realm()
+ {
+ public String getId()
+ {
+ return "MyRealm";
+ }
+
+ public String getPrincipal()
+ {
+ return "jetty";
+ }
+
+ public String getCredentials()
+ {
+ return "jetty";
+ }
+ };
+
+ _dummyRealm = new Realm()
+ {
+ public String getId()
+ {
+ return "MyRealm";
+ }
+
+ public String getPrincipal()
+ {
+ return "jetty";
+ }
+
+ public String getCredentials()
+ {
+ return "dummy";
+ }
+ };
+
+ setRealm(_testRealm);
+
+ SelectChannelConnector connector = new SelectChannelConnector();
+ server.addConnector(connector);
+
+ LoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties");
+ server.addBean(loginService);
+
+ ConstraintSecurityHandler security = new ConstraintSecurityHandler();
+ server.setHandler(security);
+
+ Constraint constraint = new Constraint();
+ constraint.setName("auth");
+ constraint.setAuthenticate( true );
+ constraint.setRoles(new String[]{"user", "admin"});
+
+ ConstraintMapping mapping = new ConstraintMapping();
+ mapping.setPathSpec( "/*" );
+ mapping.setConstraint( constraint );
+
+ Set<String> knownRoles = new HashSet<String>();
+ knownRoles.add("user");
+ knownRoles.add("admin");
+
+ security.setConstraintMappings(new ConstraintMapping[] {mapping}, knownRoles);
+ security.setAuthenticator(new BasicAuthenticator());
+ security.setLoginService(loginService);
+ security.setStrict(false);
+
+ ServletContextHandler root = new ServletContextHandler();
+ root.setContextPath("/");
+ root.setResourceBase(getBasePath());
+ ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+ servletHolder.setInitParameter( "gzip", "true" );
+ root.addServlet( servletHolder, "/*" );
+
+ Handler status = new StatusHandler();
+ Handler test = new TestHandler(getBasePath());
+
+ HandlerCollection handlers = new HandlerCollection();
+ handlers.setHandlers(new Handler[]{status, test, root});
+ security.setHandler(handlers);
+ }
+}
Copied: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslContentExchangeTest.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-client/src/test/java/org/eclipse/jetty/client/SslContentExchangeTest.java)
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslContentExchangeTest.java (rev 0)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslContentExchangeTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,55 @@
+// ========================================================================
+// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+package org.eclipse.jetty.client;
+
+import java.io.File;
+
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
+import org.eclipse.jetty.servlet.DefaultServlet;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+public class SslContentExchangeTest
+ extends ContentExchangeTest
+{
+
+ protected void configureServer(Server server)
+ throws Exception
+ {
+ setProtocol("https");
+
+ SslSelectChannelConnector connector = new SslSelectChannelConnector();
+ String keystore = new File("src/test/resources/keystore").getAbsolutePath();
+ connector.setKeystore(keystore);
+ connector.setPassword("storepwd");
+ connector.setKeyPassword("keypwd");
+ server.addConnector(connector);
+
+ Handler handler = new TestHandler(getBasePath());
+
+ ServletContextHandler root = new ServletContextHandler();
+ root.setContextPath("/");
+ root.setResourceBase(getBasePath());
+ ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+ servletHolder.setInitParameter( "gzip", "true" );
+ root.addServlet( servletHolder, "/*" );
+
+ HandlerCollection handlers = new HandlerCollection();
+ handlers.setHandlers(new Handler[]{handler, root});
+ server.setHandler( handlers );
+ }
+}
Modified: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -18,6 +18,7 @@
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.util.log.Log;
/**
* Functional testing for HttpExchange.
@@ -33,7 +34,10 @@
_scheme="https://";
startServer();
_httpClient=new HttpClient();
- // _httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
+ _httpClient.setIdleTimeout(2000);
+ _httpClient.setTimeout(2500);
+ _httpClient.setConnectTimeout(1000);
+ _httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
_httpClient.setConnectorType(HttpClient.CONNECTOR_SOCKET);
_httpClient.setMaxConnectionsPerAddress(2);
_httpClient.start();
@@ -59,4 +63,60 @@
{ connector });
_connector=connector;
}
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.client.HttpExchangeTest#testGetWithContentExchange()
+ */
+ @Override
+ public void testGetWithContentExchange() throws Exception
+ {
+ // TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532
+ if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")<0)
+ super.testGetWithContentExchange();
+ else
+ Log.warn("Skipped SSL testGetWithContentExchange on IBM JVM");
+ }
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.client.HttpExchangeTest#testPerf()
+ */
+ @Override
+ public void testPerf() throws Exception
+ {
+ // TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532
+ if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")<0)
+ super.testPerf();
+ else
+ Log.warn("Skipped SSL testPerf on IBM JVM");
+ }
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.client.HttpExchangeTest#testPostWithContentExchange()
+ */
+ @Override
+ public void testPostWithContentExchange() throws Exception
+ {
+ // TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532
+ if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")<0)
+ super.testPostWithContentExchange();
+ else
+ Log.warn("Skipped SSL testPostWithContentExchange on IBM JVM");
+ }
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.client.HttpExchangeTest#testReserveConnections()
+ */
+ @Override
+ public void testReserveConnections() throws Exception
+ {
+ // TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532
+ if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")<0)
+ super.testReserveConnections();
+ else
+ Log.warn("Skipped SSL testReserveConnections on IBM JVM");
+ }
}
Copied: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredContentExchangeTest.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredContentExchangeTest.java)
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredContentExchangeTest.java (rev 0)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredContentExchangeTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,104 @@
+// ========================================================================
+// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+package org.eclipse.jetty.client;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jetty.client.security.Realm;
+import org.eclipse.jetty.http.security.Constraint;
+import org.eclipse.jetty.security.ConstraintMapping;
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.security.HashLoginService;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.security.authentication.BasicAuthenticator;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
+import org.eclipse.jetty.servlet.DefaultServlet;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+public class SslSecuredContentExchangeTest
+extends ContentExchangeTest
+{
+ protected void configureServer(Server server)
+ throws Exception
+ {
+ setProtocol("https");
+ setRealm(new Realm()
+ {
+ public String getId()
+ {
+ return "MyRealm";
+ }
+
+ public String getPrincipal()
+ {
+ return "jetty";
+ }
+
+ public String getCredentials()
+ {
+ return "jetty";
+ }
+ });
+
+ SslSelectChannelConnector connector = new SslSelectChannelConnector();
+ String keystore = new File("src/test/resources/keystore").getAbsolutePath();
+ connector.setKeystore(keystore);
+ connector.setPassword("storepwd");
+ connector.setKeyPassword("keypwd");
+ server.addConnector(connector);
+
+ LoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties");
+ server.addBean(loginService);
+
+ ConstraintSecurityHandler security = new ConstraintSecurityHandler();
+ server.setHandler(security);
+
+ Constraint constraint = new Constraint();
+ constraint.setName("auth");
+ constraint.setAuthenticate( true );
+ constraint.setRoles(new String[]{"user", "admin"});
+
+ ConstraintMapping mapping = new ConstraintMapping();
+ mapping.setPathSpec( "/*" );
+ mapping.setConstraint( constraint );
+
+ Set<String> knownRoles = new HashSet<String>();
+ knownRoles.add("user");
+ knownRoles.add("admin");
+
+ security.setConstraintMappings(new ConstraintMapping[] {mapping}, knownRoles);
+ security.setAuthenticator(new BasicAuthenticator());
+ security.setLoginService(loginService);
+ security.setStrict(false);
+
+ ServletContextHandler root = new ServletContextHandler();
+ root.setContextPath("/");
+ root.setResourceBase(getBasePath());
+ ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+ servletHolder.setInitParameter( "gzip", "true" );
+ root.addServlet( servletHolder, "/*" );
+
+ Handler handler = new TestHandler(getBasePath());
+
+ HandlerCollection handlers = new HandlerCollection();
+ handlers.setHandlers(new Handler[]{handler, root});
+ security.setHandler(handlers);
+ }
+}
Copied: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredErrorStatusTest.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredErrorStatusTest.java)
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredErrorStatusTest.java (rev 0)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecuredErrorStatusTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,166 @@
+// ========================================================================
+// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+package org.eclipse.jetty.client;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jetty.client.ContentExchangeTest.TestHandler;
+import org.eclipse.jetty.client.security.Realm;
+import org.eclipse.jetty.http.HttpStatus;
+import org.eclipse.jetty.http.security.Constraint;
+import org.eclipse.jetty.security.ConstraintMapping;
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.security.HashLoginService;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.security.authentication.BasicAuthenticator;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.servlet.DefaultServlet;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+public class SslSecuredErrorStatusTest
+ extends ErrorStatusTest
+{
+ private Realm _testRealm;
+ private Realm _dummyRealm;
+
+ public void testPutUnauthorized()
+ throws Exception
+ {
+ setRealm(null);
+
+ doPutFail(HttpStatus.UNAUTHORIZED_401);
+
+ setRealm(_testRealm);
+ }
+
+ public void testPutWrongPassword()
+ throws Exception
+ {
+ setRealm(_dummyRealm);
+
+ doPutFail(HttpStatus.UNAUTHORIZED_401);
+
+ setRealm(_testRealm);
+ }
+
+ public void testGetUnauthorized()
+ throws Exception
+ {
+ setRealm(null);
+
+ doGetFail(HttpStatus.UNAUTHORIZED_401);
+
+ setRealm(_testRealm);
+ }
+
+ public void testGetWrongPassword()
+ throws Exception
+ {
+ setRealm(_dummyRealm);
+
+ doGetFail(HttpStatus.UNAUTHORIZED_401);
+
+ setRealm(_testRealm);
+ }
+
+ protected void configureServer(Server server)
+ throws Exception
+ {
+ setProtocol("http");
+
+ _testRealm = new Realm()
+ {
+ public String getId()
+ {
+ return "MyRealm";
+ }
+
+ public String getPrincipal()
+ {
+ return "jetty";
+ }
+
+ public String getCredentials()
+ {
+ return "jetty";
+ }
+ };
+
+ _dummyRealm = new Realm()
+ {
+ public String getId()
+ {
+ return "MyRealm";
+ }
+
+ public String getPrincipal()
+ {
+ return "jetty";
+ }
+
+ public String getCredentials()
+ {
+ return "dummy";
+ }
+ };
+
+ setRealm(_testRealm);
+
+ SelectChannelConnector connector = new SelectChannelConnector();
+ server.addConnector(connector);
+
+ LoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties");
+ server.addBean(loginService);
+
+ ConstraintSecurityHandler security = new ConstraintSecurityHandler();
+ server.setHandler(security);
+
+ Constraint constraint = new Constraint();
+ constraint.setName("auth");
+ constraint.setAuthenticate( true );
+ constraint.setRoles(new String[]{"user", "admin"});
+
+ ConstraintMapping mapping = new ConstraintMapping();
+ mapping.setPathSpec( "/*" );
+ mapping.setConstraint( constraint );
+
+ Set<String> knownRoles = new HashSet<String>();
+ knownRoles.add("user");
+ knownRoles.add("admin");
+
+ security.setConstraintMappings(new ConstraintMapping[] {mapping}, knownRoles);
+ security.setAuthenticator(new BasicAuthenticator());
+ security.setLoginService(loginService);
+ security.setStrict(false);
+
+ ServletContextHandler root = new ServletContextHandler();
+ root.setContextPath("/");
+ root.setResourceBase(getBasePath());
+ ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+ servletHolder.setInitParameter( "gzip", "true" );
+ root.addServlet( servletHolder, "/*" );
+
+ Handler status = new StatusHandler();
+ Handler test = new TestHandler(getBasePath());
+
+ HandlerCollection handlers = new HandlerCollection();
+ handlers.setHandlers(new Handler[]{status, test, root});
+ security.setHandler(handlers);
+ }
+}
Modified: jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecurityListenerTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecurityListenerTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-client/src/test/java/org/eclipse/jetty/client/SslSecurityListenerTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -44,6 +44,7 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.util.log.Log;
/**
* Functional testing.
@@ -100,6 +101,14 @@
public void testSslGet() throws Exception
{
+ // TODO Resolve problems on IBM JVM https://bugs.eclipse.org/bugs/show_bug.cgi?id=304532
+ if (System.getProperty("java.vendor").toLowerCase().indexOf("ibm")>=0)
+ {
+ Log.warn("Skipped SSL testSslGet on IBM JVM");
+ return;
+ }
+
+
final CyclicBarrier barrier = new CyclicBarrier(2);
ContentExchange httpExchange = new ContentExchange(true)
@@ -112,10 +121,8 @@
}
};
- // httpExchange.setURL("https://dav.codehaus.org/user/jesse/index.html");
- httpExchange.setURL("https://localhost:" + _port + "/");
+ httpExchange.setURL("https://127.0.0.1:" + _port + "/");
httpExchange.setMethod(HttpMethods.GET);
- // httpExchange.setRequestHeader("Connection","close");
_httpClient.send(httpExchange);
@@ -123,7 +130,6 @@
assertEquals(HttpServletResponse.SC_OK,httpExchange.getResponseStatus());
- // System.err.println(httpExchange.getResponseContent());
assertTrue(httpExchange.getResponseContent().length()>400);
}
Modified: jetty/branches/jetty-8/jetty-continuation/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-continuation/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-continuation/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-continuation</artifactId>
<name>Jetty :: Continuation</name>
<description>Asynchronous API</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.continuation</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -55,24 +58,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
</plugin>
</plugins>
</build>
<dependencies>
- <dependency>
- <groupId>${servlet.spec.groupId}</groupId>
- <artifactId>${servlet.spec.artifactId}</artifactId>
- <scope>provided</scope>
- </dependency>
<dependency>
+ <groupId>${servlet.spec.groupId}</groupId>
+ <artifactId>${servlet.spec.artifactId}</artifactId>
+ <version>${servlet.spec.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>6.1.15</version>
Modified: jetty/branches/jetty-8/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Continuation.java
===================================================================
--- jetty/branches/jetty-8/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Continuation.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Continuation.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -147,7 +147,8 @@
*
* @param timeoutMs
* The time in milliseconds to wait before expiring this
- * continuation after a call to {@link #suspend()} or {@link #suspend(ServletResponse)}
+ * continuation after a call to {@link #suspend()} or {@link #suspend(ServletResponse)}.
+ * A timeout of <=0 means the continuation will never expire.
*/
void setTimeout(long timeoutMs);
Modified: jetty/branches/jetty-8/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java
===================================================================
--- jetty/branches/jetty-8/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1,6 +1,8 @@
package org.eclipse.jetty.continuation;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import javax.servlet.AsyncContext;
import javax.servlet.AsyncEvent;
@@ -11,7 +13,6 @@
import javax.servlet.ServletResponseWrapper;
-
/* ------------------------------------------------------------ */
/**
* This implementation of Continuation is used by {@link ContinuationSupport}
@@ -27,41 +28,46 @@
private final ServletRequest _request;
private ServletResponse _response;
private AsyncContext _context;
- private final AsyncListener _listener = new AsyncListener()
- {
- public void onComplete(AsyncEvent event) throws IOException
- {
- }
-
- public void onError(AsyncEvent event) throws IOException
- {
- }
-
- public void onStartAsync(AsyncEvent event) throws IOException
- {
- event.getAsyncContext().addListener(this);
- }
-
- public void onTimeout(AsyncEvent event) throws IOException
- {
- _initial=false;
- event.getAsyncContext().dispatch();
- }
- };
-
+ private List<AsyncListener> _listeners=new ArrayList<AsyncListener>();
private volatile boolean _initial=true;
private volatile boolean _resumed=false;
private volatile boolean _expired=false;
private volatile boolean _responseWrapped=false;
-
+
+ private long _timeoutMs=-1;
+
+ /* ------------------------------------------------------------ */
public Servlet3Continuation(ServletRequest request)
{
_request=request;
+
+ _listeners.add(new AsyncListener()
+ {
+ public void onComplete(AsyncEvent event) throws IOException
+ {
+ }
+
+ public void onError(AsyncEvent event) throws IOException
+ {
+ }
+
+ public void onStartAsync(AsyncEvent event) throws IOException
+ {
+ event.getAsyncContext().addListener(this);
+ }
+
+ public void onTimeout(AsyncEvent event) throws IOException
+ {
+ _initial=false;
+ event.getAsyncContext().dispatch();
+ }
+ });
}
+ /* ------------------------------------------------------------ */
public void addContinuationListener(final ContinuationListener listener)
{
- _context.addListener(new AsyncListener()
+ AsyncListener wrapped = new AsyncListener()
{
public void onComplete(final AsyncEvent event) throws IOException
{
@@ -83,9 +89,15 @@
_expired=true;
listener.onTimeout(Servlet3Continuation.this);
}
- });
+ };
+
+ if (_context==null)
+ _context.addListener(wrapped);
+ else
+ _listeners.add(wrapped);
}
+ /* ------------------------------------------------------------ */
public void complete()
{
AsyncContext context=_context;
@@ -94,37 +106,44 @@
_context.complete();
}
+ /* ------------------------------------------------------------ */
public ServletResponse getServletResponse()
{
return _response;
}
+ /* ------------------------------------------------------------ */
public boolean isExpired()
{
return _expired;
}
+ /* ------------------------------------------------------------ */
public boolean isInitial()
{
// TODO - this is not perfect if non continuation API is used directly
return _initial&&_request.getDispatcherType()!=DispatcherType.ASYNC;
}
+ /* ------------------------------------------------------------ */
public boolean isResumed()
{
return _resumed;
}
+ /* ------------------------------------------------------------ */
public boolean isSuspended()
{
return _request.isAsyncStarted();
}
+ /* ------------------------------------------------------------ */
public void keepWrappers()
{
_responseWrapped=true;
}
+ /* ------------------------------------------------------------ */
public void resume()
{
AsyncContext context=_context;
@@ -134,11 +153,15 @@
_context.dispatch();
}
+ /* ------------------------------------------------------------ */
public void setTimeout(long timeoutMs)
{
- _context.setTimeout(timeoutMs);
+ _timeoutMs=timeoutMs;
+ if (_context!=null)
+ _context.setTimeout(timeoutMs);
}
+ /* ------------------------------------------------------------ */
public void suspend(ServletResponse response)
{
_response=response;
@@ -146,23 +169,32 @@
_resumed=false;
_expired=false;
_context=_request.startAsync();
- _context.addListener(_listener);
+ _context.setTimeout(_timeoutMs);
+
+ for (AsyncListener listener:_listeners)
+ _context.addListener(listener);
+ _listeners.clear();
}
+ /* ------------------------------------------------------------ */
public void suspend()
{
_resumed=false;
_expired=false;
_context=_request.startAsync();
- _context.addListener(_listener);
+ _context.setTimeout(_timeoutMs);
+
+ for (AsyncListener listener:_listeners)
+ _context.addListener(listener);
+ _listeners.clear();
}
+ /* ------------------------------------------------------------ */
public boolean isResponseWrapped()
{
return _responseWrapped;
}
-
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.continuation.Continuation#getAttribute(java.lang.String)
@@ -172,7 +204,6 @@
return _request.getAttribute(name);
}
-
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.continuation.Continuation#removeAttribute(java.lang.String)
@@ -191,7 +222,6 @@
_request.setAttribute(name,attribute);
}
-
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.continuation.Continuation#undispatch()
Modified: jetty/branches/jetty-8/jetty-deploy/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-deploy/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-deploy/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-deploy</artifactId>
<name>Jetty :: Deployers</name>
<description>Jetty deployers</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.deploy</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -39,14 +42,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
</plugin>
</plugins>
</build>
Modified: jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java
===================================================================
--- jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/ContextDeployer.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -393,11 +393,11 @@
{
try
{
- if (name.endsWith(".xml")&&dir.equals(getConfigurationDir().getFile()))
+ if (name.endsWith(".xml"))
return true;
return false;
}
- catch (IOException e)
+ catch (Exception e)
{
Log.warn(e);
return false;
Modified: jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/WebAppDeployer.java
===================================================================
--- jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/WebAppDeployer.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/WebAppDeployer.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -295,7 +295,7 @@
_deployed.add(wah);
if (_contexts.isStarted())
- _contexts.start(); // TODO Multi exception
+ wah.start(); // TODO Multi exception
}
}
Modified: jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/MonitoredDirAppProvider.java
===================================================================
--- jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/MonitoredDirAppProvider.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/MonitoredDirAppProvider.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -91,7 +91,7 @@
{
public void fileAdded(String filename) throws Exception
{
- Log.debug("added ", filename);
+ if (Log.isDebugEnabled()) Log.debug("added ", filename);
addConfiguredContextApp(filename);
}
@@ -99,14 +99,13 @@
{
System.err.println("changed "+filename);
// TODO should this not be an add/remove?
- Log.debug("changed ", filename);
+ if (Log.isDebugEnabled()) Log.debug("changed ", filename);
addConfiguredContextApp(filename);
}
public void fileRemoved(String filename) throws Exception
{
- System.err.println("removed "+filename);
- Log.debug("removed ", filename);
+ if (Log.isDebugEnabled()) Log.debug("removed ", filename);
// TODO: How to determine ID from filename that doesn't exist?
// TODO: we probably need a map from discovered filename to resulting App
@@ -217,14 +216,13 @@
@Override
protected void doStart() throws Exception
{
- Log.info(this.getClass().getSimpleName() + ".doStart()");
if (_monitoredDir == null)
{
throw new IllegalStateException("No configuration dir specified");
}
File scandir = _monitoredDir.getFile();
- Log.info("Deployment monitor " + scandir+ " at intervale "+_scanInterval);
+ Log.info("Deployment monitor " + scandir+ " at interval "+_scanInterval);
_scanner=new Scanner();
_scanner.setScanDirs(Collections.singletonList(scandir));
_scanner.setScanInterval(_scanInterval);
Modified: jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
===================================================================
--- jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -53,7 +53,7 @@
{
public void fileAdded(String filename) throws Exception
{
- Log.debug("added ",filename);
+ if (Log.isDebugEnabled()) Log.debug("added ",filename);
App app = ScanningAppProvider.this.createApp(filename);
if (app != null)
{
@@ -64,7 +64,7 @@
public void fileChanged(String filename) throws Exception
{
- Log.debug("changed ",filename);
+ if (Log.isDebugEnabled()) Log.debug("changed ",filename);
App app = _appMap.remove(filename);
if (app != null)
{
@@ -80,7 +80,7 @@
public void fileRemoved(String filename) throws Exception
{
- Log.debug("removed ",filename);
+ if (Log.isDebugEnabled()) Log.debug("removed ",filename);
App app = _appMap.remove(filename);
if (app != null)
_deploymentManager.removeApp(app);
@@ -118,14 +118,14 @@
@Override
protected void doStart() throws Exception
{
- Log.info(this.getClass().getSimpleName() + ".doStart()");
+ if (Log.isDebugEnabled()) Log.debug(this.getClass().getSimpleName() + ".doStart()");
if (_monitoredDir == null)
{
throw new IllegalStateException("No configuration dir specified");
}
File scandir = _monitoredDir.getFile();
- Log.info("Deployment monitor " + scandir + " at intervale " + _scanInterval);
+ Log.info("Deployment monitor " + scandir + " at interval " + _scanInterval);
_scanner = new Scanner();
_scanner.setScanDirs(Collections.singletonList(scandir));
_scanner.setScanInterval(_scanInterval);
Copied: jetty/branches/jetty-8/jetty-distribution/src/main/resources/javadoc/contents.html (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-distribution/src/main/resources/javadoc/contents.html)
===================================================================
--- jetty/branches/jetty-8/jetty-distribution/src/main/resources/javadoc/contents.html (rev 0)
+++ jetty/branches/jetty-8/jetty-distribution/src/main/resources/javadoc/contents.html 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,4 @@
+
+<h1>Javadoc not generated</h1>
+See the online version at <a
+href="http://download.eclipse.org/jetty/">http://download.eclipse.org/jetty/</a>.
Modified: jetty/branches/jetty-8/jetty-distribution/src/main/resources/start.ini
===================================================================
--- jetty/branches/jetty-8/jetty-distribution/src/main/resources/start.ini 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-distribution/src/main/resources/start.ini 2010-04-06 18:17:57 UTC (rev 1472)
@@ -14,7 +14,7 @@
#
#===========================================================
-OPTIONS=Server,jmx,resources,websocket
+OPTIONS=Server,jmx,resources,websocket,ext
#===========================================================
# The following is an example of the ini args to run the
Modified: jetty/branches/jetty-8/jetty-http/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-http/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-http/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<name>Jetty :: Http Utility</name>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.http</bundle-symbolic-name>
+ </properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
@@ -58,6 +61,12 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
</project>
Modified: jetty/branches/jetty-8/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java
===================================================================
--- jetty/branches/jetty-8/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -133,7 +133,7 @@
int day_of_month = gc.get(Calendar.DAY_OF_MONTH);
int month = gc.get(Calendar.MONTH);
int year = gc.get(Calendar.YEAR);
- year = year % 100;
+ year = year % 10000;
int epoch = (int) ((date / 1000) % (60 * 60 * 24));
int seconds = epoch % 60;
@@ -149,8 +149,9 @@
buf.append('-');
buf.append(MONTHS[month]);
buf.append('-');
- StringUtil.append2digits(buf, year);
-
+ StringUtil.append2digits(buf, year/100);
+ StringUtil.append2digits(buf, year%100);
+
buf.append(' ');
StringUtil.append2digits(buf, hours);
buf.append(':');
@@ -185,12 +186,24 @@
/* ------------------------------------------------------------ */
/**
- * Format "EEE, dd-MMM-yy HH:mm:ss 'GMT'" for cookies
+ * Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
*/
public static void formatCookieDate(StringBuilder buf, long date)
{
__dateGenerator.get().formatCookieDate(buf,date);
}
+
+ /* ------------------------------------------------------------ */
+ /**
+ * Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
+ */
+ public static String formatCookieDate(long date)
+ {
+ StringBuilder buf = new StringBuilder(28);
+ formatCookieDate(buf, date);
+ return buf.toString();
+ }
+
/* ------------------------------------------------------------ */
@@ -276,14 +289,16 @@
- public final static String __01Jan1970 = formatDate(0).trim();
- public final static Buffer __01Jan1970_BUFFER = new ByteArrayBuffer(__01Jan1970);
+ public final static String __01Jan1970=formatCookieDate(0);
+ public final static Buffer __01Jan1970_BUFFER=new ByteArrayBuffer(__01Jan1970);
/* -------------------------------------------------------------- */
protected final ArrayList<Field> _fields = new ArrayList<Field>(20);
protected final HashMap<Buffer,Field> _bufferMap = new HashMap<Buffer,Field>(32);
protected int _revision;
+
+
/* ------------------------------------------------------------ */
/**
* Constructor.
Modified: jetty/branches/jetty-8/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java
===================================================================
--- jetty/branches/jetty-8/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -167,8 +167,13 @@
if (!_endp.isOpen())
throw new EofException();
flushBuffer();
- if (_content != null && _content.length()>0 || _bufferChunked)
- throw new IllegalStateException("FULL");
+ if (_content != null && _content.length()>0)
+ {
+ Buffer nc=_buffers.getBuffer(_content.length()+content.length());
+ nc.put(_content);
+ nc.put(content);
+ _content=nc;
+ }
}
_content = content;
@@ -186,7 +191,7 @@
// Make _content a direct buffer
_bypass = true;
}
- else
+ else if (!_bufferChunked)
{
// Yes - so we better check we have a buffer
if (_buffer == null)
@@ -483,6 +488,7 @@
HttpFields.Field transfer_encoding = null;
boolean keep_alive = false;
boolean close=false;
+ boolean content_type=false;
StringBuilder connection = null;
if (fields != null)
@@ -511,6 +517,7 @@
if (BufferUtil.isPrefix(MimeTypes.MULTIPART_BYTERANGES_BUFFER, field.getValueBuffer())) _contentLength = HttpTokens.SELF_DEFINING_CONTENT;
// write the field to the header buffer
+ content_type=true;
field.put(_header);
break;
@@ -654,7 +661,7 @@
{
// we have seen all the _content there is
_contentLength = _contentWritten;
- if (content_length == null)
+ if (content_length == null && (_method==null || _contentLength>0 || content_type ))
{
// known length but not actually set.
_header.put(HttpHeaders.CONTENT_LENGTH_BUFFER);
Modified: jetty/branches/jetty-8/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -369,7 +369,7 @@
fields.clear();
fields.addSetCookie("everything","value","domain","path",0,"comment",true,true,0);
- assertEquals("everything=value;Path=path;Domain=domain;Expires=Thu, 01 Jan 1970 00:00:00 GMT;Secure;HttpOnly",fields.getStringField("Set-Cookie"));
+ assertEquals("everything=value;Path=path;Domain=domain;Expires=Thu, 01-Jan-1970 00:00:00 GMT;Secure;HttpOnly",fields.getStringField("Set-Cookie"));
fields.clear();
fields.addSetCookie("ev erything","va lue","do main","pa th",1,"co mment",true,true,2);
Modified: jetty/branches/jetty-8/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -39,6 +39,28 @@
{
super(arg0);
}
+
+ public void testRequest()
+ throws Exception
+ {
+ Buffer bb=new ByteArrayBuffer(8096);
+ Buffer sb=new ByteArrayBuffer(1500);
+ HttpFields fields = new HttpFields();
+ ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
+ HttpGenerator hg = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
+
+ fields.add("Host","something");
+ fields.add("User-Agent","test");
+
+ hg.setRequest("GET","/index.html");
+ hg.setVersion(11);
+ hg.completeHeader(fields,true);
+ hg.complete();
+
+ assertTrue(endp.getOut().toString().indexOf("GET /index.html HTTP/1.1")==0);
+ assertTrue(endp.getOut().toString().indexOf("Content-Length")==-1);
+
+ }
public void testHTTP()
throws Exception
Modified: jetty/branches/jetty-8/jetty-io/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-io/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-io/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<name>Jetty :: IO Utility</name>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.io</bundle-symbolic-name>
+ </properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
@@ -52,6 +55,12 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
</project>
Modified: jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java
===================================================================
--- jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -28,4 +28,21 @@
*/
public boolean isReadyForDispatch();
+
+ /* ------------------------------------------------------------ */
+ /** Set the writable status.
+ * The writable status is considered next time the async scheduling
+ * is calculated.
+ *
+ * @param writable true if the endpoint is known to be writable or false
+ * if it is known to not be writable.
+ */
+ public void setWritable(boolean writable);
+
+ /* ------------------------------------------------------------ */
+ /** Schedule a write dispatch.
+ * Set the endpoint to not be writable and schedule a dispatch when
+ * it becomes writable.
+ */
+ public void scheduleWrite();
}
Modified: jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java
===================================================================
--- jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -15,12 +15,25 @@
import java.io.IOException;
+/* ------------------------------------------------------------ */
+/** Abstract Connection used by Jetty Connectors.
+ * <p>
+ * Jetty will call the handle method of a connection when there is work
+ * to be done on the connection. For blocking connections, this is soon
+ * as the connection is open and handle will keep being called until the
+ * connection is closed. For non-blocking connections, handle will only
+ * be called if there are bytes to be read or the connection becomes writable
+ * after being write blocked.
+ *
+ * @see org.eclipse.jetty.io.nio.SelectorManager
+ */
public interface Connection
{
/* ------------------------------------------------------------ */
/**
* Handle the connection.
- * @return The Connection to use for the next handling of the connection. This allows protocol upgrades.
+ * @return The Connection to use for the next handling of the connection.
+ * This allows protocol upgrades and support for CONNECT.
* @throws IOException
*/
Connection handle() throws IOException;
Modified: jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java
===================================================================
--- jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -4,11 +4,11 @@
// All rights reserved. This program and the accompanying materials
// are made available under the 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.io.nio;
@@ -29,8 +29,8 @@
/**
- *
*
+ *
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
@@ -41,9 +41,9 @@
protected final Socket _socket;
protected InetSocketAddress _local;
protected InetSocketAddress _remote;
-
+
/**
- *
+ *
*/
public ChannelEndPoint(ByteChannel channel)
{
@@ -51,23 +51,23 @@
this._channel = channel;
_socket=(channel instanceof SocketChannel)?((SocketChannel)channel).socket():null;
}
-
+
public boolean isBlocking()
{
return !(_channel instanceof SelectableChannel) || ((SelectableChannel)_channel).isBlocking();
}
-
+
public boolean blockReadable(long millisecs) throws IOException
{
return true;
}
-
+
public boolean blockWritable(long millisecs) throws IOException
{
return true;
}
- /*
+ /*
* @see org.eclipse.io.EndPoint#isOpen()
*/
public boolean isOpen()
@@ -139,7 +139,7 @@
{
throw new IOException("Not Implemented");
}
-
+
return len;
}
@@ -203,9 +203,9 @@
Buffer buf0 = header==null?null:header.buffer();
Buffer buf1 = buffer==null?null:buffer.buffer();
-
+
if (_channel instanceof GatheringByteChannel &&
- header!=null && header.length()!=0 && buf0 instanceof NIOBuffer &&
+ header!=null && header.length()!=0 && buf0 instanceof NIOBuffer &&
buffer!=null && buffer.length()!=0 && buf1 instanceof NIOBuffer)
{
final NIOBuffer nbuf0 = (NIOBuffer)buf0;
@@ -235,7 +235,7 @@
// do the gathering write.
length=(int)((GatheringByteChannel)_channel).write(_gather2);
-
+
int hl=header.length();
if (length>hl)
{
@@ -246,7 +246,7 @@
{
header.skip(length);
}
-
+
}
finally
{
@@ -267,8 +267,20 @@
}
else
{
- // TODO - consider copying buffers buffer and trailer into header if there is space!
-
+ if (header!=null)
+ {
+ if (buffer!=null && buffer.length()>0 && header.space()>buffer.length())
+ {
+ header.put(buffer);
+ buffer.clear();
+ }
+ if (trailer!=null && trailer.length()>0 && header.space()>trailer.length())
+ {
+ header.put(trailer);
+ trailer.clear();
+ }
+ }
+
// flush header
if (header!=null && header.length()>0)
length=flush(header);
@@ -284,7 +296,7 @@
trailer!=null && trailer.length()>0)
length+=flush(trailer);
}
-
+
return length;
}
@@ -298,50 +310,50 @@
/* ------------------------------------------------------------ */
- /*
+ /*
* @see org.eclipse.io.EndPoint#getLocalAddr()
*/
public String getLocalAddr()
{
if (_socket==null)
return null;
-
+
if (_local==null)
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
-
+
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
return StringUtil.ALL_INTERFACES;
-
+
return _local.getAddress().getHostAddress();
}
/* ------------------------------------------------------------ */
- /*
+ /*
* @see org.eclipse.io.EndPoint#getLocalHost()
*/
public String getLocalHost()
{
if (_socket==null)
return null;
-
+
if (_local==null)
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
-
+
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
return StringUtil.ALL_INTERFACES;
-
+
return _local.getAddress().getCanonicalHostName();
}
/* ------------------------------------------------------------ */
- /*
+ /*
* @see org.eclipse.io.EndPoint#getLocalPort()
*/
public int getLocalPort()
{
if (_socket==null)
return 0;
-
+
if (_local==null)
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
if (_local==null)
@@ -350,31 +362,31 @@
}
/* ------------------------------------------------------------ */
- /*
+ /*
* @see org.eclipse.io.EndPoint#getRemoteAddr()
*/
public String getRemoteAddr()
{
if (_socket==null)
return null;
-
+
if (_remote==null)
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
-
+
if (_remote==null)
return null;
return _remote.getAddress().getHostAddress();
}
/* ------------------------------------------------------------ */
- /*
+ /*
* @see org.eclipse.io.EndPoint#getRemoteHost()
*/
public String getRemoteHost()
{
if (_socket==null)
return null;
-
+
if (_remote==null)
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
@@ -384,14 +396,14 @@
}
/* ------------------------------------------------------------ */
- /*
+ /*
* @see org.eclipse.io.EndPoint#getRemotePort()
*/
public int getRemotePort()
{
if (_socket==null)
return 0;
-
+
if (_remote==null)
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
@@ -399,7 +411,7 @@
}
/* ------------------------------------------------------------ */
- /*
+ /*
* @see org.eclipse.io.EndPoint#getConnection()
*/
public Object getTransport()
@@ -410,7 +422,7 @@
/* ------------------------------------------------------------ */
public void flush()
throws IOException
- {
+ {
}
/* ------------------------------------------------------------ */
Modified: jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java
===================================================================
--- jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -29,6 +29,7 @@
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.thread.Timeout;
+import org.eclipse.jetty.util.thread.Timeout.Task;
/* ------------------------------------------------------------ */
@@ -750,7 +751,18 @@
// tick over the timers
_idleTimeout.tick(now);
- _timeout.tick(now);
+
+ _timeout.setNow(now);
+ Task task = _timeout.expired();
+ while (task!=null)
+ {
+ if (task instanceof Runnable)
+ dispatch((Runnable)task);
+ else
+ task.expired();
+
+ task = _timeout.expired();
+ }
}
catch (CancelledKeyException e)
{
@@ -783,6 +795,12 @@
}
/* ------------------------------------------------------------ */
+ /**
+ * @param task The task to timeout. If it implements Runnable, then
+ * expired will be called from a dispatched thread.
+ *
+ * @param timeoutMs
+ */
public void scheduleTimeout(Timeout.Task task, long timeoutMs)
{
_timeout.schedule(task, timeoutMs);
Modified: jetty/branches/jetty-8/jetty-jaspi/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-jaspi/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-jaspi/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-jaspi</artifactId>
<name>Jetty :: JASPI Security</name>
<description>Jetty security infrastructure</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.jaspi</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -39,14 +42,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
</plugin>
</plugins>
</build>
Modified: jetty/branches/jetty-8/jetty-jmx/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-jmx/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-jmx/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-jmx</artifactId>
<name>Jetty :: JMX Management</name>
<description>JMX management artifact for jetty.</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.jmx</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -52,6 +55,12 @@
</execution>
</executions>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-jmx/src/main/resources/org/eclipse/jetty/server/session/jmx/AbstractSessionManager-mbean.properties
===================================================================
--- jetty/branches/jetty-8/jetty-jmx/src/main/resources/org/eclipse/jetty/server/session/jmx/AbstractSessionManager-mbean.properties 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-jmx/src/main/resources/org/eclipse/jetty/server/session/jmx/AbstractSessionManager-mbean.properties 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,11 +8,17 @@
sessionCookie: The set session cookie
sessionDomain: The domain of the session cookie or null for the default
sessionPath: The path of the session cookie or null for the default
-sessions: The instantaneous number of sessions
sessionsTotal: The total number of sessions
sessionsMax: The maximum number of simultaneous sessions
sessionTimeMax: The maximum session lifetime in seconds
sessionTimeMean: The mean session lifetime in seconds
sessionTimeStdDev: The standard deviation of session lifetime in seconds
sessionIdPathParameterName: The name to use for URL session tracking
-resetStats(): Reset statistics
+statsReset(): Reset statistics
+sessions: Current instantaneous number of sessions
+sessionsMax: Maximum number of simultaneous sessions since statsReset() was called
+sessionsMin: Minimum number of simultaneous sessions since statsReset() was called
+sessionTimeMax: Maximum amount of time in seconds session remained valid since statsReset() was called
+sessionTimeTotal: Total amount of time in seconds sessions remained valid since statsReset() was called
+sessionTimeMean: Mean amount of time in seconds a session remained valid since statsReset() was called
+sessionTimeStdDev: Standard deviation of amount of time in seconds a session remained valid since statsReset() was called
\ No newline at end of file
Modified: jetty/branches/jetty-8/jetty-jndi/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-jndi/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-jndi/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-jndi</artifactId>
<name>Jetty :: JNDI Naming</name>
<description>JNDI spi impl for java namespace.</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.jndi</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -35,6 +38,12 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/META-INF/MANIFEST.MF
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/META-INF/MANIFEST.MF 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/META-INF/MANIFEST.MF 2010-04-06 18:17:57 UTC (rev 1472)
@@ -55,19 +55,13 @@
org.eclipse.jetty.xml;bundle-version="[8.0,
9)"
Bundle-RequiredExecutionEnvironment: J2SE-1.6
-Import-Package: javax.mail;resolution:=optional,
- javax.mail.event;resolution:=optional,
- javax.mail.internet;resolution:=optional,
- javax.mail.search;resolution:=optional,
- javax.mail.util;resolution:=optional,
- javax.naming;resolution:=optional,
- javax.naming.directory;resolution:=optional,
- javax.security.auth;resolution:=optional,
- javax.security.auth.callback;resolution:=optional,
- javax.security.auth.login;resolution:=optional,
- javax.security.auth.spi;resolution:=optional,
- javax.servlet,
- javax.servlet.http,
+Import-Package: javax.mail;version="1.4.0";resolution:=optional,
+ javax.mail.event;version="1.4.0";resolution:=optional,
+ javax.mail.internet;version="1.4.0";resolution:=optional,
+ javax.mail.search;version="1.4.0";resolution:=optional,
+ javax.mail.util;version="1.4.0";resolution:=optional,
+ javax.servlet;version="2.5.0",
+ javax.servlet.http;version="2.5.0",
javax.transaction;version="1.1.0";resolution:=optional,
javax.transaction.xa;version="1.1.0";resolution:=optional,
org.osgi.framework,
@@ -76,7 +70,6 @@
org.osgi.service.startlevel;version="1.0",
org.osgi.service.url;version="1.0.0",
org.osgi.util.tracker;version="1.3.0",
- org.xml.sax,
org.slf4j;resolution:=optional,
org.slf4j.spi;resolution:=optional,
org.slf4j.helpers;resolution:=optional
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -59,6 +59,23 @@
<!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
+ <Set name="Port"><Property name="jetty.port.ssl" default="8443" /></Set>
+ <Set name="maxIdleTime">30000</Set>
+ <Set name="Acceptors">2</Set>
+ <Set name="AcceptQueueSize">100</Set>
+ <Set name="Keystore"><Property name="jetty.home" default="." />/etc/keystore</Set>
+ <Set name="Password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
+ <Set name="KeyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
+ <Set name="truststore"><Property name="jetty.home" default="." />/etc/keystore</Set>
+ <Set name="trustPassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
+ </New>
+ </Arg>
+ </Call>
+
+
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- To add a HTTP blocking connector -->
<!-- mixin jetty-bio.xml: -->
@@ -133,6 +150,23 @@
</New>
</Arg>
</Call>
+ <!-- Providers of OSGi Apps -->
+ <Call name="addAppProvider">
+ <Arg>
+ <New class="org.eclipse.jetty.osgi.boot.OSGiAppProvider">
+ <Set name="monitoredDir"><Property name="jetty.home" default="." />/webapps</Set>
+ <Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
+ <Set name="scanInterval">5</Set>
+ <Set name="contextXmlDir"><Property name="jetty.home" default="." />/contexts</Set>
+ <!-- comma separated list of bundle symbolic names that
+ contain custom tag libraries (*.tld files)
+ if those bundles don't exist or can't be loaded no errors or warning will be issued!
+ this default value is to plug the tld files of the reference implementation of JSF -->
+ <Set name="tldBundles"><Property name="org.eclipse.jetty.osgi.tldsbundles" default="javax.faces.jsf-impl" /></Set>
+ </New>
+ </Arg>
+ </Call>
+
</New>
</Arg>
</Call>
@@ -241,5 +275,15 @@
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
+
+ <!-- jetty-jndi by default -->
+ <Call class="java.lang.System" name="setProperty">
+ <Arg>java.naming.factory.initial</Arg>
+ <Arg><SystemProperty name="java.naming.factory.initial" default="org.eclipse.jetty.jndi.InitialContextFactory"/></Arg>
+ </Call>
+ <Call class="java.lang.System" name="setProperty">
+ <Arg>java.naming.factory.url.pkgs</Arg>
+ <Arg><SystemProperty name="java.naming.factory.url.pkgs" default="org.eclipse.jetty.jndi"/></Arg>
+ </Call>
</Configure>
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -10,6 +10,9 @@
<artifactId>jetty-osgi-boot</artifactId>
<name>Jetty :: OSGi :: Boot</name>
<description>Jetty OSGi Boot bundle</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.boot</bundle-symbolic-name>
+ </properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
@@ -39,6 +42,11 @@
<configuration>
<tasks>
<replace file="target/classes/META-INF/MANIFEST.MF" token="Bundle-Version: 8.0.0.qualifier" value="Bundle-Version: ${parsedVersion.osgiVersion}" />
+ <copy todir="target/classes/jettyhome">
+ <fileset dir="jettyhome">
+ <exclude name="**/*.log" />
+ </fileset>
+ </copy>
</tasks>
</configuration>
<goals>
@@ -70,7 +78,13 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -27,6 +27,7 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceRegistration;
/**
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiAppProvider.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiAppProvider.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiAppProvider.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -46,6 +46,7 @@
private boolean _extractWars = false;
private boolean _parentLoaderPriority = false;
private String _defaultsDescriptor;
+ private String _tldBundles;
/**
* When a context file corresponds to a deployed bundle and is changed we
@@ -290,5 +291,23 @@
{
setMonitoredDir(contextsDir);
}
+
+ /**
+ * @param tldBundles Comma separated list of bundles that contain tld jars
+ * that should be setup on the jetty instances created here.
+ */
+ public void setTldBundles(String tldBundles)
+ {
+ _tldBundles = tldBundles;
+ }
+
+ /**
+ * @return The list of bundles that contain tld jars that should be setup
+ * on the jetty instances created here.
+ */
+ public String getTldBundles()
+ {
+ return _tldBundles;
+ }
}
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/OSGiWebappClassLoader.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/OSGiWebappClassLoader.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/OSGiWebappClassLoader.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -17,7 +17,12 @@
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.jar.JarFile;
@@ -59,7 +64,6 @@
static
{
addClassThatIdentifiesAJarThatMustBeRejected(HttpServlet.class);
- // addClassThatIdentifiesAJarThatMustBeRejected(HttpServlet.class);
}
private ClassLoader _osgiBundleClassLoader;
@@ -83,6 +87,46 @@
// TODO
}
+ @Override
+ public Enumeration<URL> getResources(String name) throws IOException
+ {
+ Enumeration<URL> osgiUrls = _osgiBundleClassLoader.getResources(name);
+ Enumeration<URL> urls = super.getResources(name);
+ if (_lookInOsgiFirst)
+ {
+ return Collections.enumeration(toList(osgiUrls, urls));
+ }
+ else
+ {
+ return Collections.enumeration(toList(urls, osgiUrls));
+ }
+ }
+
+ @Override
+ public URL getResource(String name)
+ {
+ if (_lookInOsgiFirst)
+ {
+ URL url = _osgiBundleClassLoader.getResource(name);
+ return url != null ? url : super.getResource(name);
+ }
+ else
+ {
+ URL url = super.getResource(name);
+ return url != null ? url : _osgiBundleClassLoader.getResource(name);
+ }
+ }
+
+ private List<URL> toList(Enumeration<URL> e, Enumeration<URL> e2)
+ {
+ List<URL> list = new ArrayList<URL>();
+ while (e!=null && e.hasMoreElements())
+ list.add(e.nextElement());
+ while (e2!=null && e2.hasMoreElements())
+ list.add(e2.nextElement());
+ return list;
+ }
+
/**
*
*/
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebappRegistrationHelper.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebappRegistrationHelper.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebappRegistrationHelper.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -28,7 +28,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.StringTokenizer;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
@@ -252,19 +251,18 @@
// makes sure there is access to all the jetty's bundles
File jettyHomeF = new File(jettyHome);
+ URLClassLoader libExtClassLoader = null;
try
{
- URLClassLoader libExtClassLoader = LibExtClassLoaderHelper.createLibEtcClassLoaderHelper(jettyHomeF,_server,JettyBootstrapActivator.class
- .getClassLoader());
- URL[] jarsWithTlds = getJarsWithTlds();
- _commonParentClassLoaderForWebapps = jarsWithTlds == null?libExtClassLoader:new TldLocatableURLClassloader(libExtClassLoader,getJarsWithTlds());
+ libExtClassLoader = LibExtClassLoaderHelper.createLibEtcClassLoaderHelper(jettyHomeF,_server,
+ JettyBootstrapActivator.class.getClassLoader());
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
- Thread.currentThread().setContextClassLoader(_commonParentClassLoaderForWebapps);
+ Thread.currentThread().setContextClassLoader(libExtClassLoader);
String jettyetc = System.getProperty(OSGiWebappConstants.SYS_PROP_JETTY_ETC_FILES,"etc/jetty.xml");
StringTokenizer tokenizer = new StringTokenizer(jettyetc,";,");
@@ -276,7 +274,7 @@
properties.put("jetty.host",System.getProperty("jetty.host",""));
properties.put("jetty.port",System.getProperty("jetty.port","8080"));
properties.put("jetty.port.ssl",System.getProperty("jetty.port.ssl","8443"));
-
+
while (tokenizer.hasMoreTokens())
{
String etcFile = tokenizer.nextToken().trim();
@@ -296,8 +294,7 @@
HandlerCollection handlers = new HandlerCollection();
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLogHandler requestLogHandler = new RequestLogHandler();
- handlers.setHandlers(new Handler[]
- { contexts, new DefaultHandler(), requestLogHandler });
+ handlers.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
_server.setHandler(handlers);
}
}
@@ -322,6 +319,18 @@
init();
+ //now that we have an app provider we can call the registration customizer.
+ try
+ {
+ URL[] jarsWithTlds = getJarsWithTlds();
+ _commonParentClassLoaderForWebapps = jarsWithTlds == null?libExtClassLoader:new TldLocatableURLClassloader(libExtClassLoader,getJarsWithTlds());
+ }
+ catch (MalformedURLException e)
+ {
+ e.printStackTrace();
+ }
+
+
_server.start();
}
catch (Throwable t)
@@ -345,20 +354,6 @@
*/
private void init()
{
-
- // [Hugues] if no jndi is setup let's do it.
- // we could also get the bundle for jetty-jndi and open the
- // corresponding properties file
- // instead of hardcoding the values: but they are unlikely to change.
- if (System.getProperty("java.naming.factory.initial") == null)
- {
- System.setProperty("java.naming.factory.initial","org.eclipse.jetty.jndi.InitialContextFactory");
- }
- if (System.getProperty("java.naming.factory.url.pkgs") == null)
- {
- System.setProperty("java.naming.factory.url.pkgs","org.eclipse.jetty.jndi");
- }
-
// Get the context handler
_ctxtHandler = (ContextHandlerCollection)_server.getChildHandlerByClass(ContextHandlerCollection.class);
@@ -770,7 +765,7 @@
ArrayList<URL> res = new ArrayList<URL>();
for (WebappRegistrationCustomizer regCustomizer : JSP_REGISTRATION_HELPERS)
{
- URL[] urls = regCustomizer.getJarsWithTlds(BUNDLE_FILE_LOCATOR_HELPER);
+ URL[] urls = regCustomizer.getJarsWithTlds(_provider, BUNDLE_FILE_LOCATOR_HELPER);
for (URL url : urls)
{
if (!res.contains(url))
@@ -793,6 +788,14 @@
{
// rfc66
wah.setAttribute(OSGiWebappConstants.RFC66_OSGI_BUNDLE_CONTEXT,contributor.getBundleContext());
+
+ //spring-dm-1.2.1 looks for the BundleContext as a different attribute.
+ //not a spec... but if we want to support
+ //org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext
+ //then we need to do this to:
+ wah.setAttribute("org.springframework.osgi.web." + BundleContext.class.getName(),
+ contributor.getBundleContext());
+
}
/**
@@ -856,6 +859,12 @@
// rfc-66:
context.setAttribute(OSGiWebappConstants.RFC66_OSGI_BUNDLE_CONTEXT,bundle.getBundleContext());
+ //spring-dm-1.2.1 looks for the BundleContext as a different attribute.
+ //not a spec... but if we want to support
+ //org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext
+ //then we need to do this to:
+ context.setAttribute("org.springframework.osgi.web." + BundleContext.class.getName(),
+ bundle.getBundleContext());
return context;
}
catch (FileNotFoundException e)
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/BundleClassLoaderHelper.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/BundleClassLoaderHelper.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/BundleClassLoaderHelper.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -12,6 +12,7 @@
// ========================================================================
package org.eclipse.jetty.osgi.boot.utils;
+import org.eclipse.jetty.osgi.boot.utils.internal.DefaultBundleClassLoaderHelper;
import org.osgi.framework.Bundle;
/**
@@ -35,6 +36,9 @@
/** The name of the custom implementation for this interface in a fragment. */
public static final String CLASS_NAME = "org.eclipse.jetty.osgi.boot.utils.BundleClassLoaderHelperImpl";
+ /** The default instance supports felix and equinox */
+ public static BundleClassLoaderHelper DEFAULT = new DefaultBundleClassLoaderHelper();
+
/**
* @return The classloader of a given bundle. Assuming the bundle is
* started.
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/BundleFileLocatorHelper.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/BundleFileLocatorHelper.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/BundleFileLocatorHelper.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -14,6 +14,7 @@
import java.io.File;
+import org.eclipse.jetty.osgi.boot.utils.internal.DefaultFileLocatorHelper;
import org.osgi.framework.Bundle;
/**
@@ -28,6 +29,10 @@
/** The name of the custom implementation for this interface in a fragment. */
public static final String CLASS_NAME = "org.eclipse.jetty.osgi.boot.utils.FileLocatorHelperImpl";
+ /** The default instance supports felix and equinox */
+ public static BundleFileLocatorHelper DEFAULT = new DefaultFileLocatorHelper();
+
+
/**
* Works with equinox, felix, nuxeo and probably more. Not exactly in the
* spirit of OSGi but quite necessary to support self-contained webapps and
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/WebappRegistrationCustomizer.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/WebappRegistrationCustomizer.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/WebappRegistrationCustomizer.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -14,6 +14,8 @@
import java.net.URL;
+import org.eclipse.jetty.osgi.boot.OSGiAppProvider;
+
/**
* Fix various shortcomings with the way jasper parses the tld files.
*/
@@ -47,6 +49,6 @@
* @return
* @throws Exception
*/
- URL[] getJarsWithTlds(BundleFileLocatorHelper fileLocator) throws Exception;
+ URL[] getJarsWithTlds(OSGiAppProvider provider, BundleFileLocatorHelper fileLocator) throws Exception;
}
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/PackageAdminServiceTracker.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/PackageAdminServiceTracker.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/PackageAdminServiceTracker.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -94,7 +94,8 @@
// find a convention to look for a class inside the fragment.
try
{
- Class<?> c = Class.forName(frag.getSymbolicName() + ".FragmentActivator");
+ String fragmentActivator = frag.getSymbolicName() + ".FragmentActivator";
+ Class<?> c = Class.forName(fragmentActivator);
if (c != null)
{
BundleActivator bActivator = (BundleActivator)c.newInstance();
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/META-INF/MANIFEST.MF
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/META-INF/MANIFEST.MF 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/META-INF/MANIFEST.MF 2010-04-06 18:17:57 UTC (rev 1472)
@@ -9,9 +9,46 @@
Import-Package: javax.el;version="2.2",
javax.servlet.jsp;version="2.2",
javax.servlet.jsp.el;version="2.2",
- javax.servlet.jsp.jstl.core;version="2.2",
- javax.servlet.jsp.jstl.fmt;version="2.2",
- javax.servlet.jsp.jstl.sql;version="2.2",
- javax.servlet.jsp.jstl.tlv;version="2.2",
javax.servlet.jsp.resources;version="2.2",
javax.servlet.jsp.tagext;version="2.2"
+ javax.servlet.jsp.jstl.core;version="1.2";resolution:=optional,
+ javax.servlet.jsp.jstl.fmt;version="1.2";resolution:=optional,
+ javax.servlet.jsp.jstl.sql;version="1.2";resolution:=optional,
+ javax.servlet.jsp.jstl.tlv;version="1.2";resolution:=optional,
+ com.sun.el;resolution:=optional,
+ com.sun.el.lang;resolution:=optional,
+ com.sun.el.parser;resolution:=optional,
+ com.sun.el.util;resolution:=optional,
+ javax.servlet.resources;version="3.0",
+ org.apache.jasper;version="2.2";resolution:=optional,
+ org.apache.jasper.compiler;version="2.2";resolution:=optional,
+ org.apache.jasper.compiler.tagplugin;version="2.2";resolution:=optional,
+ org.apache.jasper.runtime;version="2.2";resolution:=optional,
+ org.apache.jasper.security;version="2.2";resolution:=optional,
+ org.apache.jasper.servlet;version="2.2";resolution:=optional,
+ org.apache.jasper.tagplugins.jstl;version="2.2";resolution:=optional,
+ org.apache.jasper.util;version="2.2";resolution:=optional,
+ org.apache.jasper.xmlparser;version="2.2";resolution:=optional,
+ org.apache.taglibs.standard;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.extra.spath;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.functions;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.lang.jstl;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.lang.jstl.parser;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.lang.jstl.test;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.lang.jstl.test.beans;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.lang.support;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.resources;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.common.core;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.common.fmt;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.common.sql;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.common.xml;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.el.core;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.el.fmt;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.el.sql;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.el.xml;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.rt.core;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.rt.fmt;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.rt.sql;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tag.rt.xml;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tei;version="1.2.0";resolution:=optional,
+ org.apache.taglibs.standard.tlv;version="1.2.0";resolution:=optional
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -10,8 +10,15 @@
<artifactId>jetty-osgi-boot-jsp</artifactId>
<name>Jetty :: OSGi :: Boot JSP</name>
<description>Jetty OSGi Boot JSP bundle</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.boot.jsp</bundle-symbolic-name>
+ </properties>
<dependencies>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-deploy</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-boot</artifactId>
<version>${project.version}</version>
@@ -89,6 +96,12 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
Copied: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/PluggableWebAppRegistrationCustomizerImpl.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/PluggableWebAppRegistrationCustomizerImpl.java)
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/PluggableWebAppRegistrationCustomizerImpl.java (rev 0)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/PluggableWebAppRegistrationCustomizerImpl.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,160 @@
+// ========================================================================
+// Copyright (c) 2009-2010 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.osgi.boot.jasper;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.jetty.osgi.boot.OSGiAppProvider;
+import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
+import org.eclipse.jetty.osgi.boot.utils.WebappRegistrationCustomizer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.FrameworkUtil;
+
+/**
+ * Plug bundles that contains tld files so that jasper will discover them
+ * and set them up in jetty.
+ *
+ * For example: -Dorg.eclipse.jetty.osgi.tldbundles=org.springframework.web.servlet,com.opensymphony.module.sitemesh
+ * Otherwise use an attribute to the WebAppDeployer
+ * <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
+ * ....
+ * <Set name="tldBundles"><Property name="org.eclipse.jetty.osgi.tldsbundles" default="" /></Set>
+ * <New>
+ */
+public class PluggableWebAppRegistrationCustomizerImpl implements WebappRegistrationCustomizer
+{
+ /**
+ * To plug into jasper bundles that contain tld files
+ * please use a list of bundle's symbolic names:
+ * -Djetty.osgi.tldbundles=org.springframework.web.servlet,com.opensymphony.module.sitemesh
+ */
+ public static final String SYS_PROP_TLD_BUNDLES = "org.eclipse.jetty.osgi.tldbundles";
+
+ /**
+ * Union of the tld bundles defined system wide and the one defines as an attribute of the AppProvider.
+ * @param provider
+ * @return
+ */
+ private static Collection<String> getTldBundles(OSGiAppProvider provider)
+ {
+ String sysprop = System.getProperty(SYS_PROP_TLD_BUNDLES);
+ String att = (String)provider.getTldBundles();
+ if (sysprop == null && att == null)
+ {
+ return Collections.emptySet();
+ }
+ if (att == null)
+ {
+ att = sysprop;
+ }
+ else if (sysprop != null)
+ {
+ att = att + "," + sysprop;
+ }
+
+ Collection<String> tldbundles = new HashSet<String>();
+ StringTokenizer tokenizer = new StringTokenizer(att, ", \n\r\t", false);
+ while (tokenizer.hasMoreTokens())
+ {
+ tldbundles.add(tokenizer.nextToken());
+ }
+ return tldbundles;
+ }
+
+ /**
+ * @return The location of the jars that contain tld files.
+ * Jasper will discover them.
+ */
+ public URL[] getJarsWithTlds(OSGiAppProvider provider, BundleFileLocatorHelper locatorHelper) throws Exception
+ {
+ List<URL> urls = new ArrayList<URL>();
+ //naive way of finding those bundles.
+ //lots of assumptions: for example we assume a single version of each bundle that would contain tld files.
+ //this is probably good enough as those tlds are loaded system-wide on jetty.
+ //to do better than this we need to do it on a per webapp basis.
+ //probably using custom properties in the ContextHandler service
+ //and mirroring those in the MANIFEST.MF
+
+ Bundle[] bundles = FrameworkUtil.getBundle(PluggableWebAppRegistrationCustomizerImpl.class).getBundleContext().getBundles();
+ Collection<String> tldbundles = getTldBundles(provider);
+ for (Bundle bundle : bundles)
+ {
+ if (tldbundles.contains(bundle.getSymbolicName()))
+ {
+ registerTldBundle(locatorHelper, bundle, urls);
+ }
+ }
+
+ return urls.toArray(new URL[urls.size()]);
+
+ }
+
+ /**
+ * Resolves the bundle that contains tld files as a set of URLs that will be
+ * passed to jasper as a URLClassLoader later on.
+ * Usually that would be a single URL per bundle.
+ * But we do some more work if there are jars embedded in the bundle.
+ *
+ * The jasper TldScanner expects a URLClassloader to parse a jar for the /META-INF/*.tld it may contain. We place the bundles that we know contain such
+ * tag-libraries. Please note that it will work if and only if the bundle is a jar (!) Currently we just hardcode the bundle that contains the jstl
+ * implemenation.
+ *
+ * A workaround when the tld cannot be parsed with this method is to copy and paste it inside the WEB-INF of the webapplication where it is used.
+ *
+ * Support only 2 types of packaging for the bundle: - the bundle is a jar (recommended for runtime.) - the bundle is a folder and contain jars in the root
+ * and/or in the lib folder (nice for PDE developement situations) Unsupported: the bundle is a jar that embeds more jars.
+ *
+ * @param locatorHelper
+ * @param bundle
+ * @param urls
+ * @throws Exception
+ */
+ private void registerTldBundle(BundleFileLocatorHelper locatorHelper, Bundle bundle, List<URL> urls) throws Exception
+ {
+ File jasperLocation = locatorHelper.getBundleInstallLocation(bundle);
+ if (jasperLocation.isDirectory())
+ {
+ for (File f : jasperLocation.listFiles())
+ {
+ if (f.getName().endsWith(".jar") && f.isFile())
+ {
+ urls.add(f.toURI().toURL());
+ }
+ else if (f.isDirectory() && f.getName().equals("lib"))
+ {
+ for (File f2 : jasperLocation.listFiles())
+ {
+ if (f2.getName().endsWith(".jar") && f2.isFile())
+ {
+ urls.add(f2.toURI().toURL());
+ }
+ }
+ }
+ }
+ urls.add(jasperLocation.toURI().toURL());
+ }
+ else
+ {
+ urls.add(jasperLocation.toURI().toURL());
+ }
+
+ }
+
+}
\ No newline at end of file
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1,5 +1,5 @@
// ========================================================================
-// Copyright (c) 2009 Intalio, Inc.
+// Copyright (c) 2009-2010 Intalio, Inc.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
@@ -16,6 +16,7 @@
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashSet;
import javax.servlet.Servlet;
import javax.servlet.jsp.JspContext;
@@ -26,6 +27,7 @@
import org.apache.jasper.runtime.TldScanner;
import org.apache.jasper.xmlparser.ParserUtils;
import org.eclipse.jetty.osgi.boot.JettyBootstrapActivator;
+import org.eclipse.jetty.osgi.boot.OSGiAppProvider;
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
import org.eclipse.jetty.osgi.boot.utils.WebappRegistrationCustomizer;
import org.osgi.framework.Bundle;
@@ -36,10 +38,36 @@
/**
* Fix various shortcomings with the way jasper parses the tld files.
+ * Plugs the JSTL tlds assuming that they are packaged with the bundle that contains the JSTL classes.
+ *
*/
public class WebappRegistrationCustomizerImpl implements WebappRegistrationCustomizer
{
+ /**
+ * Default name of a class that belongs to the jstl bundle.
+ * From that class we locate the corresponding bundle and register it
+ * as a bundle that contains tld files.
+ */
+ private static String DEFAULT_JSTL_BUNDLE_CLASS = "org.apache.taglibs.standard.tag.el.core.WhenTag";
+ //used to be "org.apache.jasper.runtime.JspFactoryImpl" but now
+ //the standard tag library implementation are stored in a separate bundle.
+
+ //DISABLED please use the tld bundle argument for the OSGiAppProvider
+// /**
+// * Default name of a class that belongs to the bundle where the Java server Faces tld files are defined.
+// * This is the sun's reference implementation.
+// */
+// private static String DEFAUT_JSF_IMPL_CLASS = "com.sun.faces.config.ConfigureListener";
+
+ /**
+ * Default jsp factory implementation.
+ * Idally jasper is osgified and we can use services.
+ * In the mean time we statically set the jsp factory implementation.
+ * bug #299733
+ */
+ private static String DEFAULT_JSP_FACTORY_IMPL_CLASS = "org.apache.jasper.runtime.JspFactoryImpl";
+
public WebappRegistrationCustomizerImpl()
{
fixupDtdResolution();
@@ -66,7 +94,7 @@
//however its bundles does not import the jasper package
//so it fails. let's help things out:
fact = (JspFactory)JettyBootstrapActivator.class.getClassLoader()
- .loadClass("org.apache.jasper.runtime.JspFactoryImpl").newInstance();
+ .loadClass(DEFAULT_JSP_FACTORY_IMPL_CLASS).newInstance();
JspFactory.setDefaultFactory(fact);
}
@@ -93,37 +121,61 @@
* @return
* @throws Exception
*/
- public URL[] getJarsWithTlds(BundleFileLocatorHelper locatorHelper) throws Exception
+ public URL[] getJarsWithTlds(OSGiAppProvider provider, BundleFileLocatorHelper locatorHelper) throws Exception
{
- Bundle jasperBundler = FrameworkUtil.getBundle(TldScanner.class);
- File jasperLocation = locatorHelper.getBundleInstallLocation(jasperBundler);
- if (jasperLocation.isDirectory())
- {
- // try to find the jar files inside this folder
- ArrayList<URL> urls = new ArrayList<URL>();
- for (File f : jasperLocation.listFiles())
- {
- if (f.getName().endsWith(".jar") && f.isFile())
- {
- urls.add(f.toURI().toURL());
- }
- else if (f.isDirectory() && f.getName().equals("lib"))
- {
- for (File f2 : jasperLocation.listFiles())
- {
- if (f2.getName().endsWith(".jar") && f2.isFile())
- {
- urls.add(f2.toURI().toURL());
- }
- }
- }
- }
- return urls.toArray(new URL[urls.size()]);
- }
- else
- {
- return new URL[] { jasperLocation.toURI().toURL() };
- }
+ HashSet<Class<?>> classesToAddToTheTldBundles = new HashSet<Class<?>>();
+
+ //Look for the jstl bundle
+ //We assume the jstl's tlds are defined there.
+ //We assume that the jstl bundle is imported by this bundle
+ //So we can look for this class using this bundle's classloader:
+ Class<?> jstlClass = WebappRegistrationCustomizerImpl.class.getClassLoader().loadClass(DEFAULT_JSTL_BUNDLE_CLASS);
+
+ classesToAddToTheTldBundles.add(jstlClass);
+
+// //should we also take care of the JSF?
+// try
+// {
+// jstlClass = WebappRegistrationCustomizerImpl.class.getClassLoader().loadClass(DEFAUT_JSF_IMPL_CLASS);
+// classesToAddToTheTldBundles.add(jstlClass);
+// }
+// catch (Throwable t)
+// {
+// //never mind we can live without JSF it is optional.
+// }
+ ArrayList<URL> urls = new ArrayList<URL>();
+ for (Class<?> cl : classesToAddToTheTldBundles)
+ {
+ Bundle tldBundle = FrameworkUtil.getBundle(cl);
+ File tldBundleLocation = locatorHelper.getBundleInstallLocation(tldBundle);
+ if (tldBundleLocation.isDirectory())
+ {
+ // try to find the jar files inside this folder
+ for (File f : tldBundleLocation.listFiles())
+ {
+ if (f.getName().endsWith(".jar") && f.isFile())
+ {
+ urls.add(f.toURI().toURL());
+ }
+ else if (f.isDirectory() && f.getName().equals("lib"))
+ {
+ for (File f2 : tldBundleLocation.listFiles())
+ {
+ if (f2.getName().endsWith(".jar") && f2.isFile())
+ {
+ urls.add(f2.toURI().toURL());
+ }
+ }
+ }
+ }
+
+ }
+ else
+ {
+ urls.add(tldBundleLocation.toURI().toURL());
+ }
+ }
+ return urls.toArray(new URL[urls.size()]);
}
/**
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp/FragmentActivator.java
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp/FragmentActivator.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp/FragmentActivator.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -13,6 +13,7 @@
package org.eclipse.jetty.osgi.boot.jsp;
import org.eclipse.jetty.osgi.boot.internal.webapp.WebappRegistrationHelper;
+import org.eclipse.jetty.osgi.boot.jasper.PluggableWebAppRegistrationCustomizerImpl;
import org.eclipse.jetty.osgi.boot.jasper.WebappRegistrationCustomizerImpl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -36,6 +37,12 @@
*/
public void start(BundleContext context) throws Exception {
WebappRegistrationHelper.JSP_REGISTRATION_HELPERS.add(new WebappRegistrationCustomizerImpl());
+ WebappRegistrationHelper.JSP_REGISTRATION_HELPERS.add(new PluggableWebAppRegistrationCustomizerImpl());
+// try {
+// FragmentActivator.class.getClassLoader().loadClass("does.not.exist");
+// } catch (Throwable t) {
+// t.printStackTrace();
+// }
}
/**
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-logback/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-logback/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-logback/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -7,9 +7,12 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.osgi</groupId>
- <artifactId>org.eclipse.jetty.osgi.boot.logback</artifactId>
+ <artifactId>jetty-osgi-boot-logback</artifactId>
<name>Jetty :: OSGi :: Boot Logback</name>
<description>Jetty OSGi Boot Logback bundle</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.boot.logback</bundle-symbolic-name>
+ </properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.osgi</groupId>
@@ -60,7 +63,7 @@
<phase>process-resources</phase>
<configuration>
<tasks>
- <replace file="target/classes/META-INF/MANIFEST.MF" token="Bundle-Version: 7.0.1.qualifier" value="Bundle-Version: ${parsedVersion.osgiVersion}" />
+ <replace file="target/classes/META-INF/MANIFEST.MF" token="Bundle-Version: 8.0.0.qualifier" value="Bundle-Version: ${parsedVersion.osgiVersion}" />
</tasks>
</configuration>
<goals>
@@ -92,8 +95,14 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-warurl/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-warurl/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-boot-warurl/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -10,6 +10,9 @@
<artifactId>jetty-osgi-boot-warurl</artifactId>
<name>Jetty :: OSGi :: Boot :: Warurl</name>
<description>Jetty OSGi Boot-Warurl bundle</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.boot.warurl</bundle-symbolic-name>
+ </properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
@@ -62,8 +65,14 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: jetty/branches/jetty-8/jetty-osgi/jetty-osgi-httpservice/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/jetty-osgi-httpservice/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/jetty-osgi-httpservice/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -10,6 +10,9 @@
<artifactId>jetty-httpservice</artifactId>
<name>Jetty :: OSGi :: HttpService</name>
<description>Jetty OSGi HttpService bundle</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.httpservice</bundle-symbolic-name>
+ </properties>
<dependencies>
<dependency>
<groupId>org.eclipse.equinox.http</groupId>
@@ -35,6 +38,9 @@
<configuration>
<tasks>
<replace file="target/classes/META-INF/MANIFEST.MF" token="Bundle-Version: 8.0.0.qualifier" value="Bundle-Version: ${parsedVersion.osgiVersion}" />
+ <copy todir="target/classes/contexts">
+ <fileset dir="contexts" />
+ </copy>
</tasks>
</configuration>
<goals>
@@ -66,8 +72,14 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: jetty/branches/jetty-8/jetty-osgi/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-osgi/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-osgi/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -25,7 +25,7 @@
<module>jetty-osgi-boot-logback</module>
<module>jetty-osgi-boot-warurl</module>
<module>jetty-osgi-httpservice</module>
- <module>example-jetty-osgi</module>
+ <!-- module>example-jetty-osgi</module -->
</modules>
<build>
<resources>
Modified: jetty/branches/jetty-8/jetty-plus/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-plus/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-plus/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-plus</artifactId>
<name>Jetty :: Plus</name>
<description>Jetty JavaEE style services</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.plus</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<!--
@@ -26,7 +29,7 @@
<configuration>
<instructions>
<_versionpolicy> </_versionpolicy>
- <Import-Package>javax.servlet.*;version="[3.0,4.0)",javax.transaction.*;version="[1.1,1.2)",*</Import-Package>
+ <Import-Package>!javax.sql.*;!javax.security.*;!javax.naming.*;javax.servlet.*;version="[3.0,4.0)",javax.transaction.*;version="[1.1,1.2)",*</Import-Package>
</instructions>
</configuration>
</execution>
@@ -45,14 +48,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -71,6 +66,12 @@
</execution>
</executions>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-policy/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-policy/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-policy/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -12,11 +12,43 @@
<properties>
<jetty.test.policy>1.0</jetty.test.policy>
<jetty.test.policy.loc>target/test-policy</jetty.test.policy.loc>
+ <bundle-symbolic-name>${project.groupId}.policy</bundle-symbolic-name>
</properties>
<build>
<plugins>
<plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${felix.bundle.version}</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>generate-manifest</id>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ <configuration>
+ <instructions>
+ <Export-Package>org.eclipse.jetty.policy.*</Export-Package>
+ </instructions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!--
+ Required for OSGI
+ -->
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
@@ -79,6 +111,12 @@
</execution>
</executions>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-rewrite/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-rewrite/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-rewrite/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-rewrite</artifactId>
<name>Jetty :: Rewrite Handler</name>
<description>Jetty Rewrite Handler</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.rewrite</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -52,6 +55,12 @@
</execution>
</executions>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RedirectPatternRule.java
===================================================================
--- jetty/branches/jetty-8/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RedirectPatternRule.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RedirectPatternRule.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -49,7 +49,7 @@
*/
public String apply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException
{
- response.sendRedirect(_location);
+ response.sendRedirect(response.encodeRedirectURL(_location));
return target;
}
Modified: jetty/branches/jetty-8/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RedirectRegexRule.java
===================================================================
--- jetty/branches/jetty-8/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RedirectRegexRule.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RedirectRegexRule.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -57,7 +57,7 @@
target=target.replaceAll("\\$"+g,group);
}
- response.sendRedirect(target);
+ response.sendRedirect(response.encodeRedirectURL(target));
return target;
}
}
Modified: jetty/branches/jetty-8/jetty-security/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-security/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-security/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-security</artifactId>
<name>Jetty :: Security</name>
<description>Jetty security infrastructure</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.security</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -45,14 +48,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
</plugin>
</plugins>
</build>
Modified: jetty/branches/jetty-8/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java
===================================================================
--- jetty/branches/jetty-8/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -62,7 +62,7 @@
public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
{
- if (mandatory)
+ if (!mandatory)
return _deferred;
HttpServletRequest request = (HttpServletRequest)req;
@@ -114,8 +114,9 @@
digest.qop = tok;
else if ("uri".equalsIgnoreCase(name))
digest.uri = tok;
- else if ("response".equalsIgnoreCase(name)) digest.response = tok;
- break;
+ else if ("response".equalsIgnoreCase(name))
+ digest.response = tok;
+ name=null;
}
}
}
Modified: jetty/branches/jetty-8/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java
===================================================================
--- jetty/branches/jetty-8/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -154,7 +154,7 @@
if (uri==null)
uri=URIUtil.SLASH;
- mandatory|=uri.endsWith(__J_SECURITY_CHECK);
+ mandatory|=isJSecurityCheck(uri);
if (!mandatory)
return _deferred;
@@ -166,7 +166,7 @@
try
{
// Handle a request for authentication.
- if (uri.endsWith(__J_SECURITY_CHECK))
+ if (isJSecurityCheck(uri))
{
final String username = request.getParameter(__J_USERNAME);
final String password = request.getParameter(__J_PASSWORD);
@@ -213,7 +213,7 @@
}
else
{
- response.sendRedirect(URIUtil.addPaths(request.getContextPath(),_formErrorPage));
+ response.sendRedirect(response.encodeRedirectURL(URIUtil.addPaths(request.getContextPath(),_formErrorPage)));
}
return Authentication.SEND_FAILURE;
@@ -260,7 +260,7 @@
}
else
{
- response.sendRedirect(URIUtil.addPaths(request.getContextPath(),_formLoginPage));
+ response.sendRedirect(response.encodeRedirectURL(URIUtil.addPaths(request.getContextPath(),_formLoginPage)));
}
return Authentication.SEND_CONTINUE;
@@ -275,8 +275,22 @@
throw new ServerAuthException(e);
}
}
-
+
/* ------------------------------------------------------------ */
+ public boolean isJSecurityCheck(String uri)
+ {
+ int jsc = uri.indexOf(__J_SECURITY_CHECK);
+
+ if (jsc<0)
+ return false;
+ int e=jsc+__J_SECURITY_CHECK.length();
+ if (e==uri.length())
+ return true;
+ char c = uri.charAt(e);
+ return c==';'||c=='#'||c=='/'||c=='?';
+ }
+
+ /* ------------------------------------------------------------ */
public boolean isLoginOrErrorPage(String pathInContext)
{
return pathInContext != null && (pathInContext.equals(_formErrorPath) || pathInContext.equals(_formLoginPath));
Modified: jetty/branches/jetty-8/jetty-security/src/test/java/org/eclipse/jetty/security/ConstraintTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-security/src/test/java/org/eclipse/jetty/security/ConstraintTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-security/src/test/java/org/eclipse/jetty/security/ConstraintTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -301,7 +301,6 @@
response = _connector.getResponses("GET /ctx/testLoginPage HTTP/1.0\r\n"+
"Cookie: JSESSIONID=" + session + "\r\n" +
"\r\n");
- System.err.println(response);
assertTrue(response.indexOf(" 200 OK") > 0);
assertTrue(response.indexOf("URI=/ctx/testLoginPage") > 0);
@@ -335,6 +334,58 @@
assertTrue(response.indexOf("!role") > 0);
}
+ public void testFormNoCookies()
+ throws Exception
+ {
+ _security.setAuthenticator(new FormAuthenticator("/testLoginPage","/testErrorPage",false));
+ _security.setStrict(false);
+ _server.start();
+
+ String response;
+
+ response = _connector.getResponses("GET /ctx/noauth/info HTTP/1.0\r\n\r\n");
+ assertTrue(response.startsWith("HTTP/1.1 200 OK"));
+
+ response = _connector.getResponses("GET /ctx/forbid/info HTTP/1.0\r\n\r\n");
+ assertTrue(response.startsWith("HTTP/1.1 403 Forbidden"));
+
+ response = _connector.getResponses("GET /ctx/auth/info HTTP/1.0\r\n\r\n");
+ assertTrue(response.indexOf(" 302 Found") > 0);
+ assertTrue(response.indexOf("/ctx/testLoginPage") > 0);
+ int jsession=response.indexOf(";jsessionid=");
+ String session = response.substring(jsession + 12, response.indexOf("\r\n",jsession));
+
+ response = _connector.getResponses("GET /ctx/testLoginPage;jsessionid="+session+";other HTTP/1.0\r\n"+
+ "\r\n");
+ assertTrue(response.indexOf(" 200 OK") > 0);
+ assertTrue(response.indexOf("URI=/ctx/testLoginPage") > 0);
+
+ response = _connector.getResponses("POST /ctx/j_security_check;jsessionid="+session+";other HTTP/1.0\r\n" +
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
+ "Content-Length: 31\r\n" +
+ "\r\n" +
+ "j_username=user&j_password=wrong\r\n");
+ assertTrue(response.indexOf("Location") > 0);
+
+ response = _connector.getResponses("POST /ctx/j_security_check;jsessionid="+session+";other HTTP/1.0\r\n" +
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
+ "Content-Length: 35\r\n" +
+ "\r\n" +
+ "j_username=user&j_password=password\r\n");
+ assertTrue(response.startsWith("HTTP/1.1 302 "));
+ assertTrue(response.indexOf("Location") > 0);
+ assertTrue(response.indexOf("/ctx/auth/info") > 0);
+
+ response = _connector.getResponses("GET /ctx/auth/info;jsessionid="+session+";other HTTP/1.0\r\n" +
+ "\r\n");
+ assertTrue(response.startsWith("HTTP/1.1 200 OK"));
+
+ response = _connector.getResponses("GET /ctx/admin/info;jsessionid="+session+";other HTTP/1.0\r\n" +
+ "\r\n");
+ assertTrue(response.startsWith("HTTP/1.1 403"));
+ assertTrue(response.indexOf("!role") > 0);
+ }
+
public void testStrictBasic()
throws Exception
{
Modified: jetty/branches/jetty-8/jetty-server/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-server/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -9,6 +9,9 @@
<name>Jetty :: Server Core</name>
<description>The core jetty server artifact.</description>
<url>${jetty.url}</url>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.server</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -57,14 +60,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Copied: jetty/branches/jetty-8/jetty-server/src/main/config/etc/jetty-ipaccess.xml (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-server/src/main/config/etc/jetty-ipaccess.xml)
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/config/etc/jetty-ipaccess.xml (rev 0)
+++ jetty/branches/jetty-8/jetty-server/src/main/config/etc/jetty-ipaccess.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
+
+<!-- =============================================================== -->
+<!-- Mixin the Statistics Handler -->
+<!-- =============================================================== -->
+
+
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+
+ <Get id="oldhandler" name="handler"/>
+
+ <Set name="handler">
+ <New id="IPAccessHandler" class="org.eclipse.jetty.server.handler.IPAccessHandler">
+ <Set name="handler"><Ref id="oldhandler"/></Set>
+ <Set name="white">
+ <Array type="String">
+ <Item>127.0.0.1</Item>
+ <Item>127.0.0.2/*.html</Item>
+ </Array>
+ </Set>
+ <Set name="black">
+ <Array type="String">
+ <Item>127.0.0.1/blacklisted</Item>
+ <Item>127.0.0.2/black.html</Item>
+ </Array>
+ </Set>
+ </New>
+ </Set>
+
+</Configure>
Modified: jetty/branches/jetty-8/jetty-server/src/main/config/etc/jetty.xml
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/config/etc/jetty.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/config/etc/jetty.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -16,20 +16,11 @@
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
- <!-- Default queued blocking threadpool
- -->
+ <!-- Default queued blocking threadpool -->
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">200</Set>
</New>
-
- <!-- Optional Java 5 bounded threadpool with job queue
- <New class="org.eclipse.jetty.util.thread.ExecutorThreadPool">
- <Arg name="coreSize" type="int">25</Arg>
- <Arg name="maxSize" type="int">50</Arg>
- <Arg name="maxIdleMs" type="long">30000</Arg>
- </New>
- -->
</Set>
@@ -137,66 +128,8 @@
</Arg>
</Call>
- <!-- =========================================================== -->
- <!-- Configure the context deployer -->
- <!-- A context deployer will deploy contexts described in -->
- <!-- configuration files discovered in a directory. -->
- <!-- The configuration directory can be scanned for hot -->
- <!-- deployments at the configured scanInterval. -->
- <!-- -->
- <!-- This deployer is configured to deploy contexts configured -->
- <!-- in the $JETTY_HOME/contexts directory -->
- <!-- -->
- <!-- =========================================================== -->
- <!--
- <Call name="addBean">
- <Arg>
- <New class="org.eclipse.jetty.deploy.ContextDeployer">
- <Set name="contexts"><Ref id="Contexts"/></Set>
- <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set>
- <Set name="scanInterval">5</Set>
- <Call name="setAttribute">
- <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
- <Arg>.*/servlet-api-[^/]*\.jar$</Arg>
- </Call>
- </New>
- </Arg>
- </Call>
- -->
<!-- =========================================================== -->
- <!-- Configure the webapp deployer. -->
- <!-- A webapp deployer will deploy standard webapps discovered -->
- <!-- in a directory at startup, without the need for additional -->
- <!-- configuration files. It does not support hot deploy or -->
- <!-- non standard contexts (see ContextDeployer above). -->
- <!-- -->
- <!-- This deployer is configured to deploy webapps from the -->
- <!-- $JETTY_HOME/webapps directory -->
- <!-- -->
- <!-- Normally only one type of deployer need be used. -->
- <!-- -->
- <!-- =========================================================== -->
- <!--
- <Call name="addBean">
- <Arg>
- <New class="org.eclipse.jetty.deploy.WebAppDeployer">
- <Set name="contexts"><Ref id="Contexts"/></Set>
- <Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/webapps</Set>
- <Set name="parentLoaderPriority">false</Set>
- <Set name="extract">true</Set>
- <Set name="allowDuplicates">false</Set>
- <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
- <Call name="setAttribute">
- <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
- <Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
- </Call>
- </New>
- </Arg>
- </Call>
- -->
-
- <!-- =========================================================== -->
<!-- Configure Authentication Login Service -->
<!-- Realms may be configured for the entire server here, or -->
<!-- they can be configured for a specific web app in a context -->
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -664,33 +664,38 @@
protected void scheduleTimeout()
{
EndPoint endp=_connection.getEndPoint();
- if (endp.isBlocking())
+ if (_timeoutMs>0)
{
- synchronized(this)
+ if (endp.isBlocking())
{
- _expireAt = System.currentTimeMillis()+_timeoutMs;
- long wait=_timeoutMs;
- while (_expireAt>0 && wait>0)
+ synchronized(this)
{
- try
+ _expireAt = System.currentTimeMillis()+_timeoutMs;
+ long wait=_timeoutMs;
+ while (_expireAt>0 && wait>0)
{
- this.wait(wait);
+ try
+ {
+ this.wait(wait);
+ }
+ catch (InterruptedException e)
+ {
+ Log.ignore(e);
+ }
+ wait=_expireAt-System.currentTimeMillis();
}
- catch (InterruptedException e)
+
+ if (_expireAt>0 && wait<=0)
{
- Log.ignore(e);
+ expired();
}
- wait=_expireAt-System.currentTimeMillis();
- }
-
- if (_expireAt>0 && wait<=0)
- {
- expired();
- }
- }
+ }
+ }
+ else
+ {
+ _connection.scheduleTimeout(_event._timeout,_timeoutMs);
+ }
}
- else
- _connection.scheduleTimeout(_event._timeout,_timeoutMs);
}
/* ------------------------------------------------------------ */
@@ -962,19 +967,29 @@
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
- public class AsyncEventState extends AsyncEvent
+ public class AsyncTimeout extends Timeout.Task implements Runnable
{
- private final ServletContext _suspendedContext;
- private ServletContext _dispatchContext;
- private String _path;
- private Timeout.Task _timeout= new Timeout.Task()
- {
@Override
public void expired()
{
AsyncContinuation.this.expired();
}
- };
+
+ @Override
+ public void run()
+ {
+ AsyncContinuation.this.expired();
+ }
+ }
+
+ /* ------------------------------------------------------------ */
+ /* ------------------------------------------------------------ */
+ public class AsyncEventState extends AsyncEvent
+ {
+ private final ServletContext _suspendedContext;
+ private ServletContext _dispatchContext;
+ private String _path;
+ private Timeout.Task _timeout= new AsyncTimeout();
public AsyncEventState(ServletContext context, ServletRequest request, ServletResponse response)
{
@@ -1001,7 +1016,5 @@
{
return _path;
}
-
-
}
}
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -40,6 +40,7 @@
import org.eclipse.jetty.http.HttpVersions;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.http.Parser;
+import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
@@ -71,7 +72,19 @@
* The connection state is held by 3 separate state machines: The request state, the
* response state and the continuation state. All three state machines must be driven
* to completion for every request, and all three can complete in any order.
- *
+ * </p>
+ * <p>
+ * The HttpConnection support protocol upgrade. If on completion of a request, the
+ * response code is 101 (switch protocols), then the org.eclipse.jetty.io.Connection
+ * request attribute is checked to see if there is a new Connection instance. If so,
+ * the new connection is returned from {@link #handle()} and is used for future
+ * handling of the underlying connection. Note that for switching protocols that
+ * don't use 101 responses (eg CONNECT), the response should be sent and then the
+ * status code changed to 101 before returning from the handler. Implementors
+ * of new Connection types should be careful to extract any buffered data from
+ * (HttpParser)http.getParser()).getHeaderBuffer() and
+ * (HttpParser)http.getParser()).getBodyBuffer() to initialise their new connection.
+ * </p>
*
*/
public class HttpConnection implements Connection
@@ -480,8 +493,8 @@
Log.debug("return with suspended request");
more_in_buffer=false;
}
- else if (_generator.isCommitted() && !_generator.isComplete() && _endp instanceof SelectChannelEndPoint) // TODO remove SelectChannel dependency
- ((SelectChannelEndPoint)_endp).setWritable(false);
+ else if (_generator.isCommitted() && !_generator.isComplete() && _endp instanceof AsyncEndPoint)
+ ((AsyncEndPoint)_endp).setWritable(false);
}
}
}
@@ -630,10 +643,12 @@
if (_expect100Continue)
{
- // Continue not sent so don't parse any content
+ Log.debug("100 continues not sent");
+ // We didn't send 100 continues, but the latest interpretation
+ // of the spec (see httpbis) is that the client will either
+ // send the body anyway, or close. So we no longer need to
+ // do anything special here.
_expect100Continue = false;
- if (_parser instanceof HttpParser)
- ((HttpParser)_parser).setState(HttpParser.STATE_END);
}
if(_endp.isOpen())
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1354,6 +1354,7 @@
_requestedSessionId=null;
_requestedSessionIdFromCookie=false;
_session=null;
+ _sessionManager=null;
_requestURI=null;
_scope=null;
_scheme=URIUtil.HTTP;
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -724,7 +724,7 @@
int i1=_contentType.indexOf("charset=",i0);
if (i1<0)
{
- _contentType = _contentType+" charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
+ _contentType = _contentType+";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
}
else
{
@@ -849,24 +849,24 @@
}
else
{
- _contentType=_mimeType+";charset="+_characterEncoding;
+ _contentType=_mimeType+"charset="+_characterEncoding;
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
}
}
else
{
- _contentType=_mimeType+";charset="+_characterEncoding;
+ _contentType=_mimeType+"charset="+_characterEncoding;
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
}
}
else if (i2<0)
{
- _contentType=contentType.substring(0,i1)+" charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
+ _contentType=contentType.substring(0,i1)+";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
}
else
{
- _contentType=contentType.substring(0,i1)+contentType.substring(i2)+" charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
+ _contentType=contentType.substring(0,i1)+contentType.substring(i2)+";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
}
}
@@ -912,7 +912,7 @@
else // No encoding in the params.
{
_cachedMimeType=null;
- _contentType=_characterEncoding==null?contentType:contentType+" charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
+ _contentType=_characterEncoding==null?contentType:contentType+";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
_connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType);
}
}
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1111,7 +1111,7 @@
getServer().getContainer().removeBean(old);
if (value!=null)
{
- _logger.info("Managing "+name);
+ if (_logger.isDebugEnabled()) _logger.debug("Managing "+name);
getServer().getContainer().addBean(value);
}
}
Copied: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java)
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java (rev 0)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,200 @@
+// ========================================================================
+// Copyright (c) 2010 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.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;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.http.HttpStatus;
+import org.eclipse.jetty.http.PathMap;
+import org.eclipse.jetty.io.EndPoint;
+import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.Request;
+
+
+/**
+ * IP Access Handler
+ * <p>
+ * Control access to the wrapped handler by the real remote IP.
+ * The real IP of the connection is used (not the IP reported in the forwarded for headers),
+ * as this cannot be as easily forged.
+ * <p>
+ * Control is provided by white/black lists of both internet addresses and URIs.
+ * Internet addresses may be absolute (eg 10.1.2.3) or a prefix pattern (eg 10.1.3. ).
+ * URI patterns follow the servlet specification for simple prefix and suffix wild cards.
+ * <p>
+ * An empty white list is treated as match all. If there is at least one entry in the
+ * white list, then a request must match a white list entry. Black list entries are always
+ * appied, so that even if an entry matches the white list, a black list entry will override.
+ * </p>
+ * <p>
+ * Examples of match specifications are:
+ * <ul>
+ * <li>10.1.2.3 - all requests from IP 10.1.2.3
+ * <li>10.1.2.3/foo/bar - all requests from IP 10.1.2.3 to URI /foo/bar
+ * <li>10.1.2.3/foo/* - all requests from IP 10.1.2.3 to URIs starting with /foo/
+ * <li>10.1.2.3/*.html - all requests from IP 10.1.2.3 to URIs ending with .html
+ * <li>10.1. - all requests from IPs starting with 10.1.
+ * <li>10.1./foo/bar - all requests from IPs starting with 10.1. to URI /foo/bar
+ * <li>10.1./foo/* - all requests from IPs starting with 10.1. to URIs starting with /foo/
+ * </ul>
+ * <p>
+ * Typically, the black/white lists will be used in one of three modes:
+ * <nl>
+ * <li>Blocking a few specific IPs/URLs by specifying several black list entries.
+ * <li>Allowing only some specific IPs/URLs by specifying several white lists entries.
+ * <li>Allowing a general range of IPs/URLs by specifying serveral general white list
+ * entries, that are then further refined by several specific black list exceptions
+ * </ul>
+ *
+ */
+public class IPAccessHandler extends HandlerWrapper
+{
+ Map<String,PathMap> _whiteAddr = new HashMap<String, PathMap>();
+ List<String> _whitePattern = new CopyOnWriteArrayList<String>();
+ Map<String,PathMap> _blackAddr = new HashMap<String, PathMap>();
+ List<String> _blackPattern = new CopyOnWriteArrayList<String>();
+
+ /**
+ */
+ public IPAccessHandler()
+ {
+ }
+
+ public void addBlack(String addrPath)
+ {
+ add(addrPath, _blackAddr, _blackPattern);
+ }
+
+ public void addWhite(String addrPath)
+ {
+ add(addrPath, _whiteAddr, _whitePattern);
+ }
+
+ public void setBlack(String[] addrPaths)
+ {
+ set(addrPaths, _blackAddr, _blackPattern);
+ }
+
+ public void setWhite(String[] addrPaths)
+ {
+ set(addrPaths, _whiteAddr, _whitePattern);
+ }
+
+ /**
+ */
+ @Override
+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ // Get the real remote IP (not the one set by the forwarded headers (which may be forged))
+ HttpConnection connection = baseRequest.getConnection();
+ if (connection!=null)
+ {
+ EndPoint endp=connection.getEndPoint();
+ if (endp!=null)
+ {
+ String addr = endp.getRemoteAddr();
+ if (addr!=null && !isAddrUriAllowed(addr,baseRequest.getPathInfo()))
+ {
+ response.sendError(HttpStatus.FORBIDDEN_403);
+ baseRequest.setHandled(true);
+ return;
+ }
+ }
+ }
+
+ getHandler().handle(target,baseRequest, request, response);
+ }
+
+ protected void add(String addrPath, Map<String,PathMap> addrMap, List<String> patternList)
+ {
+ int idx = addrPath.indexOf('/');
+ String addr = idx > 0 ? addrPath.substring(0,idx) : addrPath;
+ String path = idx > 0 ? addrPath.substring(idx) : null;
+ if (path!=null && path.length()>1 && path.charAt(1)=='*')
+ path=path.substring(1);
+
+ PathMap map = addrMap.get(addr);
+ if (map==null)
+ {
+ map = new PathMap(true);
+ addrMap.put(addr,map);
+ if (addr.endsWith("."))
+ patternList.add(addr);
+ }
+
+ if (path != null)
+ map.put(path,path);
+ }
+
+ protected void set(String[] addrPaths, Map<String,PathMap> addrMap, List<String> patternList)
+ {
+ addrMap.clear();
+ patternList.clear();
+ for (String addrPath:addrPaths)
+ add(addrPath, addrMap, patternList);
+ }
+
+ protected boolean isAddrUriAllowed(String addr, String path)
+ {
+ if (_whiteAddr.size()>0)
+ {
+ PathMap white=_whiteAddr.get(addr);
+
+ if (white==null || (white.size()>0 && white.match(path)==null))
+ {
+ boolean match=false;
+ for (String pattern:_whitePattern)
+ {
+ if (addr.startsWith(pattern))
+ {
+ white=_whiteAddr.get(pattern);
+ if (white!=null && white.size()>0 && white.match(path)!=null)
+ {
+ match=true;
+ break;
+ }
+ }
+ }
+ if (!match)
+ return false;
+ }
+ }
+
+ PathMap black=_blackAddr.get(addr);
+ if (black!=null && (black.size()==0 || black.match(path)!=null))
+ return false;
+
+ for (String pattern:_blackPattern)
+ {
+ if (addr.startsWith(pattern))
+ {
+ black=_blackAddr.get(pattern);
+ if (black!=null && black.match(path)!=null)
+ return false;
+ break;
+ }
+ }
+
+ return true;
+ }
+
+}
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/MovedContextHandler.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/MovedContextHandler.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/MovedContextHandler.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -107,7 +107,7 @@
if (!_discardQuery && request.getQueryString()!=null)
url+="?"+request.getQueryString();
- response.sendRedirect(url);
+ response.sendRedirect(response.encodeRedirectURL(url));
String path=_newContextURL;
if (!_discardPathInfo && request.getPathInfo()!=null)
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -302,7 +302,7 @@
{
if (!request.getPathInfo().endsWith(URIUtil.SLASH))
{
- response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH));
+ response.sendRedirect(response.encodeRedirectURL(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH)));
return;
}
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -13,13 +13,12 @@
package org.eclipse.jetty.server.session;
-import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
-import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.http.security.B64Code;
import org.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
@@ -27,35 +26,45 @@
public abstract class AbstractSessionIdManager extends AbstractLifeCycle implements SessionIdManager
{
private final static String __NEW_SESSION_ID="org.eclipse.jetty.server.newSessionId";
- protected final static String SESSION_ID_RANDOM_ALGORITHM = "SHA1PRNG";
- protected final static String SESSION_ID_RANDOM_ALGORITHM_ALT = "IBMSecureRandom";
protected Random _random;
protected boolean _weakRandom;
protected String _workerName;
- protected final Server _server;
-
- public AbstractSessionIdManager(Server server)
+ /* ------------------------------------------------------------ */
+ public AbstractSessionIdManager()
{
- _server=server;
}
-
- public AbstractSessionIdManager(Server server, Random random)
+ /* ------------------------------------------------------------ */
+ public AbstractSessionIdManager(Random random)
{
_random=random;
- _server=server;
}
+
+ /* ------------------------------------------------------------ */
+ /**
+ * Get the workname. If set, the workername is dot appended to the session
+ * ID and can be used to assist session affinity in a load balancer.
+ *
+ * @return String or null
+ */
public String getWorkerName()
{
return _workerName;
}
-
- public void setWorkerName (String name)
+
+ /* ------------------------------------------------------------ */
+ /**
+ * Set the workname. If set, the workername is dot appended to the session
+ * ID and can be used to assist session affinity in a load balancer.
+ *
+ * @param workerName
+ */
+ public void setWorkerName(String workerName)
{
- _workerName=name;
+ _workerName=workerName;
}
/* ------------------------------------------------------------ */
@@ -70,6 +79,8 @@
_random=random;
_weakRandom=false;
}
+
+ /* ------------------------------------------------------------ */
/**
* Create a new session id if necessary.
*
@@ -93,25 +104,26 @@
if (new_id!=null&&idInUse(new_id))
return new_id;
-
-
// pick a new unique ID!
String id=null;
while (id==null||id.length()==0||idInUse(id))
{
- long r=_weakRandom
+ long r0=_weakRandom
?(hashCode()^Runtime.getRuntime().freeMemory()^_random.nextInt()^(((long)request.hashCode())<<32))
:_random.nextLong();
- r^=created;
- if (request!=null && request.getRemoteAddr()!=null)
- r^=request.getRemoteAddr().hashCode();
- if (r<0)
- r=-r;
- id=Long.toString(r,36);
+ if (r0<0)
+ r0=-r0;
+ long r1=_weakRandom
+ ?(hashCode()^Runtime.getRuntime().freeMemory()^_random.nextInt()^(((long)request.hashCode())<<32))
+ :_random.nextLong();
+ if (r1<0)
+ r1=-r1;
+ id=Long.toString(r0,36)+Long.toString(r1,36);
//add in the id of the node to ensure unique id across cluster
//NOTE this is different to the node suffix which denotes which node the request was received on
- id=_workerName + id;
+ if (_workerName!=null)
+ id=_workerName + id;
}
request.setAttribute(__NEW_SESSION_ID,id);
@@ -119,16 +131,20 @@
}
}
-
+ /* ------------------------------------------------------------ */
@Override
- public void doStart()
+ protected void doStart() throws Exception
{
initRandom();
}
-
+ /* ------------------------------------------------------------ */
+ @Override
+ protected void doStop() throws Exception
+ {
+ }
-
+ /* ------------------------------------------------------------ */
/**
* Set up a random number generator for the sessionids.
*
@@ -140,21 +156,13 @@
{
try
{
- _random=SecureRandom.getInstance(SESSION_ID_RANDOM_ALGORITHM);
+ _random=new SecureRandom();
}
- catch (NoSuchAlgorithmException e)
+ catch (Exception e)
{
- try
- {
- _random=SecureRandom.getInstance(SESSION_ID_RANDOM_ALGORITHM_ALT);
- _weakRandom=false;
- }
- catch (NoSuchAlgorithmException e_alt)
- {
- Log.warn("Could not generate SecureRandom for session-id randomness",e);
- _random=new Random();
- _weakRandom=true;
- }
+ Log.warn("Could not generate SecureRandom for session-id randomness",e);
+ _random=new Random();
+ _weakRandom=true;
}
}
_random.setSeed(_random.nextLong()^System.currentTimeMillis()^hashCode()^Runtime.getRuntime().freeMemory());
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionManager.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionManager.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionManager.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -184,39 +184,30 @@
_sessionIdManager.start();
// Look for a session cookie name
- String tmp=_context.getInitParameter(SessionManager.__SessionCookieProperty);
- if (tmp!=null)
- _sessionCookie=tmp;
-
- tmp=_context.getInitParameter(SessionManager.__SessionIdPathParameterNameProperty);
- if (tmp!=null)
+ if (_context!=null)
{
- setSessionIdPathParameterName(tmp);
- }
+ String tmp=_context.getInitParameter(SessionManager.__SessionCookieProperty);
+ if (tmp!=null)
+ _sessionCookie=tmp;
- // set up the max session cookie age if it isn't already
- if (_maxCookieAge==-1)
- {
- if (_context!=null)
+ tmp=_context.getInitParameter(SessionManager.__SessionIdPathParameterNameProperty);
+ if (tmp!=null)
+ setSessionIdPathParameterName(tmp);
+
+ // set up the max session cookie age if it isn't already
+ if (_maxCookieAge==-1)
{
- String str=_context.getInitParameter(SessionManager.__MaxAgeProperty);
- if (str!=null)
- _maxCookieAge=Integer.parseInt(str.trim());
+ tmp=_context.getInitParameter(SessionManager.__MaxAgeProperty);
+ if (tmp!=null)
+ _maxCookieAge=Integer.parseInt(tmp.trim());
}
- }
- // set up the session domain if it isn't already
- if (_sessionDomain==null)
- {
- // only try the context initParams
- if (_context!=null)
+
+ // set up the session domain if it isn't already
+ if (_sessionDomain==null)
_sessionDomain=_context.getInitParameter(SessionManager.__SessionDomainProperty);
- }
- // set up the sessionPath if it isn't already
- if (_sessionPath==null)
- {
- // only the context initParams
- if (_context!=null)
+ // set up the sessionPath if it isn't already
+ if (_sessionPath==null)
_sessionPath=_context.getInitParameter(SessionManager.__SessionPathProperty);
}
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -30,16 +30,9 @@
/**
* HashSessionIdManager. An in-memory implementation of the session ID manager.
*/
-public class HashSessionIdManager extends AbstractLifeCycle implements SessionIdManager
+public class HashSessionIdManager extends AbstractSessionIdManager
{
- private final static String __NEW_SESSION_ID="org.eclipse.jetty.server.newSessionId";
- protected final static String SESSION_ID_RANDOM_ALGORITHM = "SHA1PRNG";
- protected final static String SESSION_ID_RANDOM_ALGORITHM_ALT = "IBMSecureRandom";
-
MultiMap<String> _sessions;
- protected Random _random;
- private boolean _weakRandom;
- private String _workerName;
/* ------------------------------------------------------------ */
public HashSessionIdManager()
@@ -49,35 +42,10 @@
/* ------------------------------------------------------------ */
public HashSessionIdManager(Random random)
{
- _random=random;
-
+ super(random);
}
/* ------------------------------------------------------------ */
- /**
- * Get the workname. If set, the workername is dot appended to the session
- * ID and can be used to assist session affinity in a load balancer.
- *
- * @return String or null
- */
- public String getWorkerName()
- {
- return _workerName;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Set the workname. If set, the workername is dot appended to the session
- * ID and can be used to assist session affinity in a load balancer.
- *
- * @param workerName
- */
- public void setWorkerName(String workerName)
- {
- _workerName=workerName;
- }
-
- /* ------------------------------------------------------------ */
/** Get the session ID with any worker ID.
*
* @param request
@@ -109,44 +77,20 @@
/* ------------------------------------------------------------ */
@Override
- protected void doStart()
- {
- if (_random==null)
- {
- try
- {
- //This operation may block on some systems with low entropy. See this page
- //for workaround suggestions:
- //http://docs.codehaus.org/display/JETTY/Connectors+slow+to+startup
- Log.debug("Init SecureRandom.");
- _random=SecureRandom.getInstance(SESSION_ID_RANDOM_ALGORITHM);
- }
- catch (NoSuchAlgorithmException e)
- {
- try
- {
- _random=SecureRandom.getInstance(SESSION_ID_RANDOM_ALGORITHM_ALT);
- _weakRandom=false;
- }
- catch (NoSuchAlgorithmException e_alt)
- {
- Log.warn("Could not generate SecureRandom for session-id randomness",e);
- _random=new Random();
- _weakRandom=true;
- }
- }
- }
- _random.setSeed(_random.nextLong()^System.currentTimeMillis()^hashCode()^Runtime.getRuntime().freeMemory());
+ protected void doStart() throws Exception
+ {
_sessions=new MultiMap<String>(true);
+ super.doStart();
}
/* ------------------------------------------------------------ */
@Override
- protected void doStop()
+ protected void doStop() throws Exception
{
if (_sessions!=null)
_sessions.clear(); // Maybe invalidate?
_sessions=null;
+ super.doStop();
}
/* ------------------------------------------------------------ */
@@ -194,65 +138,4 @@
}
}
- /* ------------------------------------------------------------ */
- /*
- * new Session ID. If the request has a requestedSessionID which is unique,
- * that is used. The session ID is created as a unique random long XORed with
- * connection specific information, base 36.
- * @param request
- * @param created
- * @return Session ID.
- */
- public String newSessionId(HttpServletRequest request, long created)
- {
- synchronized (this)
- {
- // A requested session ID can only be used if it is in use already.
- String requested_id=request.getRequestedSessionId();
-
- if (requested_id!=null)
- {
- String cluster_id=getClusterId(requested_id);
- if (idInUse(cluster_id))
- return cluster_id;
- }
-
- // Else reuse any new session ID already defined for this request.
- String new_id=(String)request.getAttribute(__NEW_SESSION_ID);
- if (new_id!=null&&idInUse(new_id))
- return new_id;
-
- // pick a new unique ID!
- String id=null;
- while (id==null||id.length()==0||idInUse(id))
- {
- long r=_weakRandom
- ?(hashCode()^Runtime.getRuntime().freeMemory()^_random.nextInt()^(((long)request.hashCode())<<32))
- :_random.nextLong();
- r^=created;
- if (request.getRemoteAddr()!=null)
- r^=request.getRemoteAddr().hashCode();
- if (r<0)
- r=-r;
- id=Long.toString(r,36);
- }
-
- request.setAttribute(__NEW_SESSION_ID,id);
- return id;
- }
- }
-
- /* ------------------------------------------------------------ */
- public Random getRandom()
- {
- return _random;
- }
-
- /* ------------------------------------------------------------ */
- public void setRandom(Random random)
- {
- _random=random;
- _weakRandom=false;
- }
-
}
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -53,6 +53,7 @@
public class JDBCSessionIdManager extends AbstractSessionIdManager
{
protected final HashSet<String> _sessionIds = new HashSet();
+ protected Server _server;
protected String _driverClassName;
protected String _connectionUrl;
protected DataSource _datasource;
@@ -152,12 +153,14 @@
public JDBCSessionIdManager(Server server)
{
- super(server);
+ super();
+ _server=server;
}
public JDBCSessionIdManager(Server server, Random random)
{
- super(server, random);
+ super(random);
+ _server=server;
}
/**
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -186,10 +186,7 @@
}
// start manual inline of nextScope(target,baseRequest,request,response);
- //noinspection ConstantIfStatement
- if (false)
- nextScope(target,baseRequest,request,response);
- else if (_nextScope!=null)
+ if (_nextScope!=null)
_nextScope.doScope(target,baseRequest,request, response);
else if (_outerScope!=null)
_outerScope.doHandle(target,baseRequest,request, response);
@@ -207,12 +204,16 @@
//leaving context, free up the session
if (session!=null)
_sessionManager.complete(session);
- baseRequest.setSessionManager(old_session_manager);
- baseRequest.setSession(old_session);
+
+ // Leave last session in place
+ if (old_session_manager!=null )
+ {
+ baseRequest.setSessionManager(old_session_manager);
+ baseRequest.setSession(old_session);
+ }
}
}
}
-
/* ------------------------------------------------------------ */
/*
@@ -284,20 +285,26 @@
{
String uri = request.getRequestURI();
- int semi = uri.lastIndexOf(';');
- if (semi>=0)
+ String prefix=sessionManager.getSessionIdPathParameterNamePrefix();
+ if (prefix!=null)
{
- // check if there is a url encoded session param.
- String param=sessionManager.getSessionIdPathParameterName();
- if (param!=null)
- {
- int p=uri.indexOf(param,semi+1);
- if (p>0)
+ int s = uri.indexOf(prefix);
+ if (s>=0)
+ {
+ s+=prefix.length();
+ int i=s;
+ while (i<uri.length())
{
- requested_session_id = uri.substring(p+param.length()+1);
- requested_session_id_from_cookie = false;
- if(Log.isDebugEnabled())Log.debug("Got Session ID "+requested_session_id+" from URL");
+ char c=uri.charAt(i);
+ if (c==';'||c=='#'||c=='?'||c=='/')
+ break;
+ i++;
}
+
+ requested_session_id = uri.substring(s,i);
+ requested_session_id_from_cookie = false;
+ if(Log.isDebugEnabled())
+ Log.debug("Got Session ID "+requested_session_id+" from URL");
}
}
}
Copied: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslCertificates.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslCertificates.java)
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslCertificates.java (rev 0)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslCertificates.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,163 @@
+package org.eclipse.jetty.server.ssl;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLPeerUnverifiedException;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocket;
+
+import org.eclipse.jetty.http.HttpSchemes;
+import org.eclipse.jetty.http.ssl.SslSelectChannelEndPoint;
+import org.eclipse.jetty.io.EndPoint;
+import org.eclipse.jetty.io.bio.SocketEndPoint;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.util.TypeUtil;
+import org.eclipse.jetty.util.log.Log;
+
+public class SslCertificates
+{
+ /**
+ * The name of the SSLSession attribute that will contain any cached information.
+ */
+ static final String CACHED_INFO_ATTR = CachedInfo.class.getName();
+
+ public static X509Certificate[] getCertChain(SSLSession sslSession)
+ {
+ try
+ {
+ javax.security.cert.X509Certificate javaxCerts[]=sslSession.getPeerCertificateChain();
+ if (javaxCerts==null||javaxCerts.length==0)
+ return null;
+
+ int length=javaxCerts.length;
+ X509Certificate[] javaCerts=new X509Certificate[length];
+
+ java.security.cert.CertificateFactory cf=java.security.cert.CertificateFactory.getInstance("X.509");
+ for (int i=0; i<length; i++)
+ {
+ byte bytes[]=javaxCerts[i].getEncoded();
+ ByteArrayInputStream stream=new ByteArrayInputStream(bytes);
+ javaCerts[i]=(X509Certificate)cf.generateCertificate(stream);
+ }
+
+ return javaCerts;
+ }
+ catch (SSLPeerUnverifiedException pue)
+ {
+ return null;
+ }
+ catch (Exception e)
+ {
+ Log.warn(Log.EXCEPTION,e);
+ return null;
+ }
+ }
+
+
+ /* ------------------------------------------------------------ */
+ /**
+ * Allow the Listener a chance to customise the request. before the server
+ * does its stuff. <br>
+ * This allows the required attributes to be set for SSL requests. <br>
+ * The requirements of the Servlet specs are:
+ * <ul>
+ * <li> an attribute named "javax.servlet.request.ssl_session_id" of type
+ * String (since Servlet Spec 3.0).</li>
+ * <li> an attribute named "javax.servlet.request.cipher_suite" of type
+ * String.</li>
+ * <li> an attribute named "javax.servlet.request.key_size" of type Integer.</li>
+ * <li> an attribute named "javax.servlet.request.X509Certificate" of type
+ * java.security.cert.X509Certificate[]. This is an array of objects of type
+ * X509Certificate, the order of this array is defined as being in ascending
+ * order of trust. The first certificate in the chain is the one set by the
+ * client, the next is the one used to authenticate the first, and so on.
+ * </li>
+ * </ul>
+ *
+ * @param endpoint
+ * The Socket the request arrived on. This should be a
+ * {@link SocketEndPoint} wrapping a {@link SSLSocket}.
+ * @param request
+ * HttpRequest to be customised.
+ */
+ public static void customize(SSLSession sslSession, EndPoint endpoint, Request request) throws IOException
+ {
+ request.setScheme(HttpSchemes.HTTPS);
+
+ try
+ {
+ String cipherSuite=sslSession.getCipherSuite();
+ Integer keySize;
+ X509Certificate[] certs;
+ String idStr;
+
+ CachedInfo cachedInfo=(CachedInfo)sslSession.getValue(CACHED_INFO_ATTR);
+ if (cachedInfo!=null)
+ {
+ keySize=cachedInfo.getKeySize();
+ certs=cachedInfo.getCerts();
+ idStr=cachedInfo.getIdStr();
+ }
+ else
+ {
+ keySize=new Integer(ServletSSL.deduceKeyLength(cipherSuite));
+ certs=SslCertificates.getCertChain(sslSession);
+ byte[] bytes = sslSession.getId();
+ idStr = TypeUtil.toHexString(bytes);
+ cachedInfo=new CachedInfo(keySize,certs,idStr);
+ sslSession.putValue(CACHED_INFO_ATTR,cachedInfo);
+ }
+
+ if (certs!=null)
+ request.setAttribute("javax.servlet.request.X509Certificate",certs);
+
+ request.setAttribute("javax.servlet.request.cipher_suite",cipherSuite);
+ request.setAttribute("javax.servlet.request.key_size",keySize);
+ request.setAttribute("javax.servlet.request.ssl_session_id", idStr);
+ }
+ catch (Exception e)
+ {
+ Log.warn(Log.EXCEPTION,e);
+ }
+ }
+
+ /* ------------------------------------------------------------ */
+ /* ------------------------------------------------------------ */
+ /* ------------------------------------------------------------ */
+ /**
+ * Simple bundle of information that is cached in the SSLSession. Stores the
+ * effective keySize and the client certificate chain.
+ */
+ private static class CachedInfo
+ {
+ private final X509Certificate[] _certs;
+ private final Integer _keySize;
+ private final String _idStr;
+
+ CachedInfo(Integer keySize, X509Certificate[] certs,String idStr)
+ {
+ this._keySize=keySize;
+ this._certs=certs;
+ this._idStr=idStr;
+ }
+
+ X509Certificate[] getCerts()
+ {
+ return _certs;
+ }
+
+ Integer getKeySize()
+ {
+ return _keySize;
+ }
+
+ String getIdStr()
+ {
+ return _idStr;
+ }
+ }
+
+}
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -29,7 +29,6 @@
/** String name of keystore password property. */
public static final String PASSWORD_PROPERTY = "org.eclipse.jetty.ssl.password";
-
/* ------------------------------------------------------------ */
/**
@@ -47,6 +46,20 @@
/* ------------------------------------------------------------ */
/**
+ * @return The array of Ciphersuite names to include in
+ * {@link SSLEngine#setEnabledCipherSuites(String[])}
+ */
+ public abstract String[] getIncludeCipherSuites();
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @param cipherSuites The array of Ciphersuite names to include in
+ * {@link SSLEngine#setEnabledCipherSuites(String[])}
+ */
+ public abstract void setIncludeCipherSuites(String[] cipherSuites);
+
+ /* ------------------------------------------------------------ */
+ /**
* @param password The password for the key store
*/
public abstract void setPassword(String password);
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -66,14 +66,10 @@
*/
public class SslSelectChannelConnector extends SelectChannelConnector implements SslConnector
{
- /**
- * The name of the SSLSession attribute that will contain any cached
- * information.
- */
- static final String CACHED_INFO_ATTR=CachedInfo.class.getName();
-
- /** Default value for the cipher Suites. */
+ /** Default value for the excluded cipher Suites. */
private String _excludeCipherSuites[]=null;
+ /** Default value for the included cipher Suites. */
+ private String _includeCipherSuites[]=null;
/** Default value for the keystore location path. */
private String _keystorePath=DEFAULT_KEYSTORE;
@@ -112,38 +108,7 @@
* negotiate the SSL connection. <br>
* Will be null if the chain is missing or empty.
*/
- private static X509Certificate[] getCertChain(SSLSession sslSession)
- {
- try
- {
- javax.security.cert.X509Certificate javaxCerts[]=sslSession.getPeerCertificateChain();
- if (javaxCerts==null||javaxCerts.length==0)
- return null;
- int length=javaxCerts.length;
- X509Certificate[] javaCerts=new X509Certificate[length];
-
- java.security.cert.CertificateFactory cf=java.security.cert.CertificateFactory.getInstance("X.509");
- for (int i=0; i<length; i++)
- {
- byte bytes[]=javaxCerts[i].getEncoded();
- ByteArrayInputStream stream=new ByteArrayInputStream(bytes);
- javaCerts[i]=(X509Certificate)cf.generateCertificate(stream);
- }
-
- return javaCerts;
- }
- catch (SSLPeerUnverifiedException pue)
- {
- return null;
- }
- catch (Exception e)
- {
- Log.warn(Log.EXCEPTION,e);
- return null;
- }
- }
-
/* ------------------------------------------------------------ */
/**
@@ -176,47 +141,12 @@
{
super.customize(endpoint,request);
request.setScheme(HttpSchemes.HTTPS);
-
+
SslSelectChannelEndPoint sslHttpChannelEndpoint=(SslSelectChannelEndPoint)endpoint;
-
SSLEngine sslEngine=sslHttpChannelEndpoint.getSSLEngine();
-
- try
- {
- SSLSession sslSession=sslEngine.getSession();
- String cipherSuite=sslSession.getCipherSuite();
- Integer keySize;
- X509Certificate[] certs;
- String idStr;
-
- CachedInfo cachedInfo=(CachedInfo)sslSession.getValue(CACHED_INFO_ATTR);
- if (cachedInfo!=null)
- {
- keySize=cachedInfo.getKeySize();
- certs=cachedInfo.getCerts();
- idStr=cachedInfo.getIdStr();
- }
- else
- {
- keySize=new Integer(ServletSSL.deduceKeyLength(cipherSuite));
- certs=getCertChain(sslSession);
- byte[] bytes = sslSession.getId();
- idStr = TypeUtil.toHexString(bytes);
- cachedInfo=new CachedInfo(keySize,certs,idStr);
- sslSession.putValue(CACHED_INFO_ATTR,cachedInfo);
- }
-
- if (certs!=null)
- request.setAttribute("javax.servlet.request.X509Certificate",certs);
-
- request.setAttribute("javax.servlet.request.cipher_suite",cipherSuite);
- request.setAttribute("javax.servlet.request.key_size",keySize);
- request.setAttribute("javax.servlet.request.ssl_session_id", idStr);
- }
- catch (Exception e)
- {
- Log.warn(Log.EXCEPTION,e);
- }
+ SSLSession sslSession=sslEngine.getSession();
+
+ SslCertificates.customize(sslSession,endpoint,request);
}
/* ------------------------------------------------------------ */
@@ -263,9 +193,27 @@
{
this._excludeCipherSuites=cipherSuites;
}
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.server.ssl.SslConnector#getExcludeCipherSuites()
+ */
+ public String[] getIncludeCipherSuites()
+ {
+ return _includeCipherSuites;
+ }
/* ------------------------------------------------------------ */
/**
+ * @see org.eclipse.jetty.server.ssl.SslConnector#setExcludeCipherSuites(java.lang.String[])
+ */
+ public void setIncludeCipherSuites(String[] cipherSuites)
+ {
+ this._includeCipherSuites=cipherSuites;
+ }
+
+ /* ------------------------------------------------------------ */
+ /**
* @see org.eclipse.jetty.server.ssl.SslConnector#setPassword(java.lang.String)
*/
public void setPassword(String password)
@@ -594,23 +542,51 @@
/* ------------------------------------------------------------ */
protected SSLEngine createSSLEngine() throws IOException
{
- SSLEngine engine=null;
+ SSLEngine engine = null;
try
{
- engine=_context.createSSLEngine();
+ engine = _context.createSSLEngine();
engine.setUseClientMode(false);
-
+
if (_wantClientAuth)
engine.setWantClientAuth(_wantClientAuth);
if (_needClientAuth)
engine.setNeedClientAuth(_needClientAuth);
-
- if (_excludeCipherSuites!=null&&_excludeCipherSuites.length>0)
+
+ if ((_excludeCipherSuites != null && _excludeCipherSuites.length > 0) || (_includeCipherSuites != null && _includeCipherSuites.length > 0))
{
- List<String> excludedCSList=Arrays.asList(_excludeCipherSuites);
- String[] enabledCipherSuites=engine.getEnabledCipherSuites();
- List<String> enabledCSList=new ArrayList<String>(Arrays.asList(enabledCipherSuites));
+ List<String> includedCSList;
+ if (_includeCipherSuites != null)
+ {
+ includedCSList = Arrays.asList(_includeCipherSuites);
+ }
+ else
+ {
+ includedCSList = new ArrayList<String>();
+ }
+ List<String> excludedCSList;
+ if (_excludeCipherSuites != null)
+ {
+ excludedCSList = Arrays.asList(_excludeCipherSuites);
+ }
+ else
+ {
+ excludedCSList = new ArrayList<String>();
+ }
+ String[] enabledCipherSuites = engine.getEnabledCipherSuites();
+ List<String> enabledCSList = new ArrayList<String>(Arrays.asList(enabledCipherSuites));
+ String[] supportedCipherSuites = engine.getSupportedCipherSuites();
+ List<String> supportedCSList = Arrays.asList(supportedCipherSuites);
+
+ for (String cipherName : includedCSList)
+ {
+ if ((!enabledCSList.contains(cipherName)) && supportedCSList.contains(cipherName))
+ {
+ enabledCSList.add(cipherName);
+ }
+ }
+
for (String cipherName : excludedCSList)
{
if (enabledCSList.contains(cipherName))
@@ -618,7 +594,7 @@
enabledCSList.remove(cipherName);
}
}
- enabledCipherSuites=enabledCSList.toArray(new String[enabledCSList.size()]);
+ enabledCipherSuites = enabledCSList.toArray(new String[0]);
engine.setEnabledCipherSuites(enabledCipherSuites);
}
@@ -734,40 +710,4 @@
}
}
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- /**
- * Simple bundle of information that is cached in the SSLSession. Stores the
- * effective keySize and the client certificate chain.
- */
- private class CachedInfo
- {
- private final X509Certificate[] _certs;
- private final Integer _keySize;
- private final String _idStr;
-
- CachedInfo(Integer keySize, X509Certificate[] certs,String idStr)
- {
- this._keySize=keySize;
- this._certs=certs;
- this._idStr=idStr;
- }
-
- X509Certificate[] getCerts()
- {
- return _certs;
- }
-
- Integer getKeySize()
- {
- return _keySize;
- }
-
- String getIdStr()
- {
- return _idStr;
- }
- }
-
}
Modified: jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -22,11 +22,9 @@
import java.net.SocketAddress;
import java.security.KeyStore;
import java.security.SecureRandom;
-import java.security.Security;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
import javax.net.ssl.HandshakeCompletedEvent;
@@ -70,58 +68,10 @@
*/
public class SslSocketConnector extends SocketConnector implements SslConnector
{
- /**
- * The name of the SSLSession attribute that will contain any cached information.
- */
- static final String CACHED_INFO_ATTR = CachedInfo.class.getName();
-
- /**
- * Return the chain of X509 certificates used to negotiate the SSL Session.
- * <p>
- * Note: in order to do this we must convert a javax.security.cert.X509Certificate[], as used by
- * JSSE to a java.security.cert.X509Certificate[],as required by the Servlet specs.
- *
- * @param sslSession the javax.net.ssl.SSLSession to use as the source of the cert chain.
- * @return the chain of java.security.cert.X509Certificates used to negotiate the SSL
- * connection. <br>
- * Will be null if the chain is missing or empty.
- */
- private static X509Certificate[] getCertChain(SSLSession sslSession)
- {
- try
- {
- javax.security.cert.X509Certificate javaxCerts[] = sslSession.getPeerCertificateChain();
- if (javaxCerts == null || javaxCerts.length == 0)
- return null;
-
- int length = javaxCerts.length;
- X509Certificate[] javaCerts = new X509Certificate[length];
-
- java.security.cert.CertificateFactory cf = java.security.cert.CertificateFactory.getInstance("X.509");
- for (int i = 0; i < length; i++)
- {
- byte bytes[] = javaxCerts[i].getEncoded();
- ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
- javaCerts[i] = (X509Certificate) cf.generateCertificate(stream);
- }
-
- return javaCerts;
- }
- catch (SSLPeerUnverifiedException pue)
- {
- return null;
- }
- catch (Exception e)
- {
- Log.warn(Log.EXCEPTION, e);
- return null;
- }
- }
-
-
-
/** Default value for the cipher Suites. */
private String _excludeCipherSuites[] = null;
+ /** Default value for the included cipher Suites. */
+ private String _includeCipherSuites[]=null;
/** Default value for the keystore location path. */
private String _keystorePath=DEFAULT_KEYSTORE ;
@@ -300,51 +250,21 @@
SocketEndPoint socket_end_point = (SocketEndPoint)endpoint;
SSLSocket sslSocket = (SSLSocket)socket_end_point.getTransport();
-
- try
- {
- SSLSession sslSession = sslSocket.getSession();
- String cipherSuite = sslSession.getCipherSuite();
- Integer keySize;
- String idStr;
- X509Certificate[] certs;
+ SSLSession sslSession = sslSocket.getSession();
- CachedInfo cachedInfo = (CachedInfo) sslSession.getValue(CACHED_INFO_ATTR);
- if (cachedInfo != null)
- {
- keySize = cachedInfo.getKeySize();
- certs = cachedInfo.getCerts();
- idStr = cachedInfo.getIdStr();
- }
- else
- {
- keySize = new Integer(ServletSSL.deduceKeyLength(cipherSuite));
- certs = getCertChain(sslSession);
- byte[] idBytes = sslSession.getId();
- idStr = TypeUtil.toHexString(idBytes);
- cachedInfo = new CachedInfo(keySize, certs,idStr);
- sslSession.putValue(CACHED_INFO_ATTR, cachedInfo);
- }
-
- if (certs != null)
- request.setAttribute("javax.servlet.request.X509Certificate", certs);
- else if (_needClientAuth) // Sanity check
- throw new IllegalStateException("no client auth");
-
- request.setAttribute("javax.servlet.request.ssl_session_id", idStr);
- request.setAttribute("javax.servlet.request.cipher_suite", cipherSuite);
- request.setAttribute("javax.servlet.request.key_size", keySize);
- }
- catch (Exception e)
- {
- Log.warn(Log.EXCEPTION, e);
- }
+ SslCertificates.customize(sslSession,endpoint,request);
}
/* ------------------------------------------------------------ */
public String[] getExcludeCipherSuites() {
return _excludeCipherSuites;
}
+
+ /* ------------------------------------------------------------ */
+ public String[] getIncludeCipherSuites()
+ {
+ return _includeCipherSuites;
+ }
/* ------------------------------------------------------------ */
public String getKeystore()
@@ -473,22 +393,46 @@
if (_needClientAuth)
socket.setNeedClientAuth(_needClientAuth);
- if (_excludeCipherSuites != null && _excludeCipherSuites.length >0)
+ if ((_excludeCipherSuites!=null&&_excludeCipherSuites.length>0)
+ || (_includeCipherSuites!=null&&_includeCipherSuites.length>0))
{
- List excludedCSList = Arrays.asList(_excludeCipherSuites);
+ List<String> includedCSList;
+ if (_includeCipherSuites!=null)
+ {
+ includedCSList = Arrays.asList(_includeCipherSuites);
+ } else {
+ includedCSList = new ArrayList<String>();
+ }
+ List<String> excludedCSList;
+ if (_excludeCipherSuites!=null)
+ {
+ excludedCSList = Arrays.asList(_excludeCipherSuites);
+ } else {
+ excludedCSList = new ArrayList<String>();
+ }
String[] enabledCipherSuites = socket.getEnabledCipherSuites();
- List enabledCSList = new ArrayList(Arrays.asList(enabledCipherSuites));
- Iterator exIter = excludedCSList.iterator();
+ List<String> enabledCSList=Arrays.asList(enabledCipherSuites);
+
+ String[] supportedCipherSuites = socket.getSupportedCipherSuites();
+ List<String> supportedCSList=Arrays.asList(supportedCipherSuites);
+
+ for (String cipherName : includedCSList)
+ {
+ if ((!enabledCSList.contains(cipherName))
+ && supportedCSList.contains(cipherName))
+ {
+ enabledCSList.add(cipherName);
+ }
+ }
- while (exIter.hasNext())
- {
- String cipherName = (String)exIter.next();
+ for (String cipherName : excludedCSList)
+ {
if (enabledCSList.contains(cipherName))
{
enabledCSList.remove(cipherName);
}
- }
- enabledCipherSuites = (String[])enabledCSList.toArray(new String[enabledCSList.size()]);
+ }
+ enabledCipherSuites=enabledCSList.toArray(new String[0]);
socket.setEnabledCipherSuites(enabledCipherSuites);
}
@@ -516,6 +460,12 @@
}
/* ------------------------------------------------------------ */
+ public void setIncludeCipherSuites(String[] cipherSuites)
+ {
+ this._includeCipherSuites=cipherSuites;
+ }
+
+ /* ------------------------------------------------------------ */
public void setKeyPassword(String password)
{
_keyPassword = Password.getPassword(KEYPASSWORD_PROPERTY,password,null);
@@ -657,42 +607,6 @@
}
/* ------------------------------------------------------------ */
- /**
- * Simple bundle of information that is cached in the SSLSession. Stores the effective keySize
- * and the client certificate chain.
- */
- private class CachedInfo
- {
- private final X509Certificate[] _certs;
- private final Integer _keySize;
- private final String _idStr;
-
-
- CachedInfo(Integer keySize, X509Certificate[] certs,String id)
- {
- this._keySize = keySize;
- this._certs = certs;
- this._idStr = id;
- }
-
- X509Certificate[] getCerts()
- {
- return _certs;
- }
-
- Integer getKeySize()
- {
- return _keySize;
- }
-
- String getIdStr ()
- {
- return _idStr;
- }
- }
-
-
- /* ------------------------------------------------------------ */
public class SslConnection extends ConnectorEndPoint
{
public SslConnection(Socket socket) throws IOException
Modified: jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncContextTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncContextTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncContextTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -28,6 +28,7 @@
import junit.framework.TestCase;
import org.eclipse.jetty.server.handler.HandlerWrapper;
+import org.eclipse.jetty.server.session.SessionHandler;
public class AsyncContextTest extends TestCase
{
@@ -40,7 +41,11 @@
{
_connector = new LocalConnector();
_server.setConnectors(new Connector[]{ _connector });
- _server.setHandler(_handler);
+
+ SessionHandler session = new SessionHandler();
+ session.setHandler(_handler);
+
+ _server.setHandler(session);
_server.start();
}
@@ -361,7 +366,8 @@
try
{
Thread.sleep(_resumeAfter);
- asyncContext.dispatch();
+ if(((HttpServletRequest)asyncContext.getRequest()).getSession(true).getId()!=null)
+ asyncContext.dispatch();
}
catch(Exception e)
{
Modified: jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -247,7 +247,7 @@
response.setContentType("foo/bar; other=xyz");
assertEquals("foo/bar; other=xyz",response.getContentType());
response.getWriter();
- assertEquals("foo/bar; other=xyz charset=ISO-8859-1",response.getContentType());
+ assertEquals("foo/bar; other=xyz;charset=ISO-8859-1",response.getContentType());
response.setContentType("foo2/bar2");
assertEquals("foo2/bar2;charset=ISO-8859-1",response.getContentType());
@@ -255,9 +255,9 @@
response.setCharacterEncoding("utf-8");
response.setContentType("text/html; other=xyz");
- assertEquals("text/html; other=xyz charset=utf-8",response.getContentType());
+ assertEquals("text/html; other=xyz;charset=utf-8",response.getContentType());
response.getWriter();
- assertEquals("text/html; other=xyz charset=utf-8",response.getContentType());
+ assertEquals("text/html; other=xyz;charset=utf-8",response.getContentType());
response.setContentType("text/xml");
assertEquals("text/xml;charset=UTF-8",response.getContentType());
}
Modified: jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/handler/StatisticsHandlerTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/handler/StatisticsHandlerTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/handler/StatisticsHandlerTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -338,7 +338,7 @@
Continuation continuation = ContinuationSupport.getContinuation(httpRequest);
if (continuationHandle.get() == null)
{
- continuation.setTimeout(10);
+ continuation.setTimeout(100);
continuation.suspend();
continuationHandle.set(continuation);
}
Copied: jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionHandlerTest.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionHandlerTest.java)
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionHandlerTest.java (rev 0)
+++ jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionHandlerTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,835 @@
+package org.eclipse.jetty.server.session;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.Part;
+import javax.servlet.DispatcherType;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.jetty.http.HttpCookie;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.SessionIdManager;
+import org.eclipse.jetty.server.SessionManager;
+
+public class SessionHandlerTest extends TestCase
+{
+
+ public void testRequestedIdFromCookies()
+ {
+
+ final String cookieName = "SessionId";
+ final String sessionId = "1234.host";
+ HttpServletRequest httpRequest = new MockHttpServletRequest()
+ {
+ public Cookie[] getCookies()
+ {
+ return new Cookie[]
+ { new Cookie(cookieName,sessionId) };
+ }
+ };
+
+ Request baseRequest = new Request();
+ baseRequest.setDispatcherType(DispatcherType.REQUEST);
+ Assert.assertEquals(DispatcherType.REQUEST,baseRequest.getDispatcherType());
+
+ SessionHandler sessionHandler = new SessionHandler();
+ sessionHandler.setSessionManager(new MockSessionManager()
+ {
+
+
+ public SessionCookieConfig getSessionCookieConfig()
+ {
+ return new SessionCookieConfig()
+ {
+
+ public String getComment()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getDomain()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getMaxAge()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getName()
+ {
+ return cookieName;
+ }
+
+ public String getPath()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isHttpOnly()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isSecure()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setComment(String comment)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setDomain(String domain)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setHttpOnly(boolean httpOnly)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setMaxAge(int maxAge)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setName(String name)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setPath(String path)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSecure(boolean secure)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+ }
+ public boolean isUsingCookies()
+ {
+ return true;
+ }
+
+ public String getSessionCookie()
+ {
+ return cookieName;
+ }
+ });
+ sessionHandler.setRequestedId(baseRequest,httpRequest);
+
+ Assert.assertEquals(sessionId,baseRequest.getRequestedSessionId());
+ Assert.assertTrue(baseRequest.isRequestedSessionIdFromCookie());
+
+ }
+
+ public void testRequestedIdFromURI()
+ {
+
+ final String parameterName = "sessionid";
+ final String sessionId = "1234.host";
+ HttpServletRequest httpRequest = new MockHttpServletRequest()
+ {
+ @Override
+ public String getRequestURI()
+ {
+ return "http://www.foo.net/app/action.do;" + parameterName + "=" + sessionId + ";p1=abc;p2=def";
+ }
+ };
+
+ Request baseRequest = new Request();
+ baseRequest.setDispatcherType(DispatcherType.REQUEST);
+ Assert.assertEquals(DispatcherType.REQUEST,baseRequest.getDispatcherType());
+
+ SessionHandler sessionHandler = new SessionHandler();
+ sessionHandler.setSessionManager(new MockSessionManager()
+ {
+
+ @Override
+ public String getSessionIdPathParameterName()
+ {
+ return parameterName;
+ }
+
+ @Override
+ public String getSessionIdPathParameterNamePrefix()
+ {
+ return ";"+parameterName+"=";
+ }
+ });
+
+ sessionHandler.setRequestedId(baseRequest,httpRequest);
+
+ Assert.assertEquals(sessionId,baseRequest.getRequestedSessionId());
+ Assert.assertFalse(baseRequest.isRequestedSessionIdFromCookie());
+ }
+
+ /**
+ * Mock class for HttpServletRequest interface.
+ */
+ @SuppressWarnings("unchecked")
+ class MockHttpServletRequest implements HttpServletRequest
+ {
+
+ public String getRequestURI()
+ {
+ return null;
+ }
+
+ public Cookie[] getCookies()
+ {
+ return null;
+ }
+
+ public String getAuthType()
+ {
+ return null;
+ }
+
+ public String getContextPath()
+ {
+ return null;
+ }
+
+ public long getDateHeader(String name)
+ {
+ return 0;
+ }
+
+ public String getHeader(String name)
+ {
+ return null;
+ }
+
+ public Enumeration getHeaderNames()
+ {
+ return null;
+ }
+
+ public Enumeration getHeaders(String name)
+ {
+ return null;
+ }
+
+ public int getIntHeader(String name)
+ {
+ return 0;
+ }
+
+ public String getMethod()
+ {
+ return null;
+ }
+
+ public String getPathInfo()
+ {
+ return null;
+ }
+
+ public String getPathTranslated()
+ {
+ return null;
+ }
+
+ public String getQueryString()
+ {
+ return null;
+ }
+
+ public String getRemoteUser()
+ {
+ return null;
+ }
+
+ public StringBuffer getRequestURL()
+ {
+ return null;
+ }
+
+ public String getRequestedSessionId()
+ {
+ return null;
+ }
+
+ public String getServletPath()
+ {
+ return null;
+ }
+
+ public HttpSession getSession()
+ {
+ return null;
+ }
+
+ public HttpSession getSession(boolean create)
+ {
+ return null;
+ }
+
+ public Principal getUserPrincipal()
+ {
+ return null;
+ }
+
+ public boolean isRequestedSessionIdFromCookie()
+ {
+ return false;
+ }
+
+ public boolean isRequestedSessionIdFromURL()
+ {
+ return false;
+ }
+
+ public boolean isRequestedSessionIdFromUrl()
+ {
+ return false;
+ }
+
+ public boolean isRequestedSessionIdValid()
+ {
+ return false;
+ }
+
+ public boolean isUserInRole(String role)
+ {
+ return false;
+ }
+
+ public Object getAttribute(String name)
+ {
+ return null;
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return null;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return null;
+ }
+
+ public int getContentLength()
+ {
+ return 0;
+ }
+
+ public String getContentType()
+ {
+ return null;
+ }
+
+ public ServletInputStream getInputStream() throws IOException
+ {
+ return null;
+ }
+
+ public String getLocalAddr()
+ {
+ return null;
+ }
+
+ public String getLocalName()
+ {
+ return null;
+ }
+
+ public int getLocalPort()
+ {
+ return 0;
+ }
+
+ public Locale getLocale()
+ {
+ return null;
+ }
+
+ public Enumeration getLocales()
+ {
+ return null;
+ }
+
+ public String getParameter(String name)
+ {
+ return null;
+ }
+
+ public Map getParameterMap()
+ {
+ return null;
+ }
+
+ public Enumeration getParameterNames()
+ {
+ return null;
+ }
+
+ public String[] getParameterValues(String name)
+ {
+ return null;
+ }
+
+ public String getProtocol()
+ {
+ return null;
+ }
+
+ public BufferedReader getReader() throws IOException
+ {
+ return null;
+ }
+
+ public String getRealPath(String path)
+ {
+ return null;
+ }
+
+ public String getRemoteAddr()
+ {
+ return null;
+ }
+
+ public String getRemoteHost()
+ {
+ return null;
+ }
+
+ public int getRemotePort()
+ {
+ return 0;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path)
+ {
+ return null;
+ }
+
+ public String getScheme()
+ {
+ return null;
+ }
+
+ public String getServerName()
+ {
+ return null;
+ }
+
+ public int getServerPort()
+ {
+ return 0;
+ }
+
+ public boolean isSecure()
+ {
+ return false;
+ }
+
+ public void removeAttribute(String name)
+ {
+ }
+
+ public void setAttribute(String name, Object o)
+ {
+ }
+
+ public void setCharacterEncoding(String env) throws UnsupportedEncodingException
+ {
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServletRequest#authenticate(javax.servlet.http.HttpServletResponse)
+ */
+ public boolean authenticate(HttpServletResponse response) throws IOException, ServletException
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServletRequest#getPart(java.lang.String)
+ */
+ public Part getPart(String name) throws IOException, ServletException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServletRequest#getParts()
+ */
+ public Collection<Part> getParts() throws IOException, ServletException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServletRequest#login(java.lang.String, java.lang.String)
+ */
+ public void login(String username, String password) throws ServletException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServletRequest#logout()
+ */
+ public void logout() throws ServletException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @see javax.servlet.ServletRequest#getAsyncContext()
+ */
+ public AsyncContext getAsyncContext()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.servlet.ServletRequest#getDispatcherType()
+ */
+ public DispatcherType getDispatcherType()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.servlet.ServletRequest#getServletContext()
+ */
+ public ServletContext getServletContext()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.servlet.ServletRequest#isAsyncStarted()
+ */
+ public boolean isAsyncStarted()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ * @see javax.servlet.ServletRequest#isAsyncSupported()
+ */
+ public boolean isAsyncSupported()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ * @see javax.servlet.ServletRequest#startAsync()
+ */
+ public AsyncContext startAsync() throws IllegalStateException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.servlet.ServletRequest#startAsync(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
+ */
+ public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ }
+
+ /**
+ * Mock class for SessionManager interface.
+ */
+ class MockSessionManager implements SessionManager
+ {
+ public HttpCookie access(HttpSession session, boolean secure)
+ {
+ return null;
+ }
+
+ public void addEventListener(EventListener listener)
+ {
+ }
+
+ public void clearEventListeners()
+ {
+ }
+
+ public void complete(HttpSession session)
+ {
+ }
+
+ public String getClusterId(HttpSession session)
+ {
+ return null;
+ }
+
+ public boolean getHttpOnly()
+ {
+ return false;
+ }
+
+ public HttpSession getHttpSession(String id)
+ {
+ return null;
+ }
+
+ public SessionIdManager getIdManager()
+ {
+ return null;
+ }
+
+ public int getMaxCookieAge()
+ {
+ return 0;
+ }
+
+ public int getMaxInactiveInterval()
+ {
+ return 0;
+ }
+
+ public SessionIdManager getMetaManager()
+ {
+ return null;
+ }
+
+ public String getNodeId(HttpSession session)
+ {
+ return null;
+ }
+
+ public boolean getSecureCookies()
+ {
+ return false;
+ }
+
+ public HttpCookie getSessionCookie(HttpSession session, String contextPath, boolean requestIsSecure)
+ {
+ return null;
+ }
+
+ public String getSessionCookie()
+ {
+ return null;
+ }
+
+ public String getSessionDomain()
+ {
+ return null;
+ }
+
+ public String getSessionIdPathParameterName()
+ {
+ return null;
+ }
+
+ public String getSessionIdPathParameterNamePrefix()
+ {
+ return null;
+ }
+
+ public String getSessionPath()
+ {
+ return null;
+ }
+
+ public boolean isUsingCookies()
+ {
+ return false;
+ }
+
+ public boolean isValid(HttpSession session)
+ {
+ return false;
+ }
+
+ public HttpSession newHttpSession(HttpServletRequest request)
+ {
+ return null;
+ }
+
+ public void removeEventListener(EventListener listener)
+ {
+ }
+
+ public void setIdManager(SessionIdManager idManager)
+ {
+ }
+
+ public void setMaxCookieAge(int maxCookieAge)
+ {
+ }
+
+ public void setMaxInactiveInterval(int seconds)
+ {
+ }
+
+ public void setSessionCookie(String cookieName)
+ {
+ }
+
+ public void setSessionDomain(String domain)
+ {
+ }
+
+ public void setSessionHandler(SessionHandler handler)
+ {
+ }
+
+ public void setSessionIdPathParameterName(String parameterName)
+ {
+ }
+
+ public void setSessionPath(String path)
+ {
+ }
+
+ public void addLifeCycleListener(Listener listener)
+ {
+ }
+
+ public boolean isFailed()
+ {
+ return false;
+ }
+
+ public boolean isRunning()
+ {
+ return false;
+ }
+
+ public boolean isStarted()
+ {
+ return false;
+ }
+
+ public boolean isStarting()
+ {
+ return false;
+ }
+
+ public boolean isStopped()
+ {
+ return false;
+ }
+
+ public boolean isStopping()
+ {
+ return false;
+ }
+
+ public void removeLifeCycleListener(Listener listener)
+ {
+ }
+
+ public void start() throws Exception
+ {
+ }
+
+ public void stop() throws Exception
+ {
+ }
+
+ /**
+ * @see org.eclipse.jetty.server.SessionManager#getDefaultSessionTrackingModes()
+ */
+ public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jetty.server.SessionManager#getEffectiveSessionTrackingModes()
+ */
+ public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jetty.server.SessionManager#getSessionCookieConfig()
+ */
+ public SessionCookieConfig getSessionCookieConfig()
+ {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jetty.server.SessionManager#isUsingURLs()
+ */
+ public boolean isUsingURLs()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jetty.server.SessionManager#setSessionTrackingModes(java.util.Set)
+ */
+ public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+}
Modified: jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -37,6 +37,7 @@
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -46,6 +47,7 @@
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
+import org.eclipse.jetty.util.IO;
/**
* HttpServer Tester.
@@ -75,23 +77,25 @@
private static final String RESPONSE1="HTTP/1.1 200 OK\n"+"Connection: close\n"+"Server: Jetty("+JETTY_VERSION+")\n"+'\n'+HELLO_WORLD;
private static final TrustManager[] s_dummyTrustManagers=new TrustManager[]
- { new X509TrustManager()
- {
- public java.security.cert.X509Certificate[] getAcceptedIssuers()
+ {
+ new X509TrustManager()
{
- return null;
- }
+ public java.security.cert.X509Certificate[] getAcceptedIssuers()
+ {
+ return null;
+ }
- public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
+ public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
- {
- }
+ {
+ }
- public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
+ public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
- {
+ {
+ }
}
- } };
+ };
Server server;
SslSelectChannelConnector connector;
@@ -113,6 +117,8 @@
connector.setKeystore(keystore);
connector.setPassword("storepwd");
connector.setKeyPassword("keypwd");
+ connector.setRequestBufferSize(512);
+ connector.setRequestHeaderSize(512);
server.setConnectors(new Connector[]
{ connector });
@@ -134,16 +140,45 @@
{
}
+
+ /**
+ * Feed the server the entire request at once.
+ *
+ * @throws Exception
+ */
+ public void testBigResponse() throws Exception
+ {
+ SSLContext ctx=SSLContext.getInstance("SSLv3");
+ ctx.init(null,s_dummyTrustManagers,new java.security.SecureRandom());
+
+ int port=connector.getLocalPort();
+
+ Socket client=ctx.getSocketFactory().createSocket("localhost",port);
+ OutputStream os=client.getOutputStream();
+
+ String request =
+ "GET /?dump=102400 HTTP/1.1\r\n"+
+ "Host: localhost:8080\r\n"+
+ "Connection: close\r\n"+
+ "\r\n";
+
+ os.write(request.getBytes());
+ os.flush();
+
+ String response = IO.toString(client.getInputStream());
+
+ assertTrue(response.length()>102400);
+ }
/**
* Feed the server the entire request at once.
*
* @throws Exception
*/
- public void /*test*/RequestJettyHttps() throws Exception
+ public void testRequestJettyHttps() throws Exception
{
- final int loops=100;
- final int numConns=100;
+ final int loops=10;
+ final int numConns=10;
Socket[] client=new Socket[numConns];
@@ -259,15 +294,21 @@
{
// System.err.println("HANDLE "+request.getRequestURI());
String ssl_id = (String)request.getAttribute("javax.servlet.request.ssl_session_id");
- //assertNotNull(ssl_id);
- PrintWriter out=response.getWriter();
+ assertNotNull(ssl_id);
- try
+ if (request.getParameter("dump")!=null)
{
+ ServletOutputStream out=response.getOutputStream();
+ byte[] buf = new byte[Integer.valueOf(request.getParameter("dump"))];
+ for (int i=0;i<buf.length;i++)
+ buf[i]=(byte)('0'+(i%10));
+ out.write(buf);
+ out.close();
+ }
+ else
+ {
+ PrintWriter out=response.getWriter();
out.print(HELLO_WORLD);
- }
- finally
- {
out.close();
}
}
@@ -353,6 +394,7 @@
}
}
+
public static class StreamHandler extends AbstractHandler
{
public int bytes=0;
Modified: jetty/branches/jetty-8/jetty-servlet/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-servlet/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlet/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -9,6 +9,9 @@
<artifactId>jetty-servlet</artifactId>
<name>Jetty :: Servlet Handling</name>
<description>Jetty Servlet Container</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.servlet</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -44,6 +47,12 @@
</execution>
</executions>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
===================================================================
--- jetty/branches/jetty-8/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -762,9 +762,7 @@
{
// Parse the satisfiable ranges
List ranges =InclusiveByteRange.satisfiableRanges(reqRanges,content_length);
-
- System.err.println(ranges+" "+request.getHeader(HttpHeaders.RANGE)+" "+content_length);
-
+
// if there are no satisfiable ranges, send 416 response
if (ranges==null || ranges.size()==0)
{
Modified: jetty/branches/jetty-8/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
===================================================================
--- jetty/branches/jetty-8/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1080,7 +1080,15 @@
_servletPathMap=pm;
}
-
+ // flush filter chain cache
+ if (_chainCache!=null)
+ {
+ for (int i=_chainCache.length;i-->0;)
+ {
+ if (_chainCache[i]!=null)
+ _chainCache[i].clear();
+ }
+ }
if (Log.isDebugEnabled())
{
Deleted: jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AbstractSessionTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AbstractSessionTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AbstractSessionTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1,176 +0,0 @@
-// ========================================================================
-// Copyright (c) 2008-2009 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-
-package org.eclipse.jetty.servlet;
-
-import junit.framework.TestCase;
-
-public abstract class AbstractSessionTest extends TestCase
-{
- public static final String __host1 = "localhost";
- public static final String __host2 = __host1;
- public static final String __port1 = "8010";
- public static final String __port2 = "8011";
- SessionTestServer _server1;
- SessionTestServer _server2;
-
- public abstract SessionTestServer newServer1 ();
-
- public abstract SessionTestServer newServer2();
-
- public void setUp () throws Exception
- {
- _server1 = newServer1();
- _server2 = newServer2();
- _server1.start();
- _server2.start();
- }
-
- public void tearDown () throws Exception
- {
- if (_server1 != null)
- _server1.stop();
- if (_server2 != null)
- _server2.stop();
-
- _server1=null;
- _server2=null;
- }
-
-
- public void testSessions () throws Exception
- {
- SessionTestClient client1 = new SessionTestClient("http://"+__host1+":"+__port1);
- SessionTestClient client2 = new SessionTestClient("http://"+__host2+":"+__port2);
- // confirm that user has no session
- assertFalse(client1.send("/contextA", null));
- String cookie1 = client1.newSession("/contextA");
- assertNotNull(cookie1);
- System.err.println("cookie1: " + cookie1);
-
- // confirm that client2 has the same session attributes as client1
- assertTrue(client1.setAttribute("/contextA", cookie1, "foo", "bar"));
- assertTrue(client2.hasAttribute("/contextA", cookie1, "foo", "bar"));
-
- // confirm that /contextA would share same sessionId as /contextB
- assertTrue(client1.send("/contextA/dispatch/forward/contextB", cookie1));
- assertTrue(client2.send("/contextA/dispatch/forward/contextB", cookie1));
- assertTrue(client1.send("/contextB", cookie1));
-
- // verify that session attributes on /contextA is different from /contextB
- assertFalse(client1.hasAttribute("/contextB/action", cookie1, "foo", "bar"));
-
- // add new session attributes on /contextB
- client1.setAttribute("/contextB/action", cookie1, "zzzzz", "yyyyy");
- assertTrue(client1.hasAttribute("/contextB/action", cookie1, "zzzzz", "yyyyy"));
-
- // verify that client2 has same sessionAttributes on /contextB
- // client1's newly added attribute "zzzzz" needs to be flushed to the database first
- // saveInterval is configured at 10s... to test, uncomment the 2 lines below.
- //Thread.sleep(10000);
- //assertTrue(client2.hasAttribute("/contextB/action", cookie1, "zzzzz", "yyyyy"));
-
- String cookie2 = client2.newSession("/contextA");
- assertNotNull(cookie2);
- System.err.println("cookie2: " + cookie2);
-
- // confirm that client1 has same session attributes as client2
- assertTrue(client2.setAttribute("/contextA", cookie2, "hello", "world"));
- assertTrue(client1.hasAttribute("/contextA", cookie2, "hello", "world"));
-
- // confirm that /contextA would share same sessionId as /contextB
- assertTrue(client1.send("/contextA/dispatch/forward/contextB", cookie2));
- assertTrue(client2.send("/contextA/dispatch/forward/contextB", cookie2));
- assertTrue(client1.send("/contextB", cookie2));
-
- // Session invalidate on contextA
- assertTrue(client1.invalidate("/contextA", cookie1));
-
- // confirm that session on contextB has not been invalidated after contextA has been invalidated
- assertTrue(client1.send("/contextB", cookie1));
-
- // confirm that session on contextA has been deleted
- assertFalse(client1.send("/contextA", cookie1));
-
- // Session invalidate on contextB
- assertTrue(client1.invalidate("/contextB/action", cookie1));
-
- // confirm that session on contextB has been deleted
- assertFalse(client1.send("/contextB/action", cookie1));
-
- // session will reflect after 10s, so node2 still would not be deleted.
- assertTrue(client2.send("/contextB/action", cookie1));
-
- // wait for saveInterval and check if the session invalidation has been reflected to the other node
- // to test, uncomment 3 lines below
- //Thread.sleep(10000);
- //assertFalse(client2.send("/contextA", cookie1));
- //assertFalse(client2.send("/contextB/action", cookie1));
- }
-
- public void testSessionManagerStop() throws Exception
- {
- SessionTestClient client1 = new SessionTestClient("http://"+__host1+":"+__port1);
- SessionTestClient client2 = new SessionTestClient("http://"+__host2+":"+__port2);
- // confirm that user has no session
- assertFalse(client1.send("/contextA", null));
- String cookie1 = client1.newSession("/contextA");
- assertNotNull(cookie1);
- System.err.println("cookie1: " + cookie1);
-
- // creates a session for contextB
- assertTrue(client1.send("/contextB", cookie1));
-
- // confirm that /contextA and /contextB sessions are available
- assertTrue(client1.send("/contextA", cookie1));
- assertTrue(client1.send("/contextB/action", cookie1));
- assertTrue(client1.setAttribute("/contextA", cookie1, "a", "b"));
- assertTrue(client1.setAttribute("/contextB/action", cookie1, "c", "d"));
-
- // confirm that /contextA and /contextB sessions from client2 are available
- assertTrue(client2.send("/contextA", cookie1));
- assertTrue(client2.send("/contextB/action", cookie1));
- assertTrue(client2.hasAttribute("/contextA", cookie1, "a", "b"));
- assertTrue(client2.hasAttribute("/contextB/action", cookie1, "c", "d"));
-
- // stop sessionManager from node1
- _server1._sessionMgr1.stop();
-
- // verify session still exists for contextB
- assertTrue(client1.send("/contextB/action", cookie1));
- assertTrue(client1.hasAttribute("/contextB/action", cookie1, "c", "d"));
-
- // stop sessionManager from node2
- _server2._sessionMgr2.stop();
-
- // verfiy session still exists for contextA
- assertTrue(client2.send("/contextA", cookie1));
- assertTrue(client2.hasAttribute("/contextA", cookie1, "a", "b"));
- }
-
- public void testFailover() throws Exception
- {
- SessionTestClient client1 = new SessionTestClient("http://"+__host1+":"+__port1);
- SessionTestClient client2 = new SessionTestClient("http://"+__host2+":"+__port2);
- // confirm that user has no session
- assertFalse(client1.send("/contextA", null));
- String cookie1 = client1.newSession("/contextA");
-
- assertNotNull(cookie1);
- System.err.println("cookie1: " + cookie1);
-
- assertTrue(client1.setAttribute("/contextA", cookie1, "a", "b"));
-
- assertTrue(client2.hasAttribute("/contextA", cookie1, "a", "b"));
- }
-}
Deleted: jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/SessionTestClient.java
===================================================================
--- jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/SessionTestClient.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/SessionTestClient.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1,125 +0,0 @@
-// ========================================================================
-// Copyright (c) 2008-2009 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-
-
-package org.eclipse.jetty.servlet;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-public class SessionTestClient
-{
-
- private String _baseUrl;
-
- // e.g http://localhost:8010
- public SessionTestClient(String baseUrl)
- {
- _baseUrl = baseUrl;
- }
-
- public boolean send(String context, String cookie) throws Exception
- {
- HttpURLConnection conn = sendRequest("GET", new URL(_baseUrl + context + "/session/"),
- cookie);
- return isSessionAvailable(conn);
- }
-
- public String newSession(String context) throws Exception
- {
- HttpURLConnection conn = sendRequest("POST", new URL(_baseUrl + context +
- "/session/?Action=New%20Session"), null);
- conn.disconnect();
- return getJSESSIONID(conn.getHeaderField("Set-Cookie"));
- }
-
- public boolean setAttribute(String context, String cookie, String name, String value) throws Exception
- {
- // should be POST, GET for now
- HttpURLConnection conn = sendRequest("GET", new URL(_baseUrl + context +
- "/session/?Action=Set&Name=" + name + "&Value=" + value), cookie);
- return isAttributeSet(conn, name, value);
- }
-
- public boolean hasAttribute(String context, String cookie, String name, String value) throws Exception
- {
- HttpURLConnection conn = sendRequest("GET", new URL(_baseUrl + context + "/session/"),
- cookie);
- return isAttributeSet(conn, name, value);
- }
-
- public boolean invalidate(String context, String cookie) throws Exception
- {
- // should be POST, GET for now
- HttpURLConnection conn = sendRequest("GET", new URL(_baseUrl + context +
- "/session/?Action=Invalidate"), cookie);
- return !isSessionAvailable(conn);
- }
-
- protected static boolean isSessionAvailable(HttpURLConnection conn) throws Exception
- {
- return !isTokenPresent(conn, "<H3>No Session</H3>");
- }
-
- protected static boolean isAttributeSet(HttpURLConnection conn, String name, String value) throws Exception
- {
- return isTokenPresent(conn, "<b>" + name + ":</b> " + value + "<br/>");
- }
-
- protected static boolean isTokenPresent(HttpURLConnection conn, String token) throws Exception
- {
- BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- String line = null;
- boolean present = false;
- while((line=br.readLine())!=null)
- {
-
- if(line.indexOf(token)!=-1)
- {
- present = true;
- break;
- }
- }
- conn.disconnect();
- return present;
- }
-
- public HttpURLConnection sendRequest(String method, URL url, String cookie) throws Exception
- {
- return sendRequest(method, url, cookie, false);
- }
-
- public HttpURLConnection sendRequest(String method, URL url, String cookie,
- boolean followRedirects) throws Exception
- {
- HttpURLConnection conn = (HttpURLConnection)url.openConnection();
- conn.setRequestMethod(method);
- conn.setDoInput(true);
- conn.setInstanceFollowRedirects(followRedirects);
- if(cookie!=null)
- conn.setRequestProperty("Cookie", cookie);
- conn.connect();
- return conn;
- }
-
- protected static String getJSESSIONID(String cookie)
- {
- System.err.println("COOKIE: " + cookie);
- int idx = cookie.indexOf("JSESSIONID");
- return cookie.substring(idx, cookie.indexOf(';', idx));
- }
-
-
-}
Deleted: jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/SessionTestServer.java
===================================================================
--- jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/SessionTestServer.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/SessionTestServer.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1,349 +0,0 @@
-// ========================================================================
-// Copyright (c) 2008-2009 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-
-package org.eclipse.jetty.servlet;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.Enumeration;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.SessionIdManager;
-import org.eclipse.jetty.server.SessionManager;
-import org.eclipse.jetty.server.handler.ContextHandlerCollection;
-
-/**
- * SessionTestServer
- *
- * Base class for common backend to test various session plugin
- * implementations.
- *
- * The backend runs 2 jetty servers, with 2 contexts each:
- *
- * contextA/session - dumps and allows create/delete of a session
- * contextA/dispatch/forward/contextB/session - forwards to contextB
- * contextB/session - dumps and allows create/delete of a session
- *
- * Subclasses should implement the configureEnvironment(),
- * configureSessionIdManager(), configureSessionManager1(),
- * configureSessionManager2() in order to provide the session
- * management implementations to test.
- */
-public abstract class SessionTestServer extends Server
-{
- protected SessionIdManager _sessionIdMgr;
- protected SessionManager _sessionMgr1;
- protected SessionManager _sessionMgr2;
- protected String _workerName;
-
-
- /**
- * ForwardingServlet
- * Do dispatch forward to test re-use of session id (BUT NOT CONTENTS!)
- *
- */
- public class ForwardingServlet extends HttpServlet
- {
- public void doGet (HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
- String pathInfo = request.getPathInfo();
-
- HttpSession session = request.getSession(false);
-
- if (pathInfo.startsWith("/forward/"))
- {
- pathInfo = pathInfo.substring(8);
- String cpath = pathInfo.substring(0, pathInfo.indexOf('/', 1));
- pathInfo = pathInfo.substring(cpath.length());
- ServletContext context = ((Request)request).getServletContext().getContext(cpath);
- RequestDispatcher dispatcher = context.getRequestDispatcher(pathInfo);
- dispatcher.forward(request, response);
- }
- }
- }
-
-
-
- /**
- * SessionDumpServlet
- *
- * Servlet to dump the contents of the session.
- */
- public class SessionDumpServlet extends HttpServlet
- {
- int redirectCount=0;
-
- public void init(ServletConfig config)
- throws ServletException
- {
- super.init(config);
- }
-
-
- public void dump(HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException
- {
- response.setContentType("text/html");
-
- HttpSession session = request.getSession(getURI(request).indexOf("new")>0);
- try
- {
- if (session!=null)
- session.isNew();
- }
- catch(IllegalStateException e)
- {
- session=null;
- e.printStackTrace();
- }
-
- PrintWriter out = response.getWriter();
- out.println("<h1>Session Dump Servlet:</h1>");
- String submitUrl = getServletContext().getContextPath();
- submitUrl = (submitUrl.equals("")?"/":submitUrl);
- submitUrl = (submitUrl.endsWith("/")?submitUrl:submitUrl+"/");
- submitUrl += "session/";
- out.println("<form action=\""+submitUrl+"\" method=\"post\">");
-
- if (session==null)
- {
- out.println("<H3>No Session</H3>");
- out.println("<input type=\"submit\" name=\"Action\" value=\"New Session\"/>");
- }
- else
- {
- try
- {
- out.println("<b>ID:</b> "+session.getId()+"<br/>");
- out.println("<b>New:</b> "+session.isNew()+"<br/>");
- out.println("<b>Created:</b> "+new Date(session.getCreationTime())+"<br/>");
- out.println("<b>Last:</b> "+new Date(session.getLastAccessedTime())+"<br/>");
- out.println("<b>Max Inactive:</b> "+session.getMaxInactiveInterval()+"<br/>");
- out.println("<b>Context:</b> "+session.getServletContext()+"<br/>");
-
-
- Enumeration keys=session.getAttributeNames();
- while(keys.hasMoreElements())
- {
- String name=(String)keys.nextElement();
- String value=""+session.getAttribute(name);
-
- out.println("<b>"+name+":</b> "+value+"<br/>");
- }
-
- out.println("<b>Name:</b><input type=\"text\" name=\"Name\" /><br/>");
- out.println("<b>Value:</b><input type=\"text\" name=\"Value\" /><br/>");
-
- out.println("<input type=\"submit\" name=\"Action\" value=\"Set\"/>");
- out.println("<input type=\"submit\" name=\"Action\" value=\"Remove\"/>");
- out.println("<input type=\"submit\" name=\"Action\" value=\"Refresh\"/>");
- out.println("<input type=\"submit\" name=\"Action\" value=\"Invalidate\"/><br/>");
-
- out.println("</form><br/>");
-
- if (request.isRequestedSessionIdFromCookie())
- out.println("<P>Turn off cookies in your browser to try url encoding<BR>");
-
- if (request.isRequestedSessionIdFromURL())
- out.println("<P>Turn on cookies in your browser to try cookie encoding<BR>");
- out.println("<a href=\""+response.encodeURL(request.getRequestURI()+"?q=0")+"\">Encoded Link</a><BR>");
-
- }
- catch (IllegalStateException e)
- {
- e.printStackTrace();
- }
- }
- }
-
-
- public String getServletInfo() {
- return "Session Dump Servlet";
- }
-
-
- public String getURI(HttpServletRequest request)
- {
- String uri=(String)request.getAttribute("javax.servlet.forward.request_uri");
- if (uri==null)
- uri=request.getRequestURI();
- return uri;
- }
- }
- /**
- * SessionForwardedServlet
- *
- * Servlet that is target of a dispatch forward.
- * It will always try and make a new session, and then dump its
- * contents as html.
- */
- public class SessionForwardedServlet extends SessionDumpServlet
- {
-
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
- handleForm(request, response);
- dump(request, response);
- }
-
- protected void handleForm(HttpServletRequest request,
- HttpServletResponse response)
- {
- HttpSession session = request.getSession(false);
- String action = request.getParameter("Action");
- String name = request.getParameter("Name");
- String value = request.getParameter("Value");
-
- if (action!=null)
- {
- if(action.equals("New Session"))
- {
- session = request.getSession(true);
- session.setAttribute("test","value");
- }
- else if (session!=null)
- {
- if (action.equals("Invalidate"))
- session.invalidate();
- else if (action.equals("Set") && name!=null && name.length()>0)
- session.setAttribute(name,value);
- else if (action.equals("Remove"))
- session.removeAttribute(name);
- }
- }
- }
-
-
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException
- {
- request.getSession(true);
- dump(request, response);
- }
- }
-
-
- /**
- * SessionActionServlet
- *
- * Servlet to allow making a new session under user control
- * by clicking the "New Session" button (ie query params ?Action=New Session)
- */
- public class SessionActionServlet extends SessionDumpServlet
- {
- protected void handleForm(HttpServletRequest request,
- HttpServletResponse response)
- {
- HttpSession session = request.getSession(false);
- String action = request.getParameter("Action");
- String name = request.getParameter("Name");
- String value = request.getParameter("Value");
-
- if (action!=null)
- {
- if(action.equals("New Session"))
- {
- session = request.getSession(true);
- session.setAttribute("test","value");
- }
- else if (session!=null)
- {
- if (action.equals("Invalidate"))
- session.invalidate();
- else if (action.equals("Set") && name!=null && name.length()>0)
- session.setAttribute(name,value);
- else if (action.equals("Remove"))
- session.removeAttribute(name);
- }
- }
- }
-
- public void doPost(HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException
- {
- handleForm(request,response);
- String nextUrl = getURI(request)+"?R="+redirectCount++;
- String encodedUrl=response.encodeRedirectURL(nextUrl);
- response.sendRedirect(encodedUrl);
- }
-
- public void doGet (HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException
- {
- handleForm(request,response);
- dump(request, response);
- }
- }
-
- public SessionTestServer(int port, String workerName)
- {
- super(port);
- _workerName = workerName;
- configureEnvironment();
- configureIdManager();
- configureSessionManager1();
- configureSessionManager2();
- configureServer();
- }
-
- public abstract void configureEnvironment ();
-
- public abstract void configureIdManager();
-
- public abstract void configureSessionManager1();
-
- public abstract void configureSessionManager2();
-
- public void configureServer ()
- {
- if (_sessionIdMgr == null || _sessionMgr1 == null || _sessionMgr2 == null)
- throw new IllegalStateException ("Must set a SessionIdManager instance and 2 SessionManager instances");
-
- setSessionIdManager(_sessionIdMgr);
- //set up 2 contexts and a filter than can forward between them
- ContextHandlerCollection contextsA = new ContextHandlerCollection();
- setHandler(contextsA);
- setSessionIdManager(_sessionIdMgr);
-
- ServletContextHandler contextA1 = new ServletContextHandler(contextsA,"/contextA",ServletContextHandler.SESSIONS);
- contextA1.addServlet(new ServletHolder(new SessionActionServlet()), "/session/*");
- contextA1.addServlet(new ServletHolder(new ForwardingServlet()), "/dispatch/*");
- contextA1.getSessionHandler().setSessionManager(_sessionMgr1);
- _sessionMgr1.setIdManager(_sessionIdMgr);
-
-
- ServletContextHandler contextA2 = new ServletContextHandler(contextsA, "/contextB", ServletContextHandler.SESSIONS);
- contextA2.addServlet(new ServletHolder(new SessionForwardedServlet()), "/session/*");
- contextA2.addServlet(new ServletHolder(new SessionActionServlet()), "/action/session/*");
- contextA2.getSessionHandler().setSessionManager(_sessionMgr2);
- _sessionMgr2.setIdManager(_sessionIdMgr);
- }
-
-}
Modified: jetty/branches/jetty-8/jetty-servlets/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-servlets/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlets/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -9,6 +9,9 @@
<artifactId>jetty-servlets</artifactId>
<name>Jetty :: Utility Servlets and Filters</name>
<description>Utility Servlets from Jetty</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.servlets</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -36,6 +39,12 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CGI.java
===================================================================
--- jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CGI.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CGI.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -309,7 +309,7 @@
String value = line.substring(k+1).trim();
if ("Location".equals(key))
{
- res.sendRedirect(value);
+ res.sendRedirect(res.encodeRedirectURL(value));
}
else if ("Status".equals(key))
{
Modified: jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java
===================================================================
--- jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -664,6 +664,12 @@
else
_rateTrackers.remove(_id);
}
+
+ @Override
+ public String toString()
+ {
+ return "RateTracker/"+_id+"/"+_type;
+ }
}
class FixedRateTracker extends RateTracker
@@ -673,6 +679,7 @@
super(id,type,numRecentRequestsTracked);
}
+ @Override
public boolean isRateExceeded(long now)
{
// rate limit is never exceeded, but we keep track of the request timestamps
@@ -685,6 +692,12 @@
}
return false;
- }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Fixed"+super.toString();
+ }
}
}
\ No newline at end of file
Modified: jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java
===================================================================
--- jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -485,8 +485,9 @@
}
if (_gzOut!=null)
- _gzOut.finish();
- _out.close();
+ _gzOut.close();
+ else
+ _out.close();
_closed=true;
}
}
@@ -503,8 +504,11 @@
doGzip();
}
- if (_gzOut!=null)
- _gzOut.finish();
+ if (_gzOut!=null && !_closed)
+ {
+ _closed=true;
+ _gzOut.close();
+ }
}
}
Modified: jetty/branches/jetty-8/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -269,7 +269,12 @@
String request1="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nCookie: " + sessionId1 + "\r\n\r\n";
String request2="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nCookie: " + sessionId2 + "\r\n\r\n";
String last="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\nCookie: " + sessionId2 + "\r\n\r\n";
- String responses = doRequests(request1+request2+request1+request2+request1,2,1100,1100,last);
+
+ // ensure the sessions are new
+ String responses = doRequests(request1+request2,1,1100,1100,last);
+ Thread.sleep(1000);
+
+ responses = doRequests(request1+request2+request1+request2+request1,2,1100,1100,last);
assertEquals(11,count(responses,"HTTP/1.1 200 OK"));
assertEquals(0,count(responses,"DoSFilter: delayed"));
Modified: jetty/branches/jetty-8/jetty-start/src/main/java/org/eclipse/jetty/start/README.txt
===================================================================
--- jetty/branches/jetty-8/jetty-start/src/main/java/org/eclipse/jetty/start/README.txt 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-start/src/main/java/org/eclipse/jetty/start/README.txt 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1,38 +1,47 @@
Jetty start
-----------
-Jetty start provides a cross platform replacement for startup scripts.
-It makes use of executable JAR mechanism, which lets application packaged as JAR
-to be started with simple command line:
+The run directory is either the top-level of a distribution
+or jetty-distribution/target/distribution directory when built from
+source.
- java -jar start.jar [jetty.xml ... ]
+Jetty start.jar provides a cross platform replacement for startup scripts.
+It makes use of executable JAR that builds the classpath and then executes
+jetty.
-or to see debug output
+To run with all the demo options:
- java -Dorg.eclipse.jetty.launcher.debug=true -jar start.jar [jetty.xml ... ]
+ java -jar start.jar OPTIONS=All
-What launcher does is:
+To run with the default options:
-- Figures out correct location of Jetty home directory.
+ java -jar start.jar
-- Configures classpath based on which JDK version it has been run with
-and what classes are available (for example, someone might have servlet classes
-in ext directory of JDK, or JSSE needs to be inlcuded on JDK 1.3 but is
-built-in in JDK 1.4 etc.)
-- Looks for Sun's JAVAC (required for Jasper JSP engine)
-and puts it in classpath. For this to work, launcher has to be started
-with JDK, not JRE!
-- After classpath has been configured, it invokes org.eclipse.jetty.Server
-with any command line arguments it received.
-- When there are no commandline args, launcher starts Jetty Demo
-(using configuration files etc/demo.xml and etc/admin.xml) and on Windows
-platform it also attemts to invoke Internet Explorer with jetty demo URL
-(http://localhost:8080/).
+The default options may be specified in the start.ini file, or if
+that is not present, they are defined in the start.config file that
+is within the start.jar.
-This means Windows users who have file type association for JAR files
-setup to launch jar using JDK can now lauch jetty with simple
-doubleclick on start.jar, or typing "start.jar" in shell window when in Jetty
-home directory.
+To run with specific configuration file(s)
-Any unknown JARs found in ext subdirectory of Jetty home will be
-added to classpath. Users can place libraries common to multiple contexts there.
+ java -jar start.jar etc/jetty.xml
+
+To see the available options
+
+ java -jar start.jar --help
+
+To run with JSP support (if available)
+
+ java -jar start.jar OPTIONS=Server,jsp
+
+To run with JMX support
+
+ java -jar start.jar OPTIONS=Server,jmx etc/jetty-jmx.xml etc/jetty.xml
+
+To run with JSP & JMX support
+
+ java -jar start.jar OPTIONS=Server,jsp,jmx etc/jetty-jmx.xml etc/jetty.xml
+
+Note that JSP requires the jasper jars to be within $JETTY/lib/jsp These
+are currently not distributed with the eclipse release and must be
+obtained from a jetty-hightide release from codehaus.
+
Modified: jetty/branches/jetty-8/jetty-util/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-util/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-util/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-util</artifactId>
<name>Jetty :: Utilities</name>
<description>Utility classes for Jetty</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.util</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -57,6 +60,12 @@
</execution>
</executions>
</plugin>
+ <!-- Always create the source bundle. the configuration is inherited by the parent pom. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+
</plugins>
</build>
<dependencies>
Modified: jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java
===================================================================
--- jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -493,7 +493,7 @@
}
// Do the delete
- if (skip<=0 && delStart>=0 && delStart>=0)
+ if (skip<=0 && delStart>=0 && delEnd>=delStart)
{
buf.delete(delStart,delEnd);
delStart=delEnd=-1;
Modified: jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java
===================================================================
--- jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -130,7 +130,7 @@
public void removeLifeCycleListener(LifeCycle.Listener listener)
{
- LazyList.removeFromArray(_listeners,listener);
+ _listeners = (LifeCycle.Listener[])LazyList.removeFromArray(_listeners,listener);
}
public String getState()
Modified: jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java
===================================================================
--- jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -226,18 +226,18 @@
private void format(String msg, Object arg0, Object arg1)
{
- int i0=msg.indexOf("{}");
+ int i0=msg==null?-1:msg.indexOf("{}");
int i1=i0<0?-1:msg.indexOf("{}",i0+2);
if (i0>=0)
{
format(msg.substring(0,i0));
- format(String.valueOf(arg0));
+ format(String.valueOf(arg0==null?"null":arg0));
if (i1>=0)
{
format(msg.substring(i0+2,i1));
- format(String.valueOf(arg1));
+ format(String.valueOf(arg1==null?"null":arg1));
format(msg.substring(i1+2));
}
else
@@ -268,32 +268,40 @@
private void format(String msg)
{
- for (int i=0;i<msg.length();i++)
- {
- char c=msg.charAt(i);
- if (Character.isISOControl(c))
+ if (msg == null)
+ _buffer.append("null");
+ else
+ for (int i=0;i<msg.length();i++)
{
- if (c=='\n')
- _buffer.append('|');
- else if (c=='\r')
- _buffer.append('<');
+ char c=msg.charAt(i);
+ if (Character.isISOControl(c))
+ {
+ if (c=='\n')
+ _buffer.append('|');
+ else if (c=='\r')
+ _buffer.append('<');
+ else
+ _buffer.append('?');
+ }
else
- _buffer.append('?');
+ _buffer.append(c);
}
- else
- _buffer.append(c);
- }
}
private void format(Throwable th)
{
- _buffer.append(LN);
- format(th.toString());
- StackTraceElement[] elements = th.getStackTrace();
- for (int i=0;elements!=null && i<elements.length;i++)
+ if (th == null)
+ _buffer.append("null");
+ else
{
- _buffer.append(LN).append("\tat ");
- format(elements[i].toString());
+ _buffer.append('\n');
+ format(th.toString());
+ StackTraceElement[] elements = th.getStackTrace();
+ for (int i=0;elements!=null && i<elements.length;i++)
+ {
+ _buffer.append("\n\tat ");
+ format(elements[i].toString());
+ }
}
}
Modified: jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java
===================================================================
--- jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -449,25 +449,21 @@
job=_jobs.take();
else
{
- job=_jobs.poll(_maxIdleTimeMs,TimeUnit.MILLISECONDS);
-
- if (job==null)
+ // maybe we should shrink?
+ final int size=_threadsStarted.get();
+ if (size>_minThreads)
{
- // maybe we should shrink?
- final int size=_threadsStarted.get();
- if (size>_minThreads)
+ long last=_lastShrink.get();
+ long now=System.currentTimeMillis();
+ if (last==0 || (now-last)>_maxIdleTimeMs)
{
- long last=_lastShrink.get();
- long now=System.currentTimeMillis();
- if (last==0 || (now-last)>_maxIdleTimeMs)
- {
- shrink=_lastShrink.compareAndSet(last,now) &&
- _threadsStarted.compareAndSet(size,size-1);
- if (shrink)
- return;
- }
+ shrink=_lastShrink.compareAndSet(last,now) &&
+ _threadsStarted.compareAndSet(size,size-1);
+ if (shrink)
+ return;
}
}
+ job=_jobs.poll(_maxIdleTimeMs,TimeUnit.MILLISECONDS);
}
}
}
Modified: jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Timeout.java
===================================================================
--- jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Timeout.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Timeout.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -369,7 +369,7 @@
* outside of any synchronization scope and may be delayed.
*
*/
- protected void expired(){}
+ public void expired(){}
}
Modified: jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -125,6 +125,27 @@
assertTrue("The lifecycle state is not stooped",lifecycle.isStopped());
}
+
+ public void testRemoveLifecycleListener ()
+ throws Exception
+ {
+
+
+ TestLifeCycle lifecycle = new TestLifeCycle();
+ TestListener listener = new TestListener();
+ lifecycle.addLifeCycleListener(listener);
+
+ lifecycle.start();
+ ((StdErrLog)Log.getLog()).setHideStacks(true);
+ assertTrue("The starting event didn't occur",listener.starting);
+ lifecycle.removeLifeCycleListener(listener);
+ lifecycle.stop();
+ assertFalse("The stopping event occurred", listener.stopping);
+
+
+
+
+ }
private class TestLifeCycle extends AbstractLifeCycle
{
Exception cause;
@@ -154,6 +175,8 @@
cause=e;
}
}
+
+
private class TestListener implements LifeCycle.Listener
{
Copied: jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java)
===================================================================
--- jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java (rev 0)
+++ jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,60 @@
+// ========================================================================
+// Copyright (c) 2010-2010 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.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.log;
+
+import junit.framework.TestCase;
+
+/**
+ * @author mgorovoy
+ * */
+public class StdErrLogTest extends TestCase
+{
+ public void testNullValues()
+ {
+ StdErrLog log = new StdErrLog();
+ log.setDebugEnabled(true);
+
+ try {
+ log.info("Testing info(msg,null,null) - {} {}",null,null);
+ log.info("Testing info(msg,null,null) - {}",null,null);
+ log.info("Testing info(msg,null,null)",null,null);
+ log.info(null,"- Testing","info(null,arg0,arg1)");
+ log.info(null,null,null);
+
+ log.debug("Testing debug(msg,null,null) - {} {}",null,null);
+ log.debug("Testing debug(msg,null,null) - {}",null,null);
+ log.debug("Testing debug(msg,null,null)",null,null);
+ log.debug(null,"- Testing","debug(null,arg0,arg1)");
+ log.debug(null,null,null);
+
+ log.debug("Testing debug(msg,null)",null);
+ log.debug(null,new Throwable("IGNORE::Testing debug(null,thrw)").fillInStackTrace());
+
+ log.warn("Testing warn(msg,null,null) - {} {}",null,null);
+ log.warn("Testing warn(msg,null,null) - {}",null,null);
+ log.warn("Testing warn(msg,null,null)",null,null);
+ log.warn(null,"- Testing","warn(msg,arg0,arg1)");
+ log.warn(null,null,null);
+
+ log.warn("Testing warn(msg,null)",null);
+ log.warn(null,new Throwable("IGNORE::Testing warn(msg,thrw)").fillInStackTrace());
+ }
+ catch (NullPointerException npe)
+ {
+ assertTrue("NullPointerException in StdErrLog.", false);
+ System.err.println(npe);
+ npe.printStackTrace();
+ }
+ }
+}
Modified: jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -21,8 +21,9 @@
public class QueuedThreadPoolTest extends TestCase
{
final AtomicInteger _jobs=new AtomicInteger();
+ volatile long _sleep=100;
- class Job implements Runnable
+ class RunningJob implements Runnable
{
public volatile boolean _running=true;
public void run()
@@ -30,7 +31,7 @@
try
{
while(_running)
- Thread.sleep(100);
+ Thread.sleep(_sleep);
}
catch(Exception e)
{
@@ -39,10 +40,13 @@
_jobs.incrementAndGet();
}
- };
+ };
+
+
public void testThreadPool() throws Exception
{
+ _sleep=100;
QueuedThreadPool tp= new QueuedThreadPool();
tp.setMinThreads(5);
tp.setMaxThreads(10);
@@ -57,7 +61,7 @@
assertEquals(5,tp.getThreads());
assertEquals(5,tp.getIdleThreads());
- Job job=new Job();
+ RunningJob job=new RunningJob();
tp.dispatch(job);
Thread.sleep(200);
assertEquals(5,tp.getThreads());
@@ -67,10 +71,10 @@
assertEquals(5,tp.getThreads());
assertEquals(5,tp.getIdleThreads());
- Job[] jobs = new Job[5];
+ RunningJob[] jobs = new RunningJob[5];
for (int i=0;i<jobs.length;i++)
{
- jobs[i]=new Job();
+ jobs[i]=new RunningJob();
tp.dispatch(jobs[i]);
}
Thread.sleep(200);
@@ -78,7 +82,7 @@
Thread.sleep(1000);
assertEquals(5,tp.getThreads());
- job=new Job();
+ job=new RunningJob();
tp.dispatch(job);
assertEquals(6,tp.getThreads());
@@ -100,10 +104,10 @@
assertEquals(5,tp.getThreads());
- jobs = new Job[15];
+ jobs = new RunningJob[15];
for (int i=0;i<jobs.length;i++)
{
- jobs[i]=new Job();
+ jobs[i]=new RunningJob();
tp.dispatch(jobs[i]);
}
assertEquals(10,tp.getThreads());
@@ -112,26 +116,77 @@
for (int i=0;i<9;i++)
jobs[i]._running=false;
- Thread.sleep(1000);
-
- assertTrue(tp.getThreads()<10);
+ Thread.sleep(1100);
int threads=tp.getThreads();
- Thread.sleep(1000);
+ assertTrue(threads<10);
+ Thread.sleep(1100);
assertTrue(tp.getThreads()<threads);
- threads=tp.getThreads();
- Thread.sleep(1000);
- assertTrue(tp.getThreads()<threads);
for (int i=9;i<jobs.length;i++)
jobs[i]._running=false;
- Thread.sleep(1000);
+ Thread.sleep(500);
tp.stop();
}
-
+ public void testShrink() throws Exception
+ {
+ Runnable job = new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ Thread.sleep(_sleep);
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ };
+
+ QueuedThreadPool tp= new QueuedThreadPool();
+ tp.setMinThreads(2);
+ tp.setMaxThreads(10);
+ tp.setMaxIdleTimeMs(400);
+ tp.setThreadsPriority(Thread.NORM_PRIORITY-1);
+
+ tp.start();
+ Thread.sleep(100);
+ assertEquals(2,tp.getThreads());
+ assertEquals(2,tp.getIdleThreads());
+ _sleep=200;
+ tp.dispatch(job);
+ tp.dispatch(job);
+ for (int i=0;i<20;i++)
+ tp.dispatch(job);
+ Thread.sleep(100);
+ assertEquals(10,tp.getThreads());
+ assertEquals(0,tp.getIdleThreads());
+
+ _sleep=5;
+ for (int i=0;i<500;i++)
+ {
+ tp.dispatch(job);
+ Thread.sleep(10);
+ if (i%100==0)
+ {
+ System.err.println(i+" threads="+tp.getThreads()+" idle="+tp.getIdleThreads());
+ }
+ }
+ System.err.println("500 threads="+tp.getThreads()+" idle="+tp.getIdleThreads());
+ Thread.sleep(100);
+ System.err.println("600 threads="+tp.getThreads()+" idle="+tp.getIdleThreads());
+ assertEquals(2,tp.getThreads());
+ assertEquals(2,tp.getIdleThreads());
+
+ }
+
public void testMaxStopTime() throws Exception
{
+ _sleep=100;
QueuedThreadPool tp= new QueuedThreadPool();
tp.setMaxStopTimeMs(500);
tp.start();
Modified: jetty/branches/jetty-8/jetty-webapp/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-webapp/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-webapp/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-webapp</artifactId>
<name>Jetty :: Webapp Application Support</name>
<description>Jetty web application support</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.webapp</bundle-symbolic-name>
+ </properties>
<build>
<resources>
<resource><directory>src/main/resources</directory></resource>
@@ -81,17 +84,8 @@
</plugin>
<!-- always include sources since jetty-xbean makes use of them -->
<plugin>
- <groupId>org.apache.maven.plugins
- </groupId>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
</plugin>
</plugins>
</build>
Modified: jetty/branches/jetty-8/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
===================================================================
--- jetty/branches/jetty-8/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -74,7 +74,7 @@
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration"//,
//"org.eclipse.jetty.webapp.TagLibConfiguration"
} ;
- private String[] _configurationClasses=__dftConfigurationClasses;
+ private String[] _configurationClasses=null;
private Configuration[] _configurations;
private String _defaultsDescriptor=WEB_DEFAULTS_XML;
private String _descriptor=null;
@@ -650,32 +650,20 @@
{
if (_configurations!=null)
return;
- if (_configurationClasses==null)
- _configurationClasses=__dftConfigurationClasses;
-
- int configsLen = _configurationClasses.length;
- @SuppressWarnings("unchecked")
- List<Configuration> serverConfigs = (List<Configuration>)getServer().getAttribute(SERVER_CONFIG);
+ //look for a Server attribute with the list of names of Configuration classes
+ //to apply to every web app. If not present, use our defaults.
+ String[] serverConfigs = (String[])getServer().getAttribute(SERVER_CONFIG);
if (serverConfigs != null)
- {
- configsLen += serverConfigs.size();
- }
-
- _configurations = new Configuration[configsLen];
+ _configurationClasses = serverConfigs;
+ if (_configurationClasses == null)
+ _configurationClasses=__dftConfigurationClasses;
+
+ _configurations = new Configuration[_configurationClasses.length];
for (int i = 0; i < _configurationClasses.length; i++)
{
_configurations[i]=(Configuration)Loader.loadClass(this.getClass(), _configurationClasses[i]).newInstance();
}
-
- if (serverConfigs != null)
- {
- int offset = _configurationClasses.length;
- for (int i = 0, n = serverConfigs.size(); i < n; i++)
- {
- _configurations[i + offset] = serverConfigs.get(i);
- }
- }
}
/* ------------------------------------------------------------ */
Modified: jetty/branches/jetty-8/jetty-websocket/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-websocket/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-websocket/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-websocket</artifactId>
<name>Jetty :: Websocket</name>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.websocket</bundle-symbolic-name>
+ </properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
@@ -63,6 +66,12 @@
</archive>
</configuration>
</plugin>
+ <!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
+ with a snapshot. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
</plugins>
</build>
</project>
Property changes on: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocket.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketBuffers.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java
===================================================================
--- jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -2,6 +2,7 @@
import java.io.IOException;
+import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
@@ -17,7 +18,7 @@
final long _timestamp;
final WebSocket _websocket;
final int _maxIdleTimeMs=300000;
-
+
public WebSocketConnection(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, long maxIdleTime)
{
_endp = endpoint;
@@ -27,7 +28,7 @@
_parser = new WebSocketParser(buffers, endpoint, new WebSocketParser.EventHandler()
{
public void onFrame(byte frame, String data)
- {
+ {
try
{
_websocket.onMessage(frame,data);
@@ -41,13 +42,13 @@
Log.warn(th);
}
}
-
+
public void onFrame(byte frame, Buffer buffer)
{
try
{
byte[] array=buffer.array();
-
+
_websocket.onMessage(frame,array,buffer.getIndex(),buffer.length());
}
catch(ThreadDeath th)
@@ -60,7 +61,8 @@
}
}
});
-
+
+ // TODO should these be AsyncEndPoint checks/calls?
if (_endp instanceof SelectChannelEndPoint)
{
final SelectChannelEndPoint scep=(SelectChannelEndPoint)_endp;
@@ -79,32 +81,29 @@
_idle = new IdleCheck()
{
public void access(EndPoint endp)
- {}
+ {}
};
- }
+ }
}
-
+
public Connection handle() throws IOException
{
- boolean more=true;
-
+ boolean progress=true;
+
try
{
- while (more)
+ while (progress)
{
int flushed=_generator.flush();
int filled=_parser.parseNext();
- more = flushed>0 || filled>0 || !_parser.isBufferEmpty() || !_generator.isBufferEmpty();
-
- // System.err.println("flushed="+flushed+" filled="+filled+" more="+more+" p.e="+_parser.isBufferEmpty()+" g.e="+_generator.isBufferEmpty());
-
+ progress = flushed>0 || filled>0;
+
if (filled<0 || flushed<0)
{
_endp.close();
break;
}
-
}
}
catch(IOException e)
@@ -115,7 +114,10 @@
finally
{
if (_endp.isOpen())
+ {
_idle.access(_endp);
+ checkWriteable();
+ }
else
// TODO - not really the best way
_websocket.onDisconnect();
@@ -127,7 +129,7 @@
{
return _endp!=null&&_endp.isOpen();
}
-
+
public boolean isIdle()
{
return _parser.isBufferEmpty() && _generator.isBufferEmpty();
@@ -145,29 +147,27 @@
public void sendMessage(String content) throws IOException
{
- _generator.addFrame(WebSocket.SENTINEL_FRAME,content,_maxIdleTimeMs);
- _generator.flush();
- _idle.access(_endp);
+ sendMessage(WebSocket.SENTINEL_FRAME,content);
}
public void sendMessage(byte frame, String content) throws IOException
{
_generator.addFrame(frame,content,_maxIdleTimeMs);
_generator.flush();
+ checkWriteable();
_idle.access(_endp);
}
public void sendMessage(byte frame, byte[] content) throws IOException
{
- _generator.addFrame(frame,content,_maxIdleTimeMs);
- _generator.flush();
- _idle.access(_endp);
+ sendMessage(frame, content, 0, content.length);
}
public void sendMessage(byte frame, byte[] content, int offset, int length) throws IOException
{
_generator.addFrame(frame,content,offset,length,_maxIdleTimeMs);
_generator.flush();
+ checkWriteable();
_idle.access(_endp);
}
@@ -188,7 +188,14 @@
{
_parser.fill(buffer);
}
-
+
+
+ private void checkWriteable()
+ {
+ if (!_generator.isBufferEmpty() && _endp instanceof AsyncEndPoint)
+ ((AsyncEndPoint)_endp).scheduleWrite();
+ }
+
private interface IdleCheck
{
void access(EndPoint endp);
Property changes on: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnection.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGenerator.java
===================================================================
--- jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGenerator.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGenerator.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1,6 +1,7 @@
package org.eclipse.jetty.websocket;
import java.io.IOException;
+import java.math.BigInteger;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.EndPoint;
@@ -9,8 +10,8 @@
/* ------------------------------------------------------------ */
/** WebSocketGenerator.
* This class generates websocket packets.
- * It is fully synchronized because it is likely that async
- * threads will call the addMessage methods while other
+ * It is fully synchronized because it is likely that async
+ * threads will call the addMessage methods while other
* threads are flushing the generator.
*/
public class WebSocketGenerator
@@ -18,179 +19,99 @@
final private WebSocketBuffers _buffers;
final private EndPoint _endp;
private Buffer _buffer;
-
+
public WebSocketGenerator(WebSocketBuffers buffers, EndPoint endp)
{
_buffers=buffers;
_endp=endp;
}
- synchronized public void addFrame(byte frame,byte[] content, int blockFor) throws IOException
+ public synchronized void addFrame(byte frame,byte[] content, int blockFor) throws IOException
{
addFrame(frame,content,0,content.length,blockFor);
}
-
- synchronized public void addFrame(byte frame,byte[] content, int offset, int length, int blockFor) throws IOException
+
+ public synchronized void addFrame(byte frame,byte[] content, int offset, int length, int blockFor) throws IOException
{
if (_buffer==null)
_buffer=_buffers.getDirectBuffer();
-
- if ((frame&0x80)==0x80)
- {
- // Send in a length delimited frame
-
- // maximum of 3 byte length == 21 bits
- if (length>2097152)
- throw new IllegalArgumentException("too big");
- int length_bytes=(length>16384)?3:(length>128)?2:1;
- int needed=length+1+length_bytes;
- checkSpace(needed,blockFor);
-
- _buffer.put(frame);
- switch (length_bytes)
- {
- case 3:
- _buffer.put((byte)(0x80|(length>>14)));
- case 2:
- _buffer.put((byte)(0x80|(0x7f&(length>>7))));
- case 1:
- _buffer.put((byte)(0x7f&length));
- }
+ if (_buffer.space() == 0)
+ expelBuffer(blockFor);
- _buffer.put(content,offset,length);
- }
- else
- {
- // send in a sentinel frame
- int needed=length+2;
- checkSpace(needed,blockFor);
+ bufferPut(frame, blockFor);
- _buffer.put(frame);
- _buffer.put(content,offset,length);
- _buffer.put((byte)0xFF);
- }
- }
-
- synchronized public void addFrame(byte frame, String content, int blockFor) throws IOException
- {
- Buffer byte_buffer=_buffers.getBuffer();
- try
+ if (isLengthFrame(frame))
{
- byte[] array=byte_buffer.array();
+ // Send a length delimited frame
- int chars = content.length();
- int bytes = 0;
- final int limit=array.length-6;
-
- for (int i = 0; i < chars; i++)
+ // How many bytes we need for the length ?
+ // We have 7 bits available, so log2(length) / 7 + 1
+ // For example, 50000 bytes is 2 8-bytes: 11000011 01010000
+ // but we need to write it in 3 7-bytes 0000011 0000110 1010000
+ // 65536 == 1 00000000 00000000 => 100 0000000 0000000
+ int lengthBytes = new BigInteger(String.valueOf(length)).bitLength() / 7 + 1;
+ for (int i = lengthBytes - 1; i > 0; --i)
{
- int code = content.charAt(i);
-
- if (bytes>=limit)
- throw new IllegalArgumentException("frame too large");
-
- if ((code & 0xffffff80) == 0)
- {
- array[bytes++]=(byte)(code);
- }
- else if((code&0xfffff800)==0)
- {
- array[bytes++]=(byte)(0xc0|(code>>6));
- array[bytes++]=(byte)(0x80|(code&0x3f));
- }
- else if((code&0xffff0000)==0)
- {
- array[bytes++]=(byte)(0xe0|(code>>12));
- array[bytes++]=(byte)(0x80|((code>>6)&0x3f));
- array[bytes++]=(byte)(0x80|(code&0x3f));
- }
- else if((code&0xff200000)==0)
- {
- array[bytes++]=(byte)(0xf0|(code>>18));
- array[bytes++]=(byte)(0x80|((code>>12)&0x3f));
- array[bytes++]=(byte)(0x80|((code>>6)&0x3f));
- array[bytes++]=(byte)(0x80|(code&0x3f));
- }
- else if((code&0xf4000000)==0)
- {
- array[bytes++]=(byte)(0xf8|(code>>24));
- array[bytes++]=(byte)(0x80|((code>>18)&0x3f));
- array[bytes++]=(byte)(0x80|((code>>12)&0x3f));
- array[bytes++]=(byte)(0x80|((code>>6)&0x3f));
- array[bytes++]=(byte)(0x80|(code&0x3f));
- }
- else if((code&0x80000000)==0)
- {
- array[bytes++]=(byte)(0xfc|(code>>30));
- array[bytes++]=(byte)(0x80|((code>>24)&0x3f));
- array[bytes++]=(byte)(0x80|((code>>18)&0x3f));
- array[bytes++]=(byte)(0x80|((code>>12)&0x3f));
- array[bytes++]=(byte)(0x80|((code>>6)&0x3f));
- array[bytes++]=(byte)(0x80|(code&0x3f));
- }
- else
- {
- array[bytes++]=(byte)('?');
- }
+ byte lengthByte = (byte)(0x80 | (0x7F & (length >> 7 * i)));
+ bufferPut(lengthByte, blockFor);
}
- addFrame(frame,array,0,bytes,blockFor);
+ bufferPut((byte)(0x7F & length), blockFor);
}
- finally
+
+ int remaining = length;
+ while (remaining > 0)
{
- _buffers.returnBuffer(byte_buffer);
- }
- }
-
- private void checkSpace(int needed, long blockFor)
- throws IOException
- {
- int space=_buffer.space();
-
- if (space<needed)
- {
- if (_endp.isBlocking())
+ int chunk = remaining < _buffer.space() ? remaining : _buffer.space();
+ _buffer.put(content, offset + (length - remaining), chunk);
+ remaining -= chunk;
+ if (_buffer.space() > 0)
{
- try
- {
- flushBuffer();
- _buffer.compact();
- space=_buffer.space();
- }
- catch(IOException e)
- {
- throw e;
- }
+ if (!isLengthFrame(frame))
+ _buffer.put((byte)0xFF);
+ // Gently flush the data, issuing a non-blocking write
+ flushBuffer();
}
else
{
- flushBuffer();
- _buffer.compact();
- space=_buffer.space();
-
- if (space<needed && _buffer.length()>0 && _endp.blockWritable(blockFor))
+ // Forcibly flush the data, issuing a blocking write
+ expelBuffer(blockFor);
+ if (remaining == 0)
{
+ if (!isLengthFrame(frame))
+ _buffer.put((byte)0xFF);
+ // Gently flush the data, issuing a non-blocking write
flushBuffer();
- _buffer.compact();
- space=_buffer.space();
}
}
-
- if (space<needed)
- {
- _endp.close();
- throw new IOException("Full Timeout");
- }
}
}
- synchronized public int flush(long blockFor)
+ private synchronized boolean isLengthFrame(byte frame)
{
- return 0;
+ return (frame & WebSocket.LENGTH_FRAME) == WebSocket.LENGTH_FRAME;
}
- synchronized public int flush() throws IOException
+ private synchronized void bufferPut(byte datum, long blockFor) throws IOException
{
+ _buffer.put(datum);
+ if (_buffer.space() == 0)
+ expelBuffer(blockFor);
+ }
+
+ public synchronized void addFrame(byte frame, String content, int blockFor) throws IOException
+ {
+ byte[] bytes = content.getBytes("UTF-8");
+ addFrame(frame, bytes, 0, bytes.length, blockFor);
+ }
+
+ public synchronized int flush(long blockFor) throws IOException
+ {
+ return expelBuffer(blockFor);
+ }
+
+ public synchronized int flush() throws IOException
+ {
int flushed = flushBuffer();
if (_buffer!=null && _buffer.length()==0)
{
@@ -199,23 +120,40 @@
}
return flushed;
}
-
- private int flushBuffer() throws IOException
+
+ private synchronized int flushBuffer() throws IOException
{
if (!_endp.isOpen())
- return -1;
-
+ throw new IOException("Closed");
+
if (_buffer!=null)
+ return _endp.flush(_buffer);
+
+ return 0;
+ }
+
+ private synchronized int expelBuffer(long blockFor) throws IOException
+ {
+ int result = flushBuffer();
+ _buffer.compact();
+ if (!_endp.isBlocking())
{
- int flushed =_endp.flush(_buffer);
- if (flushed>0)
- _buffer.skip(flushed);
- return flushed;
+ while (_buffer.space()==0)
+ {
+ // TODO: in case the I/O system signals write ready, but when we attempt to write we cannot
+ // TODO: we should decrease the blockFor timeout instead of waiting again the whole timeout
+ boolean ready = _endp.blockWritable(blockFor);
+ if (!ready)
+ throw new IOException("Write timeout");
+
+ result += flushBuffer();
+ _buffer.compact();
+ }
}
- return 0;
+ return result;
}
- synchronized public boolean isBufferEmpty()
+ public synchronized boolean isBufferEmpty()
{
return _buffer==null || _buffer.length()==0;
}
Property changes on: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketGenerator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParser.java
===================================================================
--- jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParser.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParser.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -12,9 +12,9 @@
/* ------------------------------------------------------------ */
-/**
+/**
* Parser the WebSocket protocol.
- *
+ *
*/
public class WebSocketParser
{
@@ -35,7 +35,7 @@
/* ------------------------------------------------------------ */
/**
* @param buffers The buffers to use for parsing. Only the {@link Buffers#getBuffer()} is used.
- * This should be a direct buffer if binary data is mostly used or an indirect buffer if utf-8 data
+ * This should be a direct buffer if binary data is mostly used or an indirect buffer if utf-8 data
* is mostly used.
* @param endp
* @param handler
@@ -58,18 +58,20 @@
{
return _buffer;
}
-
+
/* ------------------------------------------------------------ */
/** Parse to next event.
- * Parse to the next {@link EventHandler} event or until no more data is
+ * Parse to the next {@link EventHandler} event or until no more data is
* available. Fill data from the {@link EndPoint} only as necessary.
- * @return total bytes filled or -1 for EOF
+ * @return An indication of progress or otherwise. -1 indicates EOF, 0 indicates
+ * that no bytes were read and no messages parsed. A positive number indicates either
+ * the bytes filled or the messages parsed.
*/
public int parseNext()
{
if (_buffer==null)
_buffer=_buffers.getBuffer();
-
+
int total_filled=0;
// Loop until an datagram call back or can't fill anymore
@@ -83,11 +85,11 @@
{
// compact to mark (set at start of data)
_buffer.compact();
-
+
// if no space, then the data is too big for buffer
- if (_buffer.space() == 0)
- throw new IllegalStateException("FULL");
-
+ if (_buffer.space() == 0)
+ throw new IllegalStateException("FULL");
+
// catch IOExceptions (probably EOF) and try to parse what we have
try
{
@@ -165,13 +167,13 @@
_buffer.skip(_length);
_state=STATE_START;
_handler.onFrame(_frame,data);
-
+
if (_buffer.length()==0)
{
_buffers.returnBuffer(_buffer);
_buffer=null;
}
-
+
return total_filled;
}
}
@@ -188,10 +190,10 @@
_buffer.put(buffer);
buffer.clear();
}
-
-
+
+
}
-
+
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
Property changes on: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketServlet.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: jetty/branches/jetty-8/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorTest.java
===================================================================
--- jetty/branches/jetty-8/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketGeneratorTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -1,7 +1,6 @@
package org.eclipse.jetty.websocket;
import junit.framework.TestCase;
-
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.ByteArrayEndPoint;
import org.eclipse.jetty.util.StringUtil;
@@ -12,7 +11,7 @@
*/
public class WebSocketGeneratorTest extends TestCase
{
-
+
WebSocketBuffers _buffers;
ByteArrayBuffer _out;
ByteArrayEndPoint _endp;
@@ -28,7 +27,7 @@
_out = new ByteArrayBuffer(2048);
_endp.setOut(_out);
}
-
+
/* ------------------------------------------------------------ */
public void testOneString() throws Exception
{
@@ -52,7 +51,7 @@
assertEquals('d',_out.get());
assertEquals(0xff,0xff&_out.get());
}
-
+
public void testOneBuffer() throws Exception
{
_generator.addFrame((byte)0x84,"Hell\uFF4F W\uFF4Frld".getBytes(StringUtil.__UTF8),0);
@@ -75,15 +74,15 @@
assertEquals('l',_out.get());
assertEquals('d',_out.get());
}
-
+
public void testOneLongBuffer() throws Exception
{
byte[] b=new byte[150];
for (int i=0;i<b.length;i++)
b[i]=(byte)('0'+(i%10));
-
+
_generator.addFrame((byte)0x85,b,0);
-
+
_generator.flush();
assertEquals(0x85,0xff&_out.get());
assertEquals(0x80|(b.length>>7),0xff&_out.get());
Copied: jetty/branches/jetty-8/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageTest.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageTest.java)
===================================================================
--- jetty/branches/jetty-8/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageTest.java (rev 0)
+++ jetty/branches/jetty-8/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,189 @@
+package org.eclipse.jetty.websocket;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.servlet.http.HttpServletRequest;
+
+import junit.framework.TestCase;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.DefaultHandler;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.util.StringUtil;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class WebSocketMessageTest extends TestCase
+{
+ private Server _server;
+ private Connector _connector;
+ private TestWebSocket _serverWebSocket;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ _server = new Server();
+ _connector = new SelectChannelConnector();
+ _server.addConnector(_connector);
+ WebSocketHandler wsHandler = new WebSocketHandler()
+ {
+ @Override
+ protected WebSocket doWebSocketConnect(HttpServletRequest request, String protocol)
+ {
+ return _serverWebSocket = new TestWebSocket();
+ }
+ };
+ wsHandler.setHandler(new DefaultHandler());
+ _server.setHandler(wsHandler);
+ _server.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ _server.stop();
+ _server.join();
+ }
+
+ public void testServerSendBigStringMessage() throws Exception
+ {
+ Socket socket = new Socket("localhost", _connector.getLocalPort());
+ OutputStream output = socket.getOutputStream();
+ output.write(
+ ("GET /test HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Upgrade: WebSocket\r\n" +
+ "Connection: Upgrade\r\n" +
+ "\r\n").getBytes("ISO-8859-1"));
+ output.flush();
+
+ // Make sure the read times out if there are problems with the implementation
+ socket.setSoTimeout(1000);
+
+ InputStream input = socket.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(input, "ISO-8859-1"));
+ String responseLine = reader.readLine();
+ assertTrue(responseLine.startsWith("HTTP/1.1 101 Web Socket Protocol Handshake"));
+ // Read until we find an empty line, which signals the end of the http response
+ String line;
+ while ((line = reader.readLine()) != null)
+ if (line.length() == 0)
+ break;
+
+ assertTrue(_serverWebSocket.awaitConnected(1000));
+ assertNotNull(_serverWebSocket.outbound);
+
+ // Server sends a big message
+ StringBuilder message = new StringBuilder();
+ String text = "0123456789ABCDEF";
+ for (int i = 0; i < 64 * 1024 / text.length(); ++i)
+ message.append(text);
+ _serverWebSocket.outbound.sendMessage(message.toString());
+
+ // Read until we get 0xFF
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ while (true)
+ {
+ int read = input.read();
+ baos.write(read);
+ if (read == 0xFF)
+ break;
+ }
+ baos.close();
+ byte[] bytes = baos.toByteArray();
+ String result = StringUtil.printable(bytes);
+ assertTrue(result.startsWith("0x00"));
+ assertTrue(result.endsWith("0xFF"));
+ assertEquals(message.length() + "0x00".length() + "0xFF".length(), result.length());
+ }
+
+ public void testServerSendBigBinaryMessage() throws Exception
+ {
+ Socket socket = new Socket("localhost", _connector.getLocalPort());
+ OutputStream output = socket.getOutputStream();
+ output.write(
+ ("GET /test HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Upgrade: WebSocket\r\n" +
+ "Connection: Upgrade\r\n" +
+ "\r\n").getBytes("ISO-8859-1"));
+ output.flush();
+
+ // Make sure the read times out if there are problems with the implementation
+ socket.setSoTimeout(1000);
+
+ InputStream input = socket.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(input, "ISO-8859-1"));
+ String responseLine = reader.readLine();
+ assertTrue(responseLine.startsWith("HTTP/1.1 101 Web Socket Protocol Handshake"));
+ // Read until we find an empty line, which signals the end of the http response
+ String line;
+ while ((line = reader.readLine()) != null)
+ if (line.length() == 0)
+ break;
+
+ assertTrue(_serverWebSocket.awaitConnected(1000));
+ assertNotNull(_serverWebSocket.outbound);
+
+ // Server sends a big message
+ StringBuilder message = new StringBuilder();
+ String text = "0123456789ABCDEF";
+ for (int i = 0; i < 64 * 1024 / text.length(); ++i)
+ message.append(text);
+ byte[] data = message.toString().getBytes("UTF-8");
+ _serverWebSocket.outbound.sendMessage(WebSocket.LENGTH_FRAME, data);
+
+ // Length of the message is 65536, so the length will be encoded as 0x84 0x80 0x00
+ int frame = input.read();
+ assertEquals(0x80, frame);
+ int length1 = input.read();
+ assertEquals(0x84, length1);
+ int length2 = input.read();
+ assertEquals(0x80, length2);
+ int length3 = input.read();
+ assertEquals(0x00, length3);
+ int read = 0;
+ while (read < data.length)
+ {
+ int b = input.read();
+ assertTrue(b != -1);
+ ++read;
+ }
+ }
+
+ private class TestWebSocket implements WebSocket
+ {
+ private final CountDownLatch latch = new CountDownLatch(1);
+ private volatile Outbound outbound;
+
+ public void onConnect(Outbound outbound)
+ {
+ this.outbound = outbound;
+ latch.countDown();
+ }
+
+ private boolean awaitConnected(long time) throws InterruptedException
+ {
+ return latch.await(time, TimeUnit.MILLISECONDS);
+ }
+
+ public void onMessage(byte frame, String data)
+ {
+ }
+
+ public void onMessage(byte frame, byte[] data, int offset, int length)
+ {
+ }
+
+ public void onDisconnect()
+ {
+ }
+ }
+}
Modified: jetty/branches/jetty-8/jetty-xml/pom.xml
===================================================================
--- jetty/branches/jetty-8/jetty-xml/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/jetty-xml/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -8,6 +8,9 @@
<artifactId>jetty-xml</artifactId>
<name>Jetty :: XML utilities</name>
<description>The jetty xml utilities.</description>
+ <properties>
+ <bundle-symbolic-name>${project.groupId}.xml</bundle-symbolic-name>
+ </properties>
<build>
<plugins>
<plugin>
@@ -39,14 +42,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
</plugin>
<!--
<plugin>
Modified: jetty/branches/jetty-8/pom.xml
===================================================================
--- jetty/branches/jetty-8/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -67,6 +67,22 @@
</execution>
</executions>
</plugin>
+
+ <!-- Build helper maven plugin sets the parsedVersion.osgiVersion property -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.5</version>
+ <executions>
+ <execution>
+ <id>set-osgi-version</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>parse-version</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -120,6 +136,35 @@
</dependency>
</dependencies>
</plugin>
+
+ <!-- source maven plugin creates the source bundle and adds manifest -->
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
+ <Bundle-Name>${name}</Bundle-Name>
+ <Bundle-SymbolicName>${bundle-symbolic-name}.source;singleton:=true</Bundle-SymbolicName>
+ <Bundle-Vendor>Eclipse.org - Jetty</Bundle-Vendor>
+ <Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
+ <Eclipse-SourceBundle>${bundle-symbolic-name};version="${parsedVersion.osgiVersion}";roots:="."</Eclipse-SourceBundle>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
</build>
Copied: jetty/branches/jetty-8/test-jetty-servlet/src/main/java/Jetty400Repro.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/test-jetty-servlet/src/main/java/Jetty400Repro.java)
===================================================================
--- jetty/branches/jetty-8/test-jetty-servlet/src/main/java/Jetty400Repro.java (rev 0)
+++ jetty/branches/jetty-8/test-jetty-servlet/src/main/java/Jetty400Repro.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,129 @@
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.DefaultHandler;
+import org.eclipse.jetty.server.handler.HandlerList;
+import org.eclipse.jetty.util.resource.FileResource;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.xml.sax.SAXException;
+
+
+/**
+ * Repro a jetty problem.
+ *
+ * @author hughw
+ *
+ */
+public class Jetty400Repro extends HttpServlet{
+
+
+ private static final long serialVersionUID = 1L;
+ private static final int port = 8080;
+ private static final String host = "localhost";
+ private static final String uri = "/flub/servlet/";
+
+ /**
+ * Jetty 7.0.1 returns 400 on the second POST, when you send both Connection: Keep-Alive and
+ * Expect: 100-Continue headers in the request.
+ * @param args
+ */
+ public static void main(String[] args) throws Exception{
+ initJetty();
+ Thread.sleep(1000);
+
+ Socket sock = new Socket(host, port);
+
+ sock.setSoTimeout(500);
+
+ String body= "<flibs xmlns='http://www.flub.org/schemas/131'><flib uid='12321'><name>foo flib</name> </flib></flibs>";
+ //body= "XXX"; // => 501
+
+ int len = body.getBytes("US-ASCII").length;
+
+ String msg = "POST " + uri + " HTTP/1.1\r\n" +
+ "Content-Type: application/xml\r\n" +
+ "Host: 10.0.2.2:8080\r\n" +
+ "Content-Length: " + len + "\r\n" +
+ "Expect: 100-continue\r\n" +
+ "Connection: Keep-Alive\r\n" +
+ "\r\n" +
+ body;
+
+
+
+ sock.getOutputStream().write(msg.getBytes("US-ASCII"));
+
+ String response1 = readResponse(sock);
+ int status1 = Integer.parseInt(response1.substring(9, 12));
+ assert 401 == status1;
+
+ sock.getOutputStream().write(msg.getBytes("US-ASCII"));
+
+
+ String response2 = readResponse(sock);
+ System.out.println(response2.substring(0, 100));
+
+
+ int status2 = Integer.parseInt(response2.substring(9, 12));
+ System.out.println(status2);
+
+ assert 401 == status2;
+
+
+
+ }
+
+ private static String readResponse(Socket sock) throws IOException {
+ byte [] response = new byte [4000];
+ int n = 0;
+ for (int i=0; i< response.length && response[n] >= 0; i++){
+ try {
+ response[n++] = (byte)sock.getInputStream().read();
+ } catch (SocketTimeoutException e) {
+ break;
+ }
+ }
+ String sResult = new String(response);
+ return sResult;
+ }
+
+ private static void initJetty() throws SAXException, IOException, MalformedURLException, Exception {
+
+ Server jetty = new Server(8080);
+
+
+ // configure your web application
+ WebAppContext appContext = new WebAppContext();
+ appContext.setContextPath("/flub");
+
+ appContext.addServlet(Jetty400Repro.class, "/servlet/");
+
+ appContext.setResourceBase(".");
+
+
+ HandlerList handlers = new HandlerList();
+ handlers.setHandlers(new Handler[] { appContext, new DefaultHandler() });
+ jetty.setHandler(handlers);
+
+
+ jetty.start();
+
+
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ req.getInputStream();
+ resp.sendError(401);
+ }
+
+}
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/ChatServlet.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/CookieDump.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/Counter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/DispatchServlet.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/Dump.java
===================================================================
--- jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/Dump.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/Dump.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -38,9 +38,11 @@
import javax.servlet.http.HttpServletResponseWrapper;
import org.eclipse.jetty.continuation.Continuation;
+import org.eclipse.jetty.continuation.ContinuationListener;
import org.eclipse.jetty.continuation.ContinuationSupport;
import org.eclipse.jetty.http.HttpHeaders;
import org.eclipse.jetty.util.StringUtil;
+import org.eclipse.jetty.util.log.Log;
@@ -76,9 +78,18 @@
@Override
public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
{
+ // Handle a dump of data
+ final String data= request.getParameter("data");
+ final String chars= request.getParameter("chars");
+ final String block= request.getParameter("block");
+ final String dribble= request.getParameter("dribble");
+ final boolean flush= request.getParameter("flush")!=null?Boolean.parseBoolean(request.getParameter("flush")):false;
+
+
+
if(request.getPathInfo()!=null && request.getPathInfo().toLowerCase().indexOf("script")!=-1)
{
- response.sendRedirect(getServletContext().getContextPath() + "/dump/info");
+ response.sendRedirect(response.encodeRedirectURL(getServletContext().getContextPath() + "/dump/info"));
return;
}
@@ -158,7 +169,7 @@
{
response.setContentType("text/html");
response.getOutputStream().println("<h1>COMPLETED</h1>");
- Continuation continuation = ContinuationSupport.getContinuation(request,response);
+ Continuation continuation = ContinuationSupport.getContinuation(request);
continuation.complete();
}
catch (IOException e)
@@ -178,6 +189,29 @@
Continuation continuation = ContinuationSupport.getContinuation(request);
continuation.setTimeout(Long.parseLong(request.getParameter("suspend")));
continuation.suspend();
+
+ continuation.addContinuationListener(new ContinuationListener()
+ {
+ public void onTimeout(Continuation continuation)
+ {
+ response.addHeader("Dump","onTimeout");
+ try
+ {
+ dump(response,data,chars,block,dribble,flush);
+ continuation.complete();
+ }
+ catch (IOException e)
+ {
+ Log.ignore(e);
+ }
+ }
+
+ public void onComplete(Continuation continuation)
+ {
+ response.addHeader("Dump","onComplete");
+ }
+ });
+
continuation.undispatch();
}
catch(Exception e)
@@ -198,104 +232,9 @@
}
// Handle a dump of data
- String data= request.getParameter("data");
- String block= request.getParameter("block");
- String dribble= request.getParameter("dribble");
- boolean flush= request.getParameter("flush")!=null?Boolean.parseBoolean(request.getParameter("flush")):false;
- if (data != null && data.length() > 0)
- {
- long d=Long.parseLong(data);
- int b=(block!=null&&block.length()>0)?Integer.parseInt(block):50;
- byte[] buf=new byte[b];
- for (int i=0;i<b;i++)
- {
-
- buf[i]=(byte)('0'+(i%10));
- if (i%10==9)
- buf[i]=(byte)'\n';
- }
- buf[0]='o';
- OutputStream out=response.getOutputStream();
- response.setContentType("text/plain");
- while (d > 0)
- {
- if (b==1)
- {
- out.write(d%80==0?'\n':'.');
- d--;
- }
- else if (d>=b)
- {
- out.write(buf);
- d=d-b;
- }
- else
- {
- out.write(buf,0,(int)d);
- d=0;
- }
-
- if (dribble!=null)
- {
- out.flush();
- try
- {
- Thread.sleep(Long.parseLong(dribble));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- break;
- }
- }
-
- }
-
- if (flush)
- out.flush();
-
+ if (dump(response,data,chars,block,dribble,flush))
return;
- }
-
- // Handle a dump of data
- String chars= request.getParameter("chars");
- if (chars != null && chars.length() > 0)
- {
- long d=Long.parseLong(chars);
- int b=(block!=null&&block.length()>0)?Integer.parseInt(block):50;
- char[] buf=new char[b];
- for (int i=0;i<b;i++)
- {
- buf[i]=(char)('0'+(i%10));
- if (i%10==9)
- buf[i]='\n';
- }
- buf[0]='o';
- response.setContentType("text/plain");
- PrintWriter out=response.getWriter();
- while (d > 0 && !out.checkError())
- {
- if (b==1)
- {
- out.write(d%80==0?'\n':'.');
- d--;
- }
- else if (d>=b)
- {
- out.write(buf);
- d=d-b;
- }
- else
- {
- out.write(buf,0,(int)d);
- d=0;
- }
- }
- return;
- }
-
-
// handle an exception
String info= request.getPathInfo();
if (info != null && info.endsWith("Exception"))
@@ -325,7 +264,7 @@
if (redirect != null && redirect.length() > 0)
{
response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
- response.sendRedirect(redirect);
+ response.sendRedirect(response.encodeRedirectURL(redirect));
try
{
response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
@@ -799,6 +738,7 @@
}
+
/* ------------------------------------------------------------ */
@Override
public String getServletInfo()
@@ -872,6 +812,101 @@
}
}
+ private boolean dump(HttpServletResponse response, String data, String chars, String block, String dribble, boolean flush) throws IOException
+ {
+ if (data != null && data.length() > 0)
+ {
+ long d=Long.parseLong(data);
+ int b=(block!=null&&block.length()>0)?Integer.parseInt(block):50;
+ byte[] buf=new byte[b];
+ for (int i=0;i<b;i++)
+ {
+
+ buf[i]=(byte)('0'+(i%10));
+ if (i%10==9)
+ buf[i]=(byte)'\n';
+ }
+ buf[0]='o';
+ OutputStream out=response.getOutputStream();
+ response.setContentType("text/plain");
+ while (d > 0)
+ {
+ if (b==1)
+ {
+ out.write(d%80==0?'\n':'.');
+ d--;
+ }
+ else if (d>=b)
+ {
+ out.write(buf);
+ d=d-b;
+ }
+ else
+ {
+ out.write(buf,0,(int)d);
+ d=0;
+ }
+
+ if (dribble!=null)
+ {
+ out.flush();
+ try
+ {
+ Thread.sleep(Long.parseLong(dribble));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ break;
+ }
+ }
+
+ }
+
+ if (flush)
+ out.flush();
+
+ return true;
+ }
+
+ // Handle a dump of data
+ if (chars != null && chars.length() > 0)
+ {
+ long d=Long.parseLong(chars);
+ int b=(block!=null&&block.length()>0)?Integer.parseInt(block):50;
+ char[] buf=new char[b];
+ for (int i=0;i<b;i++)
+ {
+ buf[i]=(char)('0'+(i%10));
+ if (i%10==9)
+ buf[i]='\n';
+ }
+ buf[0]='o';
+ response.setContentType("text/plain");
+ PrintWriter out=response.getWriter();
+ while (d > 0 && !out.checkError())
+ {
+ if (b==1)
+ {
+ out.write(d%80==0?'\n':'.');
+ d--;
+ }
+ else if (d>=b)
+ {
+ out.write(buf);
+ d=d-b;
+ }
+ else
+ {
+ out.write(buf,0,(int)d);
+ d=0;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
private String notag(String s)
{
if (s==null)
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/Dump.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/HelloWorld.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/RewriteServlet.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/SecureModeServlet.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/SessionDump.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/TestFilter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/TestListener.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: jetty/branches/jetty-8/test-jetty-webapp/src/main/webapp/ws/index.html
___________________________________________________________________
Modified: svn:mime-type
- text/html
+ text/plain
Modified: jetty/branches/jetty-8/tests/test-integration/pom.xml
===================================================================
--- jetty/branches/jetty-8/tests/test-integration/pom.xml 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/tests/test-integration/pom.xml 2010-04-06 18:17:57 UTC (rev 1472)
@@ -68,6 +68,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.6</version>
Copied: jetty/branches/jetty-8/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java)
===================================================================
--- jetty/branches/jetty-8/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java (rev 0)
+++ jetty/branches/jetty-8/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,330 @@
+package org.eclipse.jetty.test;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.Socket;
+import java.security.MessageDigest;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jetty.client.ContentExchange;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.security.Realm;
+import org.eclipse.jetty.client.security.SimpleRealmResolver;
+import org.eclipse.jetty.http.HttpMethods;
+import org.eclipse.jetty.http.security.Constraint;
+import org.eclipse.jetty.http.security.Password;
+import org.eclipse.jetty.io.ByteArrayBuffer;
+import org.eclipse.jetty.security.ConstraintMapping;
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.security.HashLoginService;
+import org.eclipse.jetty.security.authentication.DigestAuthenticator;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.DefaultHandler;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.util.IO;
+import org.eclipse.jetty.util.StringUtil;
+import org.eclipse.jetty.util.TypeUtil;
+
+
+public class DigestPostTest extends TestCase
+{
+ private static final String NC = "00000001";
+
+ public final static String __message =
+ "0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 \n"+
+ "9876543210 9876543210 9876543210 9876543210 9876543210 9876543210 9876543210 9876543210 \n"+
+ "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 \n"+
+ "0987654321 0987654321 0987654321 0987654321 0987654321 0987654321 0987654321 0987654321 \n"+
+ "abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz \n"+
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ \n"+
+ "Now is the time for all good men to come to the aid of the party.\n"+
+ "How now brown cow.\n"+
+ "The quick brown fox jumped over the lazy dog.\n";
+
+ public volatile static String _received = null;
+ private Server _server;
+
+ @Override
+ public void setUp()
+ {
+ try
+ {
+ _server = new Server();
+ _server.setConnectors(new Connector[]
+ { new SelectChannelConnector() });
+
+ ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SECURITY);
+ context.setContextPath("/test");
+ context.addServlet(PostServlet.class,"/");
+
+ HashLoginService realm = new HashLoginService("test");
+ realm.putUser("testuser",new Password("password"),new String[]{"test"});
+ _server.addBean(realm);
+
+ ConstraintSecurityHandler security=(ConstraintSecurityHandler)context.getSecurityHandler();
+ security.setAuthenticator(new DigestAuthenticator());
+ security.setLoginService(realm);
+
+ Constraint constraint = new Constraint("SecureTest","test");
+ constraint.setAuthenticate(true);
+ ConstraintMapping mapping = new ConstraintMapping();
+ mapping.setConstraint(constraint);
+ mapping.setPathSpec("/*");
+
+ security.setConstraintMappings(new ConstraintMapping[]{mapping});
+
+ HandlerCollection handlers = new HandlerCollection();
+ handlers.setHandlers(new Handler[]
+ { context, new DefaultHandler() });
+ _server.setHandler(handlers);
+
+ _server.start();
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception
+ {
+ _server.stop();
+ }
+
+ public void testServerDirectlyHTTP10() throws Exception
+ {
+ Socket socket = new Socket("127.0.0.1",_server.getConnectors()[0].getLocalPort());
+ byte[] bytes = __message.getBytes("UTF-8");
+
+ _received=null;
+ socket.getOutputStream().write(
+ ("POST /test/ HTTP/1.0\r\n"+
+ "Host: 127.0.0.1:"+_server.getConnectors()[0].getLocalPort()+"\r\n"+
+ "Content-Length: "+bytes.length+"\r\n"+
+ "\r\n").getBytes("UTF-8"));
+ socket.getOutputStream().write(bytes);
+ socket.getOutputStream().flush();
+
+ String result = IO.toString(socket.getInputStream());
+
+ assertTrue(result.startsWith("HTTP/1.1 401 Unauthorized"));
+ assertEquals(null,_received);
+
+ int n=result.indexOf("nonce=");
+ String nonce=result.substring(n+7,result.indexOf('"',n+7));
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] b= md.digest(String.valueOf(System.currentTimeMillis()).getBytes(org.eclipse.jetty.util.StringUtil.__ISO_8859_1));
+ String cnonce=encode(b);
+ String digest="Digest username=\"testuser\" realm=\"test\" nonce=\""+nonce+"\" uri=\"/test/\" algorithm=MD5 response=\""+
+ newResponse("POST","/test/",cnonce,"testuser","test","password",nonce,"auth")+
+ "\" qop=auth nc="+NC+" cnonce=\""+cnonce+"\"";
+
+
+ socket = new Socket("127.0.0.1",_server.getConnectors()[0].getLocalPort());
+
+ _received=null;
+ socket.getOutputStream().write(
+ ("POST /test/ HTTP/1.0\r\n"+
+ "Host: 127.0.0.1:"+_server.getConnectors()[0].getLocalPort()+"\r\n"+
+ "Content-Length: "+bytes.length+"\r\n"+
+ "Authorization: "+digest+"\r\n"+
+ "\r\n").getBytes("UTF-8"));
+ socket.getOutputStream().write(bytes);
+ socket.getOutputStream().flush();
+
+ result = IO.toString(socket.getInputStream());
+
+ assertTrue(result.startsWith("HTTP/1.1 200 OK"));
+ assertEquals(__message,_received);
+ }
+
+ public void testServerDirectlyHTTP11() throws Exception
+ {
+ Socket socket = new Socket("127.0.0.1",_server.getConnectors()[0].getLocalPort());
+ byte[] bytes = __message.getBytes("UTF-8");
+
+ _received=null;
+ socket.getOutputStream().write(
+ ("POST /test/ HTTP/1.1\r\n"+
+ "Host: 127.0.0.1:"+_server.getConnectors()[0].getLocalPort()+"\r\n"+
+ "Content-Length: "+bytes.length+"\r\n"+
+ "\r\n").getBytes("UTF-8"));
+ socket.getOutputStream().write(bytes);
+ socket.getOutputStream().flush();
+
+ Thread.sleep(100);
+
+ byte[] buf=new byte[4096];
+ int len=socket.getInputStream().read(buf);
+ String result=new String(buf,0,len,"UTF-8");
+
+ assertTrue(result.startsWith("HTTP/1.1 401 Unauthorized"));
+ assertEquals(null,_received);
+
+ int n=result.indexOf("nonce=");
+ String nonce=result.substring(n+7,result.indexOf('"',n+7));
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] b= md.digest(String.valueOf(System.currentTimeMillis()).getBytes(StringUtil.__ISO_8859_1));
+ String cnonce=encode(b);
+ String digest="Digest username=\"testuser\" realm=\"test\" nonce=\""+nonce+"\" uri=\"/test/\" algorithm=MD5 response=\""+
+ newResponse("POST","/test/",cnonce,"testuser","test","password",nonce,"auth")+
+ "\" qop=auth nc="+NC+" cnonce=\""+cnonce+"\"";
+
+ _received=null;
+ socket.getOutputStream().write(
+ ("POST /test/ HTTP/1.0\r\n"+
+ "Host: 127.0.0.1:"+_server.getConnectors()[0].getLocalPort()+"\r\n"+
+ "Content-Length: "+bytes.length+"\r\n"+
+ "Authorization: "+digest+"\r\n"+
+ "\r\n").getBytes("UTF-8"));
+ socket.getOutputStream().write(bytes);
+ socket.getOutputStream().flush();
+
+ result = IO.toString(socket.getInputStream());
+
+ assertTrue(result.startsWith("HTTP/1.1 200 OK"));
+ assertEquals(__message,_received);
+ }
+
+ public void testServerWithHttpClientStringContent() throws Exception
+ {
+ HttpClient client = new HttpClient();
+ client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
+ client.setRealmResolver(new SimpleRealmResolver(new TestRealm()));
+ client.start();
+
+ String srvUrl = "http://127.0.0.1:" + _server.getConnectors()[0].getLocalPort() + "/test/";
+
+ ContentExchange ex = new ContentExchange();
+ ex.setMethod(HttpMethods.POST);
+ ex.setURL(srvUrl);
+ ex.setRequestContent(new ByteArrayBuffer(__message,"UTF-8"));
+
+ _received=null;
+ client.send(ex);
+ ex.waitForDone();
+
+ assertEquals(__message,_received);
+ assertEquals(200,ex.getResponseStatus());
+ }
+
+
+ public void testServerWithHttpClientStreamContent() throws Exception
+ {
+ HttpClient client = new HttpClient();
+ client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
+ client.setRealmResolver(new SimpleRealmResolver(new TestRealm()));
+ client.start();
+
+ String srvUrl = "http://127.0.0.1:" + _server.getConnectors()[0].getLocalPort() + "/test/";
+
+ ContentExchange ex = new ContentExchange();
+ ex.setMethod(HttpMethods.POST);
+ ex.setURL(srvUrl);
+ ex.setRequestContentSource(new BufferedInputStream(new FileInputStream("src/test/resources/message.txt")));
+
+ _received=null;
+ client.send(ex);
+ ex.waitForDone();
+
+ String sent = IO.toString(new FileInputStream("src/test/resources/message.txt"));
+ assertEquals(sent,_received);
+
+ assertEquals(200,ex.getResponseStatus());
+ }
+
+ public static class TestRealm implements Realm
+ {
+ public String getPrincipal()
+ {
+ return "testuser";
+ }
+
+ public String getId()
+ {
+ return "test";
+ }
+
+ public String getCredentials()
+ {
+ return "password";
+ }
+ }
+
+ public static class PostServlet extends HttpServlet
+ {
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws IOException
+ {
+ String received = IO.toString(request.getInputStream());
+ _received = received;
+
+ response.setStatus(200);
+ response.getWriter().println("Received "+received.length()+" bytes");
+ }
+
+ }
+
+ protected String newResponse(String method, String uri, String cnonce, String principal, String realm, String credentials, String nonce, String qop)
+ throws Exception
+ {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+
+ // calc A1 digest
+ md.update(principal.getBytes(StringUtil.__ISO_8859_1));
+ md.update((byte)':');
+ md.update(realm.getBytes(StringUtil.__ISO_8859_1));
+ md.update((byte)':');
+ md.update(credentials.getBytes(StringUtil.__ISO_8859_1));
+ byte[] ha1 = md.digest();
+ // calc A2 digest
+ md.reset();
+ md.update(method.getBytes(StringUtil.__ISO_8859_1));
+ md.update((byte)':');
+ md.update(uri.getBytes(StringUtil.__ISO_8859_1));
+ byte[] ha2=md.digest();
+
+ md.update(TypeUtil.toString(ha1,16).getBytes(StringUtil.__ISO_8859_1));
+ md.update((byte)':');
+ md.update(nonce.getBytes(StringUtil.__ISO_8859_1));
+ md.update((byte)':');
+ md.update(NC.getBytes(StringUtil.__ISO_8859_1));
+ md.update((byte)':');
+ md.update(cnonce.getBytes(StringUtil.__ISO_8859_1));
+ md.update((byte)':');
+ md.update(qop.getBytes(StringUtil.__ISO_8859_1));
+ md.update((byte)':');
+ md.update(TypeUtil.toString(ha2,16).getBytes(StringUtil.__ISO_8859_1));
+ byte[] digest=md.digest();
+
+ // check digest
+ return encode(digest);
+ }
+
+ private static String encode(byte[] data)
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (int i=0; i<data.length; i++)
+ {
+ buffer.append(Integer.toHexString((data[i] & 0xf0) >>> 4));
+ buffer.append(Integer.toHexString(data[i] & 0x0f));
+ }
+ return buffer.toString();
+ }
+}
Modified: jetty/branches/jetty-8/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java
===================================================================
--- jetty/branches/jetty-8/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java 2010-04-06 17:59:11 UTC (rev 1471)
+++ jetty/branches/jetty-8/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java 2010-04-06 18:17:57 UTC (rev 1472)
@@ -693,7 +693,42 @@
response.assertStatusOK("8.2.3 expect 100");
}
+ /**
+ * Test Message Transmission Requirements -- Acceptable bad client behavior, Expect 100 with body content.
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc2616#section-8.2">RFC 2616 (section 8.2)</a>
+ */
+ @Test
+ public void test8_2_UnexpectWithBody() throws Exception
+ {
+ // Expect with body
+ StringBuffer req3 = new StringBuffer();
+ req3.append("GET /redirect/R1 HTTP/1.1\n");
+ req3.append("Host: localhost\n");
+ req3.append("Expect: 100-continue\n"); // Valid Expect header.
+ req3.append("Content-Type: text/plain\n");
+ req3.append("Content-Length: 8\n");
+ req3.append("\n");
+ req3.append("123456\r\n");
+ req3.append("GET /echo/R1 HTTP/1.1\n");
+ req3.append("Host: localhost\n");
+ req3.append("Content-Type: text/plain\n");
+ req3.append("Content-Length: 8\n");
+ req3.append("Connection: close\n");
+ req3.append("\n");
+ req3.append("87654321"); // Body
+
+ List<HttpResponseTester> responses = http.requests(req3);
+
+ response=responses.get(0);
+ response.assertStatus("8.2.3 ignored no 100",302);
+
+ response=responses.get(1);
+ response.assertStatus("8.2.3 ignored no 100",200);
+ response.assertBody("87654321\n");
+ }
+
/**
* Test Message Transmission Requirements
*
Copied: jetty/branches/jetty-8/tests/test-integration/src/test/resources/message.txt (from rev 1468, jetty/tags/jetty-7-to-jetty-8-base-20100406-1/tests/test-integration/src/test/resources/message.txt)
===================================================================
--- jetty/branches/jetty-8/tests/test-integration/src/test/resources/message.txt (rev 0)
+++ jetty/branches/jetty-8/tests/test-integration/src/test/resources/message.txt 2010-04-06 18:17:57 UTC (rev 1472)
@@ -0,0 +1,12 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. In quis felis nunc.
+Quisque suscipit mauris et ante auctor ornare rhoncus lacus aliquet. Pellentesque
+habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
+Vestibulum sit amet felis augue, vel convallis dolor. Cras accumsan vehicula diam
+at faucibus. Etiam in urna turpis, sed congue mi. Morbi et lorem eros. Donec vulputate
+velit in risus suscipit lobortis. Aliquam id urna orci, nec sollicitudin ipsum.
+Cras a orci turpis. Donec suscipit vulputate cursus. Mauris nunc tellus, fermentum
+eu auctor ut, mollis at diam. Quisque porttitor ultrices metus, vitae tincidunt massa
+sollicitudin a. Vivamus porttitor libero eget purus hendrerit cursus. Integer aliquam
+consequat mauris quis luctus. Cras enim nibh, dignissim eu faucibus ac, mollis nec neque.
+Aliquam purus mauris, consectetur nec convallis lacinia, porta sed ante. Suspendisse
+et cursus magna. Donec orci enim, molestie a lobortis eu, imperdiet vitae neque.
\ No newline at end of file