* Added javadocs where missing and updated existing in both HttpFields and HttpField.
* Removed HttpFields.takeAsImmutable() because it had a confusing semantic.
* Deprecated HttpFields.[Mutable|Immutable]HttpFields and moved their implementation to top level package private classes.
* Deprecated HttpField.valueParameters(), as there is an identical getValueParameters()
* Fixed inconsistencies of HttpField.value, where in most cases could not be null, but in one case was allowed; now it can never be null.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Improve Jetty 12 DefaultServlet
+ don't wrap the httpServletRequest unless necessary due to wrapping
+ don't wrap the httpServletResponse unless necessary due to wrapping
+ send content asynchronously if large and unfiltered
+ Remove unused boolean return from ServletChannel.handle
+ added TODOs where range request handling could calculate content length
+ Call multipartlength, even though it is always -1
+ Use static for bytes written
remove lambdas for clarity
TODO Non-blocking error dispatch
TODO isHandled does not exist
TODO checkAndPrepareUpgrade and implement servlet upgrade?
remove unused variables
review javadoc (including any warnings)
review any compiler or findbug warnings (if any)
---------
Signed-off-by: gregw <gregw@webtide.com>
* Allow better configuration of WebAppContext classloader
Moved the creation of a WebAppContext classloader into an extensible method.
* Allow better configuration of WebAppContext classloader
EE8/9 also
* Allow better configuration of WebAppContext classloader
Only close loader if context created it.
* Fix#10229 Idle Timeout
Added test to reproduce
Fixed NPE if no failure listener
Possible
Added test that idle works between requests
EE9 idle timeout
idle if read operation
Handle idleTimeout for IO operations differently
improve comments
fixed test to not expect timeout listener to be called if there is demand
Idle timeouts for IO operations are not last.
Disable transient idle timeouts since AsyncContentProducer cannot handle them.
revert test to persistent idle failures
* Updating various old/moved URL references found across project (`jetty-10.0.x`) (#10098)
+ Now that the migration of `https://eclipse.org/jetty/` to `https://eclipse.dev/jetty/` has occurred, it is time to review the URI use in our project
+ Updated URLs in poms
+ Added more URIs to XmlConfiguration
+ Updated URLs in module files
+ Updated URLs in documentation
+ Updated URLs in HTML
+ Correcting bad double-scheme URLs (eg: `http://https://www.eclipse...`)
+ Updating text in *.mod files
+ Removing `/current/` from path `/jetty/documentation/current/`
+ Fixing mailing list URL
+ Fixing github URL references in jsps
---------
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Various cleanups of StringUtil and TypeUtil
Removed deprecated and unused methods
Moved charset handling to MimeTypes
resolve IDE warnings
* updates from review
* Issue #10084 - Directory entries on return of getResourcePaths(String) should include trailing slash
* Issue #10084 - Fixing test case order of entries in collection expectation
* Issue #10084 - Implementing fix for ee9
* Issue #10084 - Fixing bug in ServletContext.getRealPath() impl
* Issue #10084 - Fixing tests in ee9 to make them compatible with ee8 conversion
* Bring Resource.getFileName in alignment with other JVM methods of the same name. (eg: Path.getFileName)
* Remove usage of instanceof Content.Chunk.Error
* Updated AsyncContent to accept a transient failures
* Updated AsyncContent to accept a transient failure with inputstream
This PR refactors the ee10 handing of servlet API request and response objects:
+ The ServletContextHandler matches the request to a servlet and creates a one time only ServletContextRequest and a ServletContextResponse
+ A reusable ServletChannel object with all the heavy weight HttpInput and HttpOutput object is associated with the ServletContextRequest and ServletContextResponse.
+ Once the handling reaches the ServletHandler, the possibly wrapped request, response and callback are associated with the ServletChannel before handling.
+ Were possible the ServletApiRequest and ServletApiResponse use the possibly wrapped request/response
Added tests to check that GzipHandler can now be nested inside of an EE10 context.
---------
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: gregw <gregw@webtide.com>
Co-authored-by: Ludovic Orban <lorban@bitronix.be>
* Make a test case to resemble a failing tck test
* Add more test cases more like the tck test
* Fixed processing of EOF frames for pushed requests.
Before, the EOF frame was not added to the HTTP2Stream queue.
When the pushed request was completing it tried to consume the available content, but it was not finding EOF and so was emitting a reset frame, causing the TCK failure.
Now the EOF frame is always added to the HTTP2Stream queue, so it is properly consumed when completing the pushed request.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Fix H2 trailers frames
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
---------
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Ludovic Orban <lorban@bitronix.be>
* IdleTimeout review
+ pass TimeoutException through all APIs
+ HttpConnection now passes on TimeoutException to HttpChannel.onFailure
* More ServerTests for idletimeout
* Recreated a ServerTimeoutsTest for multiple transports
* more robust tests
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* merged work from @sbordet and @gregw
* Various improvements to CyclicTimeouts.
* Improved reset of the earliest timeout before iteration.
* Removed check for getExpireNanoTime() == -1, since it's a valid value.
* When onExpired(Expirable) returns false, the Expirable should arrange to move its timeout in the future.
* fix keystore to please BoringSSL + use correct temp path
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
* Fixed ErrorResponseAndCallback succeeded() and failed() to call super.failed() in all cases to complete the wrapped callback.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Revert "Fixed ErrorResponseAndCallback succeeded() and failed() to call super.failed() in all cases to complete the wrapped callback."
This reverts commit 5ac57c13e0.
* WIP idleTimeout
* WIP idleTimeout
* Added context wrapper for idle timeout listener
* updates from review
---------
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Ludovic Orban <lorban@bitronix.be>
* Resolve#8819 CustomRequestLog improvement
Resolves#8819 CustomRequestLog improvements:
+ only add extra detail if the log is a CustomRequestLog
+ add extra detail as a record
+ get authentication state directly from request attribute
* protect against null core request
* protect against null core request
* Use nanotime for logged latency
* Issue #9072 refactor jetty-ee module to remove it
* Remove old ee imports in module-info.javas
* Remove jetty-ee from deps
* Fix references to jetty-ee for osgi
* Update jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java
Co-authored-by: Greg Wilkins <gregw@webtide.com>
---------
Co-authored-by: Greg Wilkins <gregw@webtide.com>
* Add test to show failure
* Fix#9760 EE9 Cookies
Fix#9760 Only set path and domain if they are not blank
* Fix#9760 EE9 Cookies
Fix#9760 Only set path and domain if they are not blank
Switch on violation rather than type
* Handle legacy cookie version and comment
* Handle cookie version and comment
---------
Co-authored-by: gregw <gregw@webtide.com>
Simplified QuotedStringTokenizer #9729
* Now implements a simple subset of `quoted-string` from RFC9110
* introduced builder
* Extracted QuotedStringTokenizer interface and re-introduced the legacy implementation
* Re-introduced the ability to have unescaped \ in filenames
* Whitespace is Character.isWhiteSpace
* Disable test pending RFC8187
* No OWS around =
* Restored dispatch=true for pushed requests.
* Restored tests that use the Servlet APIs to push.
* Ensured that pushed streams have request content EOF.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Optimize Content-Length: 0 handling
Create and use a pre-encoded HttpFields.CONTENT_LENGTH_0 constant
Used the constant in more places
renamed the `putLongField` methods of HttpFields.Mutable to just `put`
Fixed wrong docs examples
* Removed unnecessary classes, among which `BatchMode`, `CloseStatus`, etc.
* Coalesced all listener interfaces into `Session.Listener`.
* Moved `RemoteEndpoint` functionality to `Session`.
* Renamed `WebSocketPolicy` to `Configurable`.
* Renamed `WriteCallback` to just `Callback`, as it is now also used for some listener methods.
* Renamed `@OnWebSocketConnect` to `@OnWebSocketOpen`
* Renamed `Session.Listener.onWebSocketConnect()` to `onWebSocketOpen()`.
* Removed `@WebSocket` annotation attributes, because they were just a subset of the configurable ones and they can be configured directly on the Session instance.
* Removed `Session.suspend()` and `SuspendToken`, and introduced `Session.demand()`.
* Introduced `@WebSocket.autoDemand` and `Session.Listener.AutoDemanding` to support automatic demand upon exit of WebSocket handler methods.
* Removed `FrameHandler.isAutoDemanding()` and `CoreSession.isAutoDemanding()`.
* Changed the responsibility of demand from `WebSocketCoreSession` to `FrameHandler`, which in turn may delegate to `MessageSink`.
* Updated MessageInputStream to fail if an exception is thrown by the application.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Simplified the use of reflection.
* Improved `setShutdownContainer()` to take into account multiple web applications,
so it is now a `Map<ClassLoader, ContainerLifeCycle>` so that each web application
has its own container to register `JakartaWebSocketClientContainer` instances.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Removed unnecessary constructors from MetaData, MetaData.Request and MetaData.Response.
* Removed MetaData.Request.getURIString() (available as getHttpURI().toString()).
* Renamed MetaData.getFields() -> getHttpFields(), as they can be headers or trailers.
* Renamed MetaData.Request.getURI() -> getHttpURI().
* Normalized handling of contentLength, now always -1 (rather than Long.MIN_VALUE) if unknown.
* Permutated MetaData.Response constructor parameters to be consistent with MetaData.Request.
* MetaData.Request's method and httpURI must be non-null.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Deleted the Ut8fStringBuffer and Utf8Appendable classes in favour of just having Utf8StringBuilder
* Simplified the Utf8StringBuilder and CharsetStringBuilder APIs and improved their exception throwing.
* Allow for replacement characters without throwing
---------
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: gregw <gregw@webtide.com>
Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Removed requestlog attributes that were never used.
* Code cleanups to remove usage of deprecated methods.
* Using MavenPaths.findTestResource* in ee9/ee10 tests to allow ee8 translation to function
* Fixed ClientCertAuthenticatorTest in both ee9 and ee10.
* Removed deprecated ClientCertAuthenticator in both ee9 and ee10.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
* Moved -api, -common, -client to jetty-core/jetty-websocket.
* Implemented jetty-core/jetty-websocket/jetty-websocket-jetty-server using only Jetty core APIs, not Servlet.
* Fixed Graceful shutdown order.
* Fixed mistakes in HttpFieldsWrapper, wrongly calling HttpHeader.name() instead of asString().
* Updated tests to pass cleanly.
* Fixed BOMs and POM dependencies.
* Introduced websocket-jetty.mod and websocket-jetty-client.mod, now used by ee10's Jetty WebSocket.
* Fixed OSGi references to old artifactIds.
* Added test to show how to lookup and use ServerWebSocketContainer from a Handler.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
getServletPath and getPathInfo will never return an encoded path segment. Instead, they will throw an IllegalArgumentException if they are called when there is a URI with violations.
Signed-off-by: gregw <gregw@webtide.com>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Convert class BadMessageException to a HttpMessage.RuntimeException to allows different types of HttpExceptions exceptions.
This follows the pattern of the QuietException interface.
* Introduced ResponseListeners to reduce per-request allocation.
* Removed ResponseNotifier in favor of ResponseListeners.
* Introduced RequestListeners to reduce the per-request allocation.
* Removed RequestNotifier in favor of RequestListeners.
* Removed unnecessary sharing of HttpRequest.requestListeners.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Replaced usages of java.net.HttpCookie with oej.http.HttpCookie.
* Moved server-side only methods from HttpCookie to HttpCookieUtils.
* Introduced and implemented oej.http.HttpCookieStore.
* Removed now obsolete oej.util.HttpCookieStore.
* Introduced HttpScheme.isSecure(String), to avoid code duplication.
* Fixed handling of cookie "localhost" domain in HttpClient.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
There is now a Handler interface hierarchy:
+ Container is a Handler that has 1 or more contained Handlers.
+ Wrapper is a Container with only 1 handler and a setHandler method.
+ Collection is a Container with n handlers and a addHandler method
class are now:
+ Abstract implements Handler
+ AbstractContainer extends Abstract implements Container
+ BaseWrapper extends AbstractContainer implements Wrapper
+ Sequence extends AbstractContainer implements Collection
Lots of other associated cleanups
With issue #9166, ByteBufferPool was removed and replaced by
RetainableByteBufferPool. Since ByteBufferPool was used by
AbstractConnector, this change broke backwards compatibility with
third-party connectors such as junixsocket-jetty.
Since there's no longer any other ByteBufferPool, rename the
RetainableByteBufferPool interface, and thereby not only reinstate
compatibility with existing third-party libraries but also save a few
keystrokes.
https://github.com/eclipse/jetty.project/issues/9284
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
* rename sessions tests with eeX version in package name as it, we can indentify which test is failing with junit result
* get rid of some duplicate classes
Signed-off-by: Olivier Lamy <olamy@apache.org>
* Added a core Session abstraction
Sessions were already a core mechanism, but there was no API for them.
There is now a new Session interface that is available via the Request API. It is intended only for users of sessions.
The previous concrete class Session has been renamed to ManagedSession and it is used by classes that extend AbstractSessionManager.
* Fixed tests
* Use static method
* Updates from review
* Updates from review
Improved javadoc
used util Attributes interface.
* Remove usage of HandlerList and reduce usage of Handler.Collection
"The best part is no part" - Elon Musk!
The overwhelming usage of `HandlerList` and `Handler.Collection` was for adding the `DefaultHandler` after the main handler. This PR adds a getter/setter for a `DefaultHandler` on the server, so we no longer need to always create a `Handler.Collection` structure. This has allowed the deprecated `HandlerList` and `HandlerWrapper` classes to be removed.
In implementing this PR, several problems were found in the calculation of `InvocationType`, not least that it was assumed that an empty `Handler.Collection` was `BLOCKING`. When this issue was fixed, any dynamic addition of contexts (deployer or SPI server) failed as the `InvocationType` changed. So this PR also introduces the `isDynamic()` attribute of all `Handler.Container`s. A dynamic container will always return `BLOCKING` from `getInvocationType()`, as there is always a race with a new handler being added. A non-dynamic container will return a real `InvocationType`, calculated from its children, but it's mutator methods will ISE if contained handlers are changed.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Jan Bartel <janb@webtide.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
* Add documentation in "Standard Modules" section for the jmx module
* Add documentation in "Standard Modules" section for the ee8,9,10-webapp modules
* Use shorter markup tags to transclude documentation from .mod files
* Extract EE version strings into variables
* Replace literal usages of EE version numbers with custom attribute
* Use convention 'eeN' instead of 'eex' in filenames
* Update metadata tag for deploy module documentation
* Update deploy module documentation to discuss EE platform-specific deploy modules
* Add documentation for the resources module
* Add resources module into section table of contents
* Use jetty-home instead of JETTY_HOME as documentation attribute
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
+ `Server` now has setter/getter for a temp directory, which can be null
+ `Context` now has a getter for a temp directory, which is never null
+ Server root Context temp directory is either whatever is set, else a work directory, else java.io.tmpdir
+ WebInfConfiguration will still create a temp directory name, but defers to ContextHandler for creation/persistence of the temp directory
+ temp directory (and BASE) removed from the deployer, as it is now the server temp directory.
`Retainable`s that return false from `canRetain()` now are noops if `retain()` is called, which allows for a simpler calling convention.
`AsyncContent` has also been reworked to allocate less and be clearer in its use of `canRetain()`.
* Fixes#8993 - Retainability of special Chunks
* Restored Jetty 11's AsyncContentProducer and related classes in jetty-ee9-nested module (src and test).
* Introduced Retainable.canRetain().
* Removed Chunk.isTerminal() and replaced it with alternative method calls.
* Clarified AsyncContent.write() in case of Chunk.Error.
* Removed AsyncContent.write(Chunk, Callback) because it was making the API confusing.
For example, AsyncContent.close() clashing with write(EOF, NOOP), or
AsyncContent.fail(x) clashing with write(Chunk.Error, NOOP), etc.
* Improved usage of Chunk.from(..., Retainable).
* Improved usage of Chunk.slice().
* Using from() in MultiPart, rather than duplicating code.
* Fixed MultiPart.Parser.Listener.onPartContent() javadocs.
* Renamed non-retaining Chunk.from() to Chunk.asChunk().
* Removed Chunk.slice() methods, inlining them where necessary.
* Carefully reviewed all usages of read()-like methods that return a Retainable instance to make sure it is released.
* Updated HTTP/2 and HTTP/3 usages of Stream.Data to follow the correct retain/release semantic.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Reorganization of jetty-client classes.
* Moved oej.client.api to oej.client
* Moved oej.client.util to oej.client
* Moved implementation classes to oej.client.internal
* Moved transports to oej.client.transport
* Moved transport implementation classes to oej.client.transport.internal
* Moved TunnelRequest to oej.client.internal.
* Moved FastCGI transport classes to o.e.j.fcgi.transport
* Moved FastCGI transport implementation classes to o.e.j.fcgi.transport.internal
* Updated WebSocket core client to use only exported, non-internal, oej.client classes.
* Expanded oej.client.Destination APIs:
- added: getOrigin(), isSecure(), getProxy(), getConnectionPool(), getHttpClient(), send(..).
- removed: getScheme(), getHost(), getPort() because they don't uniquely identify a Destination anymore (Origin does)
* Moved destination sweeper functionality from HttpDestination to HttpClient.
HttpDestination does not implement close() anymore, now relies on LifeCycle.stop()
* Moved HttpReceiver.storeCookie() logic to HttpClient.putCookie() to avoid exposing CookieManager.
* Moved HttpClient.getAcceptEncodingField() to ContentDecoder.Factories
* Avoid public/protected Logger instances.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Alternative Handler architecture.
All Handlers are Processors, which now return a boolean to indicate the request has been accepted.
The request/response/callback are no longer modal, so there is no race with the boolean return.
Optimized PathMappings.
Avoid iterations if only ServletPathSpec instances
Avoid tests for empty mappings.
Better reset implementation
Improve suffix matching
Improve exact matching
Renamed HttpStream.getNanoTimeStamp() to getNanoTime().
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
* Extracted some non controversial cleanups from another mega PR:
+ TypeUtil class shortname used more often and includes trailing digits
+ Fixed direct stopping/starting of a nested ContextHandler
+ Fixed null path handling in nested context
+ more tests for all of the above
* Extracted some non controversial cleanups from another mega PR:
Fixed nested doStart and doStop
* Extracted some non controversial cleanups from another mega PR:
Fixed DistributionTests
* Cleanup ContextHandler
Extracted some of the goodness from #8793:
+ Clear enter/exit scope methods rather than opaque suppliers and Runnables
+ Removed overloading of "Context" class name to avoid accidental usage of wrong type.
+ Less holding onto request/response as fields
* Cleanup ContextHandler
fixed test with no server
* Updates from review.
Recycle ServletChannel
Cleanup caching comments and impl
Don't recycle after completion notification
Delay setting callback until ServletHandler.handle called
Check that the retrieved ServletChannel is for the same context.
Some classes had the second S capitalized, some did not, so now stylesheel -> styleSheet.
CSS has 2 "S" for "S"tyle"S"heet.
Also, the DOM API and the Swing API have "StyleSheet".
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
revert to using computeIfAbsent on CachingHttpContentFactory
make direct buffers configurable on CachingHttpContentFactory
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
+ Removal of __CHARSET
+ Removal of unused methods
+ Using new switch/case concepts
+ cleanup of URIUtil constants
+ cleanup of URIUtil methods
+ collapse separate methods
+ simplify encodePath()
* Javadoc updates
* equalsIgnoreEncoding cleanup (no longer used by Resource layer)
ResourceCollection should not have a path
Nor name, nor filename unless all resources agree on it.
revert combine and related methods to return Resource and not explicitly a ResourceCollection, as if there is only 1, then a collection is not needed
cleanup ResourceCollection creation. Avoid sanity checks on resolved resources.
* Resource `resolve()` and `newResource()` return null on resources that do not exist
* Introduce `Resources` utility methods and use them
* Updating javadoc
* simplify the PathResource.resolveTargetPath code
* changes to how PathResource handles aliases
* fix usages of Resource.getTargetUri()
* fixes for FileSystemResourceTest
* update javadoc for Resource.getTargetURI()
* rename getTargetURI to getCanonicalURI
* let resolveCanonicalPath return null if resource does not exist
* add test in PathResourceTest for broken symlinks
* some changes from review + optimization for exists()
* restore name to getTargetUri in Resource
* fix some tests related to PathResource changes
* revert changes to PathResource equals and hashcode
* also compare URI in PathResource
* checkAlias to resolveAlias
* PathResource cleanup
+ Adding comments about class fields.
+ Removing normalization from
input/output/comparison flows.
+ Collapsing `resolveTargetPath`
into `resolveAlias` to react
accordingly to the exceptions
that can flow out of Path.toRealPath().
+ Failure on Path.toRealPath() is never
an alias, as the resource cannot ever
be served anyway.
+ More comments in `resolveAlias()`
+ Failed / Bad / Nonexistent / Inaccessible
resources are not aliases to anything.
* Renames of targetPath/targetUri
`targetPath` to `realPath`
`targetURI` to `realURI`
* Cleanup alias/aliasResolved booleans
* More testcase cleanup around not-exist
* Don't resolve alias on Error during toRealPath
* Add test to check how Alias check behaves if non-existent resource exists later
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
Moved FastCGIProxyServlet in ee9 to FastCGIProxyHandler in core.
Moved TryFilesFilter in ee9 to TryPathsHandler in core.
Update Jetty modules to properly setup the class-path in case of proxy usage.
Fixes Surefire configuration to run the tests.
The problem is that fcgi-proxy depends on fcgi-client, so both will be put on the module-path.
However, fcgi-server is used for the tests, it is in the class-path, but depends on fcgi-client that is on the module-path.
Therefore, when a fcgi-server class tries to access a fcgi-client class, JPMS throws because the fcgi-client module does not export to the unnamed module.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>