* 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>
The problem was that the retain/release idiom in HTTP2Session.onData()
was not respected.
Now after the call to HTTP2Stream.process(), the Data object is released.
Signed-off-by: Simone Bordet <simone.bordet@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>
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>
* silence stack traces in IdleTimeoutTest by refactoring test + avoid execution of handlers over closed streams
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
* Fixes#9210 - Jetty 12 - Review Pool and Pool.Entry
* Extracted interface Pool, renamed implementation to ConcurrentPool.
* Extracted Pool.Entry as interface.
* Moved StrategyType to ConcurrentPool.
* Made Pool.Factory.wrap() work in order to wrap Pool instances.
* Removed constructors that were explicitly taking Pool parameters, replaced by a single Pool.Factory parameter.
* Added javadocs.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
`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>
* Improved locking for HttpReceiver.ContentSource.
Improved response failure code path.
Now either responseFailure() must be called, or exchange.responseComplete() followed by HttpReceiver.abort().
Fixed failAndClose() for HTTP/2 and HTTP/3: the connection must not be closed, stream.reset() is sufficient.
Fixed flaky test HttpClientDemandTest.testTwoListenersWithDifferentDemand().
Fixed DistributionTests.testVirtualThreadPool().
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
In Jetty 12, demand after last frame invokes onDataAvailable(), so the latch needs to be counted down two times.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Made WebSocket over HTTP/2 work.
Re-enabled tests, and restored HTTP2StreamEndPoint,
as well as implemented getTunnelSupport() for HTTP/2.
Removed from HttpStream methods for upgrade that are
not necessary anymore.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
that could not be wrapped in a Chunk, because Data.EOF.retain()
throws UnsupportedOperationException.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
* Restored interim responses functionality (100 Continue, 102 Processing, 103 Early Hints) for core, ee9 and ee10.
Added ProcessingProtocolHandler and EarlyHintsProtocolHandler for the client.
Re-enabled all tests for interim responses for all protocols.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Properly implemented request and response trailers for all the transports, both client and server.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Code cleanup, removing deprecations, for class Pool,
ConnectionPool and its implementations.
Removed DuplexHttpDestination and MultiplexHttpDestination.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Now all the logic for completion is in lockedOnComplete().
Avoid throwing in ChannelCallback.succeeded() if HttpChannelState._error != null.
This is necessary because HttpChannelState._error may be set asynchronously by
some event such as HTTP/2 reset streams or idle timeouts, but if there is a
thread dispatched to the application the asynchronous event will not fail the
callback, as the failure may be noticed by the application (e.g. via a read() call).
Fixed TrailersTest.testHandlerRequestTrailers() by avoid reading again after
having read the trailers.
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
Made Chunk implement Retainable, and protocol implementations
to link the RetainableByteBuffer all the way to the Chunk.
Extended Retainable to have both a retain() and a release() methods.
Removed HTTP/2's ISession and IStream, now just using HTTP2Session and HTTP2Stream.
Removed *.Adapter classes in favor of interfaces with default methods.
Javadoc additions and clarifications.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Introduced a new io.Content class, with Content.Source, Content.Sink and Content.Chunk.
Updated the server-side to use io.Content instead of the previous server-side Content class.
Updated the client-side to use io.Content with a little specialization necessary for clients only.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Ludovic Orban <lorban@bitronix.be>