Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.0.x-SignInWithEthereum

This commit is contained in:
Lachlan Roberts 2024-08-22 13:18:38 +10:00
commit b07a8c0104
No known key found for this signature in database
GPG Key ID: 5663FB7A8FF7E348
376 changed files with 1452 additions and 688 deletions

View File

@ -1,5 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Jetty Security Reports
url: https://eclipse.dev/jetty/security_reports.php
url: https://jetty.org/security.html
about: Please raise security issues here.

View File

@ -18,7 +18,7 @@ labels: Bug
**OS type/version**
**Description**
<!-- Do not report security issues here! See [Jetty Security Reports](https://eclipse.dev/jetty/security_reports.php) -->
<!-- Do not report security issues here! See [Jetty Security Reports](https://jetty.org/security.html) -->
**How to reproduce?**

View File

@ -56,7 +56,7 @@ This release process will produce releases:
- [ ] Merge release branches back to main branches and delete release branches.
- [ ] Verify release existence in Maven Central by triggering the Jenkins builds of CometD.
- [ ] Update Jetty versions on the website ( follow instructions in [jetty-website](https://github.com/eclipse/jetty-website/blob/master/README.md) ).
+ [ ] Update (or check) [Download](https://eclipse.dev/jetty/download.php) page is updated.
+ [ ] Update (or check) [Download](https://jetty.org/download.html) page is updated.
+ [ ] Update (or check) documentation page(s) are updated.
- [ ] Publish GitHub Releases.
- [ ] Prepare release announcement for mailing lists.

View File

@ -17,17 +17,29 @@ import java.util.concurrent.Executors;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.VirtualThreadPool;
@SuppressWarnings("unused")
public class ArchitectureDocs
{
public void configureVirtualThreads()
public void queuedVirtualThreads()
{
// tag::virtual[]
// tag::queuedVirtual[]
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setVirtualThreadsExecutor(Executors.newVirtualThreadPerTaskExecutor());
Server server = new Server(threadPool);
// end::virtual[]
// end::queuedVirtual[]
}
public void virtualVirtualThreads()
{
// tag::virtualVirtual[]
VirtualThreadPool threadPool = new VirtualThreadPool();
// Limit the max number of current virtual threads.
threadPool.setMaxThreads(200);
Server server = new Server(threadPool);
// end::virtualVirtual[]
}
}

View File

@ -1049,6 +1049,31 @@ public class HTTPClientDocs
// end::setConnectionPool[]
}
public void preCreateConnections() throws Exception
{
// tag::preCreateConnections[]
HttpClient httpClient = new HttpClient();
httpClient.start();
// For HTTP/1.1, you need to explicitly configure to initialize connections.
if (httpClient.getTransport() instanceof HttpClientTransportOverHTTP http1)
http1.setInitializeConnections(true);
// Create a dummy request to the server you want to pre-create connections to.
Request request = httpClient.newRequest("https://host/");
// Resolve the destination for that request.
Destination destination = httpClient.resolveDestination(request);
// Pre-create, for example, half of the connections.
int preCreate = httpClient.getMaxConnectionsPerDestination() / 2;
CompletableFuture<Void> completable = destination.getConnectionPool().preCreateConnections(preCreate);
// Wait for the connections to be created.
completable.get(5, TimeUnit.SECONDS);
// end::preCreateConnections[]
}
public void unixDomain() throws Exception
{
// tag::unixDomain[]

View File

@ -708,6 +708,34 @@ If you want to use virtual threads, introduced as a preview feature in Java 19 a
See also the xref:server/index.adoc#threadpool[section about configuring the thread pool].
[[threadpool-all-virtual]]
== Module `threadpool-all-virtual`
The `threadpool-all-virtual` module allows you to configure the server-wide thread pool, similarly to what you can do with the <<threadpool,`threadpool`>> Jetty module, so that all threads are virtual threads, introduced as an official feature since Java 21.
CAUTION: Only use this module if you are using Java 21 or later.
If you are using Java 19 or Java 20, use the <<threadpool-virtual-preview,`threadpool-virtual-preview`>> Jetty module instead.
The module properties to configure the thread pool are:
----
include::{jetty-home}/modules/threadpool-all-virtual.mod[tags=documentation]
----
The property `jetty.threadpool.maxThreads` limits, using a `Semaphore`, the number of current virtual threads in use.
Limiting the number of current virtual threads helps to limit resource usage in applications, especially in case of load spikes.
When an unlimited number of virtual threads is allowed, the server might be brought down due to resource (typically memory) exhaustion.
[CAUTION]
====
Even when using virtual threads, Jetty uses non-blocking I/O, and dedicates a thread to each `java.nio.channels.Selector` to perform the `Selector.select()` operation.
Currently (up to Java 22), calling `Selector.select()` from a virtual thread pins the carrier thread.
When using the `threadpool-all-virtual` Jetty module, if you have `N` selectors, then `N` carrier threads will be pinned by the virtual threads calling `Selector.select()`, possibly making your system less efficient, and at worst locking up the entire system if there are no carrier threads available to run virtual threads.
====
[[threadpool-virtual]]
== Module `threadpool-virtual`

View File

@ -328,32 +328,30 @@ Virtual threads have been introduced as a preview feature in Java 19 and Java 20
The xref:modules/standard.adoc#threadpool-virtual-preview[`threadpool-virtual-preview`] Jetty module provides support for virtual threads in Java 19 and Java 20, and it is mutually exclusive with the `threadpool` Jetty module.
The xref:modules/standard.adoc#threadpool-virtual[`threadpool-virtual`] Jetty module provides support for virtual threads in Java 21 or later, and it is mutually exclusive with the `threadpool` Jetty module.
When using Java 21, there are two Jetty modules available:
* xref:modules/standard.adoc#threadpool-virtual[`threadpool-virtual`]
* xref:modules/standard.adoc#threadpool-all-virtual[`threadpool-all-virtual`]
Both are mutually exclusive with the `threadpool` Jetty module.
If you have already enabled the `threadpool` Jetty module, it is sufficient to remove it by removing the `$JETTY_BASE/start.d/threadpool.ini` file.
When using Java 21 or later, you can enable the xref:modules/standard.adoc#threadpool-virtual[`threadpool-virtual`] module:
The xref:modules/standard.adoc#threadpool-virtual[`threadpool-virtual`] Jetty module provides a mixed thread mode, where platform threads are used to run internal Jetty tasks, but application code is invoked using virtual threads.
The xref:modules/standard.adoc#threadpool-all-virtual[`threadpool-all-virtual`] Jetty module provides a thread mode where all threads are virtual threads, including those used internally by Jetty.
You can enable either module using:
----
$ java -jar $JETTY_HOME/start.jar --add-modules=threadpool-virtual,http
----
After the command above, the `$JETTY_BASE` directory looks like this:
or
[source]
----
$JETTY_BASE
├── resources
│ └── jetty-logging.properties
└── start.d
├── http.ini
└── threadpool-virtual.ini
$ java -jar $JETTY_HOME/start.jar --add-modules=threadpool-all-virtual,http
----
Now you can customize the `threadpool-virtual.ini` file to explicitly configure the thread pool and the virtual threads and then start Jetty:
[jetty%nowrap]
....
[jetty]
setupArgs=--add-modules=threadpool-virtual,http
....
After the command above, the `$JETTY_BASE/start.d/` directory will contain the corresponding `threadpool-virtual.ini` or `threadpool-all-virtual.ini` file.
You can now explicitly configure the thread pool module properties inside the `+*.ini+` file and then start Jetty.

View File

@ -235,11 +235,14 @@ Virtual threads have been introduced in Java 19 and Java 20 as a preview feature
NOTE: In Java versions where virtual threads are a preview feature, remember to add `+--enable-preview+` to the JVM command line options to use virtual threads.
[[thread-pool-virtual-threads-queued]]
==== Virtual Threads Support with `QueuedThreadPool`
`QueuedThreadPool` can be configured to use virtual threads by specifying the virtual threads `Executor`:
[,java,indent=0]
----
include::code:example$src/main/java/org/eclipse/jetty/docs/programming/ArchitectureDocs.java[tags=virtual]
include::code:example$src/main/java/org/eclipse/jetty/docs/programming/ArchitectureDocs.java[tags=queuedVirtual]
----
[CAUTION]
@ -255,3 +258,17 @@ Enabling virtual threads in `QueuedThreadPool` will default the number of reserv
Defaulting the number of reserved threads to zero ensures that the <<execution-strategy-pec,Produce-Execute-Consume mode>> is always used, which means that virtual threads will always be used for blocking tasks.
====
[[thread-pool-virtual-threads-virtual]]
==== Virtual Threads Support with `VirtualThreadPool`
`VirtualThreadPool` is an alternative to `QueuedThreadPool` that creates only virtual threads (no platform threads).
[,java,indent=0]
----
include::code:example$src/main/java/org/eclipse/jetty/docs/programming/ArchitectureDocs.java[tags=virtualVirtual]
----
Despite the name, `VirtualThreadPool` does not pool virtual threads, but allows you to impose a limit on the maximum number of current virtual threads, in order to limit resource consumption.
Furthermore, you can configure it to track virtual threads so that a xref:troubleshooting/component-dump.adoc[Jetty component dump] will show all virtual threads, including those that are unmounted.

View File

@ -158,7 +158,7 @@ Jetty's client library provides the following `ConnectionPool` implementations:
* `DuplexConnectionPool`, historically the first implementation, only used by the HTTP/1.1 transport.
* `MultiplexConnectionPool`, the generic implementation valid for any transport where connections are reused with a most recently used algorithm (that is, the connections most recently returned to the connection pool are the more likely to be used again).
* `RoundRobinConnectionPool`, similar to `MultiplexConnectionPool` but where connections are reused with a round-robin algorithm.
* `RandomRobinConnectionPool`, similar to `MultiplexConnectionPool` but where connections are reused with an algorithm that chooses them randomly.
* `RandomConnectionPool`, similar to `MultiplexConnectionPool` but where connections are reused with an algorithm that chooses them randomly.
The `ConnectionPool` implementation can be customized for each destination in by setting a `ConnectionPool.Factory` on the `HttpClientTransport`:
@ -167,6 +167,34 @@ The `ConnectionPool` implementation can be customized for each destination in by
include::code:example$src/main/java/org/eclipse/jetty/docs/programming/client/http/HTTPClientDocs.java[tags=setConnectionPool]
----
[[connection-pool-precreate-connections]]
=== Pre-Creating Connections
`ConnectionPool` offers the ability to pre-create connections by calling `ConnectionPool.preCreateConnections(int)`.
Pre-creating the connections saves the time and processing spent to establish the TCP connection, performing the TLS handshake (if necessary) and, for HTTP/2 and HTTP/3, perform the initial protocol setup.
This is particularly important for HTTP/2 because in the initial protocol setup the server informs the client of the maximum number of concurrent requests per connection (otherwise assumed to be just `1` by the client).
The scenarios where pre-creating connections is useful are, for example:
* Load testing, where you want to prepare the system with connections already created to avoid paying of cost of connection setup.
* Proxying scenarios, often in conjunction with the use of `RoundRobinConnectionPool` or `RandomConnectionPool`, where the proxy creates early the connections to the backend servers.
This is an example of how to pre-create connections:
[,java,indent=0]
----
include::code:example$src/main/java/org/eclipse/jetty/docs/programming/client/http/HTTPClientDocs.java[tags=preCreateConnections]
----
[NOTE]
====
Pre-creating connections for secure HTTP/1.1 requires you to call `HttpClientTransportOverHTTP.setInitializeConnections(true)`, otherwise only the TCP connection is established, but the TLS handshake is not initiated.
To initialize connections for secure HTTP/1.1, the client sends an initial `OPTIONS * HTTP/1.1` request to the server.
The server must be able to handle this request without closing the connection (in particular it must not add the `Connection: close` header in the response).
====
[[request-processing]]
== HttpClient Request Processing

View File

@ -99,6 +99,15 @@
| `org.eclipse.jetty.websocket.api.**WebSocketPolicy**` | `org.eclipse.jetty.websocket.api.**Configurable**`
|===
== Server-Side Web Application APIs Changes
Jetty 12 introduced redesigned server-side APIs for web applications.
In Jetty 11, these APIs were based on a mix of Jakarta Servlet APIs and Jetty Handler APIs, while in Jetty 12 they are solely based on Jetty Handler APIs.
In Jetty 12 you can now write web applications independently of the Servlet APIs, so you can migrate Jakarta Servlets to Jetty Handlers as explained in xref:servlet-to-handler[this section].
If you were already using the Jetty 11 Handler APIs, you can migrate them to the Jetty 12 Handler APIs as explained in xref:api-changes-handler[this section].
[[servlet-to-handler]]
== Migrate Servlets to Jetty Handlers
@ -126,6 +135,8 @@ include::code:example$src/main/java/org/eclipse/jetty/docs/programming/migration
include::code:example$src/main/java/org/eclipse/jetty/docs/programming/migration/ServletToHandlerDocs.java[tags=requestContent-source]
----
Refer also to the `Content.Source` APIs detailed in xref:arch/io.adoc#content-source[this section].
=== Handler Response APIs
[,java,indent=0]
----
@ -150,9 +161,48 @@ include::code:example$src/main/java/org/eclipse/jetty/docs/programming/migration
include::code:example$src/main/java/org/eclipse/jetty/docs/programming/migration/ServletToHandlerDocs.java[tags=responseContent-trailers]
----
Refer also to the `Content.Sink` APIs detailed in xref:arch/io.adoc#content-sink[this section].
[[api-changes]]
== APIs Changes
[[api-changes-handler]]
=== `Handler`
The server-side `Handler` class, and the APIs to use for request/response processing, have been redesigned in Jetty 12.
The Jetty 11 `Handler` method:
`Handler.handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response)`
has been changed in Jetty 12 to:
`Handler.handle(Request request, Response response, Callback callback)`
The Jetty 11 `target` parameter has been removed, and in Jetty 12 it has been replaced by the information present in `Request.getHttpURI()`.
In Jetty 11, ``Handler``s would mark the fact that they handled the request, and therefore are producing a response, by calling `Request.setHandled(true)`.
In Jetty 12, this is performed by returning `true` from the `Handler.handle(\...)` method, which also requires that the `Callback` parameter must be completed, either by succeeding it or failing it.
In Jetty 11, the `Handler.handle(\...)` method has a blocking semantic, while in Jetty 12 the `Handler.handle(\...)` method has an asynchronous semantic, thanks to the `Callback` parameter.
This means that you can return from the `Handler.handle(\...)` method _before_ the response has been sent, similarly to what you can do with the Servlet APIs when you call `HttpServletRequest.startAsync()`.
Similarly, in Jetty 11 after a call to `startAsync()` you must call `AsyncContext.complete()`, while in Jetty 12 you must complete the `Callback` parameter, either by succeeding it or failing it.
In Jetty 11, `AbstractHandler` provides a utility class to implement `Handler`.
In Jetty 12, use `Handler.Abstract`.
In Jetty 11, the APIs to deal with request or response HTTP headers are based on either Jetty's `HttpFields`, or the Servlet APIs.
In Jetty 12, the HTTP headers API are only based on `HttpFields`.
Please refer to the `HttpFields` link:{javadoc-url}/org/eclipse/jetty/http/HttpFields.html[javadocs] for details.
In Jetty 11, the request content is accessed via `Request.getInputStream()` or `HttpServletRequest.getInputStream()`.
In Jetty 12, the `Request` object itself _is-a_ `Content.Source` that can be read as explained in xref:arch/io.adoc#content-source[this section].
In Jetty 12, you can use `Content.Source.asInputStream(request)` to obtain an `InputStream` and minimize the changes to your code, but remember that `InputStream` only provides blocking APIs, while `Content.Source` provides non-blocking APIs.
In Jetty 11, the response content is accessed via `Response.getOutputStream()` or `HttpServletResponse.getOutputStream()`.
In Jetty 12, the `Response` object itself _is-a_ `Content.Sink` that can be written as explained in xref:arch/io.adoc#content-sink[this section].
In Jetty 12, you can use `Content.Sink.asOutputStream(response)` to obtain an `OutputStream` and minimize the changes to your code, but remember that `OutputStream` only provides blocking APIs, while `Content.Sink` provides non-blocking APIs.
=== `HttpClient`
The Jetty 11 `Request.onResponseContentDemanded(Response.DemandedContentListener)` API has been replaced by `Request.onResponseContentSource(Response.ContentSourceListener)` in Jetty 12.
@ -165,6 +215,8 @@ The Jetty 12 model is a "demand+pull" model: when the content is available, the
For more information about the new model, see xref:arch/io.adoc#content-source[this section].
Jetty 12 introduced the concept of low-level transport for high-level protocols, described in xref:client/io-arch.adoc#transport[this section].
=== WebSocket
The Jetty WebSocket APIs have been vastly simplified, and brought in line with the style of other APIs.

View File

@ -57,8 +57,7 @@ public class ConscryptHTTP2ClientTest
sslContextFactory.setProvider("Conscrypt");
Conscrypt.setDefaultHostnameVerifier((certs, hostname, session) -> true);
HTTP2Client client = new HTTP2Client();
try
try (HTTP2Client client = new HTTP2Client())
{
client.addBean(sslContextFactory);
client.start();
@ -97,10 +96,6 @@ public class ConscryptHTTP2ClientTest
assertTrue(latch.await(15, TimeUnit.SECONDS));
}
finally
{
client.stop();
}
}
private boolean canConnectTo(String host, int port)

View File

@ -132,17 +132,12 @@ public class ConscryptHTTP2ServerTest
ClientConnector clientConnector = new ClientConnector();
clientConnector.setSslContextFactory(newClientSslContextFactory());
HTTP2Client h2Client = new HTTP2Client(clientConnector);
HttpClient client = new HttpClient(new HttpClientTransportOverHTTP2(h2Client));
client.start();
try
try (HttpClient client = new HttpClient(new HttpClientTransportOverHTTP2(h2Client)))
{
client.start();
int port = ((ServerConnector)server.getConnectors()[0]).getLocalPort();
ContentResponse contentResponse = client.GET("https://localhost:" + port);
assertEquals(200, contentResponse.getStatus());
}
finally
{
client.stop();
}
}
}

View File

@ -45,8 +45,7 @@ public class JDK9HTTP2ClientTest
Assumptions.assumeTrue(canConnectTo(host, port));
HTTP2Client client = new HTTP2Client();
try
try (HTTP2Client client = new HTTP2Client())
{
SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
client.addBean(sslContextFactory);
@ -87,10 +86,6 @@ public class JDK9HTTP2ClientTest
latch.await(15, TimeUnit.SECONDS);
}
finally
{
client.stop();
}
}
private boolean canConnectTo(String host, int port)

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Adds the Jetty HTTP client to the server classpath.

View File

@ -39,10 +39,14 @@ public class ContinueProtocolHandler implements ProtocolHandler
@Override
public boolean accept(Request request, Response response)
{
boolean is100 = response.getStatus() == HttpStatus.CONTINUE_100;
boolean expect100 = request.getHeaders().contains(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE.asString());
boolean handled100 = request.getAttributes().containsKey(ATTRIBUTE);
return (is100 || expect100) && !handled100;
if (handled100)
return false;
boolean is100 = response.getStatus() == HttpStatus.CONTINUE_100;
if (is100)
return true;
// Also handle non-100 responses, because we need to complete the request to complete the whole exchange.
return request.getHeaders().contains(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE.asString());
}
@Override

View File

@ -104,7 +104,7 @@ import org.slf4j.LoggerFactory;
* }</pre>
*/
@ManagedObject("The HTTP client")
public class HttpClient extends ContainerLifeCycle
public class HttpClient extends ContainerLifeCycle implements AutoCloseable
{
public static final String USER_AGENT = "Jetty/" + Jetty.VERSION;
private static final Logger LOG = LoggerFactory.getLogger(HttpClient.class);
@ -1141,4 +1141,10 @@ public class HttpClient extends ContainerLifeCycle
sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory);
}
@Override
public void close() throws Exception
{
stop();
}
}

View File

@ -26,20 +26,49 @@ public class HttpClientConnectionFactory implements ClientConnectionFactory
/**
* <p>Representation of the {@code HTTP/1.1} application protocol used by {@link HttpClientTransportDynamic}.</p>
*/
public static final Info HTTP11 = new HTTP11(new HttpClientConnectionFactory());
public static final Info HTTP11 = new HTTP11();
private boolean initializeConnections;
/**
* @return whether newly created connections should be initialized with an {@code OPTIONS * HTTP/1.1} request
*/
public boolean isInitializeConnections()
{
return initializeConnections;
}
/**
* @param initialize whether newly created connections should be initialized with an {@code OPTIONS * HTTP/1.1} request
*/
public void setInitializeConnections(boolean initialize)
{
this.initializeConnections = initialize;
}
@Override
public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map<String, Object> context)
{
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, context);
connection.setInitialize(isInitializeConnections());
return customize(connection, context);
}
private static class HTTP11 extends Info
/**
* <p>Representation of the {@code HTTP/1.1} application protocol used by {@link HttpClientTransportDynamic}.</p>
* <p>Applications should prefer using the constant {@link HttpClientConnectionFactory#HTTP11}, unless they
* need to customize the associated {@link HttpClientConnectionFactory}.</p>
*/
public static class HTTP11 extends Info
{
private static final List<String> protocols = List.of("http/1.1");
private HTTP11(ClientConnectionFactory factory)
public HTTP11()
{
this(new HttpClientConnectionFactory());
}
public HTTP11(ClientConnectionFactory factory)
{
super(factory);
}

View File

@ -22,7 +22,6 @@ import org.eclipse.jetty.client.Destination;
import org.eclipse.jetty.client.DuplexConnectionPool;
import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.ProcessorUtils;
@ -37,7 +36,7 @@ public class HttpClientTransportOverHTTP extends AbstractConnectorHttpClientTran
public static final Origin.Protocol HTTP11 = new Origin.Protocol(List.of("http/1.1"), false);
private static final Logger LOG = LoggerFactory.getLogger(HttpClientTransportOverHTTP.class);
private final ClientConnectionFactory factory = new HttpClientConnectionFactory();
private final HttpClientConnectionFactory factory = new HttpClientConnectionFactory();
private int headerCacheSize = 1024;
private boolean headerCacheCaseSensitive;
@ -79,25 +78,54 @@ public class HttpClientTransportOverHTTP extends AbstractConnectorHttpClientTran
return connection;
}
@ManagedAttribute("The maximum allowed size in bytes for an HTTP header field cache")
/**
* @return the max size in bytes for the HTTP header field cache
*/
@ManagedAttribute("The maximum allowed size in bytes for the HTTP header field cache")
public int getHeaderCacheSize()
{
return headerCacheSize;
}
/**
* @param headerCacheSize the max size in bytes for the HTTP header field cache
*/
public void setHeaderCacheSize(int headerCacheSize)
{
this.headerCacheSize = headerCacheSize;
}
@ManagedAttribute("Whether the header field cache is case sensitive")
/**
* @return whether the HTTP header field cache is case-sensitive
*/
@ManagedAttribute("Whether the HTTP header field cache is case-sensitive")
public boolean isHeaderCacheCaseSensitive()
{
return headerCacheCaseSensitive;
}
/**
* @param headerCacheCaseSensitive whether the HTTP header field cache is case-sensitive
*/
public void setHeaderCacheCaseSensitive(boolean headerCacheCaseSensitive)
{
this.headerCacheCaseSensitive = headerCacheCaseSensitive;
}
/**
* @return whether newly created connections should be initialized with an {@code OPTIONS * HTTP/1.1} request
*/
@ManagedAttribute("Whether newly created connections should be initialized with an OPTIONS * HTTP/1.1 request")
public boolean isInitializeConnections()
{
return factory.isInitializeConnections();
}
/**
* @param initialize whether newly created connections should be initialized with an {@code OPTIONS * HTTP/1.1} request
*/
public void setInitializeConnections(boolean initialize)
{
factory.setInitializeConnections(initialize);
}
}

View File

@ -20,7 +20,6 @@ import java.util.concurrent.TimeoutException;
import org.eclipse.jetty.client.Authentication;
import org.eclipse.jetty.client.AuthenticationStore;
import org.eclipse.jetty.client.BytesRequestContent;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpProxy;
import org.eclipse.jetty.client.HttpRequestException;
@ -35,6 +34,7 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.io.CyclicTimeouts;
import org.eclipse.jetty.util.Attachable;
import org.eclipse.jetty.util.NanoTime;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.thread.AutoLock;
import org.eclipse.jetty.util.thread.Scheduler;
import org.slf4j.Logger;
@ -146,7 +146,7 @@ public abstract class HttpConnection implements IConnection, Attachable
// Make sure the path is there
String path = request.getPath();
if (path.trim().length() == 0)
if (StringUtil.isBlank(path))
{
path = "/";
request.path(path);
@ -191,11 +191,7 @@ public abstract class HttpConnection implements IConnection, Attachable
// Add content headers.
Request.Content content = request.getBody();
if (content == null)
{
request.body(new BytesRequestContent());
}
else
if (content != null)
{
if (!headers.contains(HttpHeader.CONTENT_TYPE))
{
@ -203,10 +199,7 @@ public abstract class HttpConnection implements IConnection, Attachable
if (contentType == null)
contentType = getHttpClient().getDefaultRequestContentType();
if (contentType != null)
{
HttpField field = new HttpField(HttpHeader.CONTENT_TYPE, contentType);
request.addHeader(field);
}
request.addHeader(new HttpField(HttpHeader.CONTENT_TYPE, contentType));
}
long contentLength = content.getLength();
if (contentLength >= 0)
@ -215,6 +208,9 @@ public abstract class HttpConnection implements IConnection, Attachable
request.addHeader(new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH, contentLength));
}
}
// RFC 9110, section 10.1.1.
if (content == null || content.getLength() == 0)
request.headers(h -> h.remove(HttpHeader.EXPECT));
// Cookies.
StringBuilder cookies = convertCookies(request.getCookies(), null);
@ -243,7 +239,7 @@ public abstract class HttpConnection implements IConnection, Attachable
{
if (builder == null)
builder = new StringBuilder();
if (builder.length() > 0)
if (!builder.isEmpty())
builder.append("; ");
builder.append(cookie.getName()).append("=").append(cookie.getValue());
}

View File

@ -528,7 +528,7 @@ public abstract class HttpSender
action.run();
// Read the request content.
chunk = content.read();
chunk = content != null ? content.read() : Content.Chunk.EOF;
}
if (LOG.isDebugEnabled())
LOG.debug("Content {} for {}", chunk, request);
@ -539,6 +539,7 @@ public abstract class HttpSender
{
// No content after the headers, demand.
demanded = true;
assert content != null;
content.demand(this::succeeded);
return Action.SCHEDULED;
}

View File

@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;
import org.eclipse.jetty.client.Connection;
import org.eclipse.jetty.client.Destination;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.HttpUpgrader;
import org.eclipse.jetty.client.Request;
@ -40,6 +41,7 @@ import org.eclipse.jetty.client.transport.HttpRequest;
import org.eclipse.jetty.client.transport.IConnection;
import org.eclipse.jetty.client.transport.SendFailure;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.EndPoint;
@ -61,6 +63,7 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements IConne
private final LongAdder bytesIn = new LongAdder();
private final LongAdder bytesOut = new LongAdder();
private long idleTimeout;
private boolean initialize;
public HttpConnectionOverHTTP(EndPoint endPoint, Map<String, Object> context)
{
@ -159,12 +162,46 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements IConne
return delegate.send(exchange);
}
/**
* @return whether to initialize the connection with an {@code OPTIONS * HTTP/1.1} request.
*/
public boolean isInitialize()
{
return initialize;
}
/**
* @param initialize whether to initialize the connection with an {@code OPTIONS * HTTP/1.1} request.
*/
public void setInitialize(boolean initialize)
{
this.initialize = initialize;
}
@Override
public void onOpen()
{
super.onOpen();
fillInterested();
promise.succeeded(this);
boolean initialize = isInitialize();
if (initialize)
{
Destination destination = getHttpDestination();
Request request = destination.getHttpClient().newRequest(destination.getOrigin().asString())
.method(HttpMethod.OPTIONS)
.path("*");
send(request, result ->
{
if (result.isSucceeded())
promise.succeeded(this);
else
promise.failed(result.getFailure());
});
}
else
{
promise.succeeded(this);
}
}
@Override

View File

@ -703,7 +703,7 @@ public class ConnectionPoolTest
assertThat(connectionPool.toString(), not(nullValue()));
}
private static class ConnectionPoolFactory
public static class ConnectionPoolFactory
{
private final String name;
private final ConnectionPool.Factory factory;

View File

@ -31,12 +31,11 @@ public class HttpClientJMXTest
@Test
public void testHttpClientName() throws Exception
{
String name = "foo";
HttpClient httpClient = new HttpClient();
httpClient.setName(name);
try
try (HttpClient httpClient = new HttpClient())
{
String name = "foo";
httpClient.setName(name);
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
MBeanContainer mbeanContainer = new MBeanContainer(mbeanServer);
// Adding MBeanContainer as a bean will trigger the registration of MBeans.
@ -59,9 +58,5 @@ public class HttpClientJMXTest
assertEquals(name, oName.getKeyProperty("context"));
}
}
finally
{
httpClient.stop();
}
}
}

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Demo Handler

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
<Call name="addHandler">

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<!-- =============================================================== -->
<!-- Attach the "core" environment app deployment provider -->

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<!-- =============================================================== -->
<!-- Create the deployment manager -->

View File

@ -12,7 +12,7 @@
<!-- // ======================================================================== -->
<!-- // -->
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/global</Set>
<Call name="setAttribute">

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addBean">

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_9_3.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_9_3.dtd">
<!-- ============================================================= -->
<!-- Configure the Jetty Server instance with an ID "Server" -->

View File

@ -1,9 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_9_3.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_9_3.dtd">
<!-- =============================================================== -->
<!-- Documentation of this file format can be found at: -->
<!-- https://eclipse.dev/jetty/documentation/ -->
<!-- https://jetty.org/docs/ -->
<!-- -->
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
<!-- and can be mixed in. See start.ini file for the default -->

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_9_3.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.ee9.webapp.WebAppContext">
<Set name="contextPath">/badapp</Set>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/bar</Set>
<Set name="baseResourceAsString"><Property name="test.bar.resourceBase.alt" /></Set>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/bar</Set>
<Set name="baseResourceAsString"><Property name="test.bar.resourceBase" /></Set>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure class="org.eclipse.jetty.ee9.webapp.WebAppContext">
<Set name="contextPath">/foo</Set>
<Set name="war">

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/simple</Set>
<Set name="tempDirectory"><Property name="test.tmpBase" /></Set>

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
# tag::description[]

View File

@ -99,7 +99,7 @@ import org.eclipse.jetty.util.thread.Scheduler;
*} </pre>
*/
@ManagedObject
public class HTTP2Client extends ContainerLifeCycle
public class HTTP2Client extends ContainerLifeCycle implements AutoCloseable
{
private final ClientConnector connector;
private int inputBufferSize = 8192;
@ -492,4 +492,10 @@ public class HTTP2Client extends ContainerLifeCycle
}
return factory;
}
@Override
public void close() throws Exception
{
stop();
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">
<Call name="addConnectionFactory">

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="httpConnector" class="org.eclipse.jetty.server.ServerConnector">
<Call name="addConnectionFactory">

View File

@ -106,27 +106,26 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest
public void testPropertiesAreForwarded() throws Exception
{
HTTP2Client http2Client = new HTTP2Client();
HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client));
Executor executor = new QueuedThreadPool();
httpClient.setExecutor(executor);
httpClient.setConnectTimeout(13);
httpClient.setIdleTimeout(17);
httpClient.setUseInputDirectByteBuffers(false);
httpClient.setUseOutputDirectByteBuffers(false);
try (HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client)))
{
Executor executor = new QueuedThreadPool();
httpClient.setExecutor(executor);
httpClient.setConnectTimeout(13);
httpClient.setIdleTimeout(17);
httpClient.setUseInputDirectByteBuffers(false);
httpClient.setUseOutputDirectByteBuffers(false);
httpClient.start();
assertTrue(http2Client.isStarted());
assertSame(httpClient.getExecutor(), http2Client.getExecutor());
assertSame(httpClient.getScheduler(), http2Client.getScheduler());
assertSame(httpClient.getByteBufferPool(), http2Client.getByteBufferPool());
assertEquals(httpClient.getConnectTimeout(), http2Client.getConnectTimeout());
assertEquals(httpClient.getIdleTimeout(), http2Client.getIdleTimeout());
assertEquals(httpClient.isUseInputDirectByteBuffers(), http2Client.isUseInputDirectByteBuffers());
assertEquals(httpClient.isUseOutputDirectByteBuffers(), http2Client.isUseOutputDirectByteBuffers());
httpClient.stop();
httpClient.start();
assertTrue(http2Client.isStarted());
assertSame(httpClient.getExecutor(), http2Client.getExecutor());
assertSame(httpClient.getScheduler(), http2Client.getScheduler());
assertSame(httpClient.getByteBufferPool(), http2Client.getByteBufferPool());
assertEquals(httpClient.getConnectTimeout(), http2Client.getConnectTimeout());
assertEquals(httpClient.getIdleTimeout(), http2Client.getIdleTimeout());
assertEquals(httpClient.isUseInputDirectByteBuffers(), http2Client.isUseInputDirectByteBuffers());
assertEquals(httpClient.isUseOutputDirectByteBuffers(), http2Client.isUseOutputDirectByteBuffers());
}
assertTrue(http2Client.isStopped());
}
@ -833,16 +832,16 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest
{
ClientConnector clientConnector = new ClientConnector();
HTTP2Client http2Client = new HTTP2Client(clientConnector);
SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
clientConnector.setSslContextFactory(sslContextFactory);
HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client));
Executor executor = new QueuedThreadPool();
clientConnector.setExecutor(executor);
httpClient.start();
try (HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client)))
{
Executor executor = new QueuedThreadPool();
clientConnector.setExecutor(executor);
SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
clientConnector.setSslContextFactory(sslContextFactory);
httpClient.start();
ContentResponse response = httpClient.GET("https://webtide.com/");
assertEquals(HttpStatus.OK_200, response.getStatus());
httpClient.stop();
ContentResponse response = httpClient.GET("https://webtide.com/");
assertEquals(HttpStatus.OK_200, response.getStatus());
}
}
}

View File

@ -73,10 +73,9 @@ public class ResponseTrailerTest extends AbstractTest
}
});
HTTP2Client http2Client = new HTTP2Client();
http2Client.start();
try
try (HTTP2Client http2Client = new HTTP2Client())
{
http2Client.start();
String host = "localhost";
int port = connector.getLocalPort();
InetSocketAddress address = new InetSocketAddress(host, port);
@ -116,9 +115,5 @@ public class ResponseTrailerTest extends AbstractTest
assertNotNull(frame);
assertTrue(frame.getMetaData().isResponse());
}
finally
{
http2Client.stop();
}
}
}

View File

@ -125,7 +125,7 @@ import org.slf4j.LoggerFactory;
* <p>HTTP/3+QUIC support is experimental and not suited for production use.
* APIs may change incompatibly between releases.</p>
*/
public class HTTP3Client extends ContainerLifeCycle
public class HTTP3Client extends ContainerLifeCycle implements AutoCloseable
{
public static final String CLIENT_CONTEXT_KEY = HTTP3Client.class.getName();
public static final String SESSION_LISTENER_CONTEXT_KEY = CLIENT_CONTEXT_KEY + ".listener";
@ -217,4 +217,10 @@ public class HTTP3Client extends ContainerLifeCycle
{
return container.shutdown();
}
@Override
public void close() throws Exception
{
stop();
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">

View File

@ -54,19 +54,13 @@ public class ExternalServerTest
SslContextFactory.Client sslClient = new SslContextFactory.Client();
ClientQuicConfiguration quicConfig = new ClientQuicConfiguration(sslClient, null);
HTTP3Client client = new HTTP3Client(quicConfig);
HttpClientTransportOverHTTP3 transport = new HttpClientTransportOverHTTP3(client);
HttpClient httpClient = new HttpClient(transport);
httpClient.start();
try
try (HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP3(client)))
{
httpClient.start();
URI uri = URI.create("https://maven-central-eu.storage-download.googleapis.com/maven2/org/apache/maven/maven-parent/38/maven-parent-38.pom");
ContentResponse response = httpClient.newRequest(uri).send();
assertThat(response.getContentAsString(), containsString("<artifactId>maven-parent</artifactId>"));
}
finally
{
httpClient.stop();
}
}
@Test
@ -75,10 +69,9 @@ public class ExternalServerTest
{
SslContextFactory.Client sslClient = new SslContextFactory.Client();
ClientQuicConfiguration quicConfig = new ClientQuicConfiguration(sslClient, null);
HTTP3Client client = new HTTP3Client(quicConfig);
client.start();
try
try (HTTP3Client client = new HTTP3Client(quicConfig))
{
client.start();
// Well-known HTTP/3 servers to try.
// HostPort hostPort = new HostPort("maven-central-eu.storage-download.googleapis.com:443");
HostPort hostPort = new HostPort("google.com:443");
@ -137,9 +130,5 @@ public class ExternalServerTest
assertTrue(requestLatch.await(5, TimeUnit.SECONDS));
}
finally
{
client.stop();
}
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addBean">

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">

View File

@ -19,7 +19,7 @@
~
-->
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure>
<Ref refid="JMXConnectorServer">

View File

@ -19,7 +19,7 @@
~
-->
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure>
<Ref refid="JMXConnectorServer">

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Adds the Jetty JNDI implementation to the classpath.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Adds OpenId Connect authentication to the server.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Adds the Jetty Plus JNDI support to the classpath.

View File

@ -393,11 +393,12 @@ public abstract class ProxyHandler extends Handler.Abstract
private boolean hasContent(Request clientToProxyRequest)
{
if (clientToProxyRequest.getLength() > 0)
long contentLength = clientToProxyRequest.getLength();
if (contentLength == 0)
return false;
if (contentLength > 0)
return true;
HttpFields headers = clientToProxyRequest.getHeaders();
return headers.get(HttpHeader.CONTENT_TYPE) != null ||
headers.get(HttpHeader.TRANSFER_ENCODING) != null;
return clientToProxyRequest.getHeaders().get(HttpHeader.TRANSFER_ENCODING) != null;
}
private boolean expects100Continue(Request clientToProxyRequest)

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RuleContainer">
<Call name="addRule">
<Arg>

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Call name="addCustomizer">
<Arg>

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="insertHandler">

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Add a rule to the rewrite module to compact paths.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables a rewrite Rules container as a request customizer.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Adds the RewriteHandler to the Handler chain.

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RuleContainer">
<!-- Protects favicon handling by not processing other rules.

View File

@ -3,7 +3,10 @@
<Configure>
<New id="threadPool" class="org.eclipse.jetty.util.thread.VirtualThreadPool">
<Arg type="int"><Property name="jetty.threadPool.maxThreads" default="200" /></Arg>
<Set name="name" property="jetty.threadPool.namePrefix" />
<Set name="tracking" property="jetty.threadPool.tracking" />
<Set name="detailedDump" property="jetty.threadPool.detailedDump" />
</New>
<Call class="org.slf4j.LoggerFactory" name="getLogger">

View File

@ -11,25 +11,18 @@
<Set name="maxEvictCount" type="int"><Property name="jetty.threadPool.maxEvictCount" default="1"/></Set>
<Set name="detailedDump" type="boolean"><Property name="jetty.threadPool.detailedDump" default="false"/></Set>
<Get id="namePrefix" name="name" />
<Call class="java.lang.Thread" name="ofVirtual">
<Call class="java.lang.Thread$Builder" name="name">
<Arg>
<Property name="jetty.threadPool.virtual.namePrefix">
<Default><Ref refid="namePrefix" />-virtual-</Default>
</Property>
</Arg>
<Arg type="long">0</Arg>
<Call class="java.lang.Thread$Builder" name="inheritInheritableThreadLocals">
<Arg type="boolean"><Property name="jetty.threadPool.virtual.inheritInheritableThreadLocals" default="false" /></Arg>
<Call id="virtualThreadFactory" class="java.lang.Thread$Builder" name="factory" />
</Call>
</Call>
</Call>
<Call name="setVirtualThreadsExecutor">
<Arg>
<Call class="java.util.concurrent.Executors" name="newThreadPerTaskExecutor">
<Arg><Ref refid="virtualThreadFactory" /></Arg>
</Call>
<New class="org.eclipse.jetty.util.thread.VirtualThreadPool">
<Set name="name">
<Property name="jetty.threadPool.virtual.namePrefix">
<Default><Ref refid="namePrefix" />-virtual-</Default>
</Property>
</Set>
<Set name="maxThreads" property="jetty.threadPool.virtual.maxThreads" />
<Set name="tracking" property="jetty.threadPool.virtual.tracking" />
<Set name="detailedDump" property="jetty.threadPool.detailedDump" />
</New>
</Arg>
</Call>
</New>

View File

@ -3,7 +3,7 @@
<!-- =============================================================== -->
<!-- Documentation of this file format can be found at: -->
<!-- https://eclipse.dev/jetty/documentation/ -->
<!-- https://jetty.org/docs/ -->
<!-- -->
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
<!-- and can be mixed in. See start.ini file for the default -->

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables a server-wide accept rate limit.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Configures the ByteBufferPool used by ServerConnectors.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables a server-wide connection limit.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables CrossOriginHandler to support the CORS protocol and protect from cross-site request forgery (CSRF) attacks.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Deprecated name for requestlog using custom request logger.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables the DebugListener.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Deprecated Debug Log using DebugHandle.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Adds the jar file from $JETTY_HOME/lib/ext and $JETTY_BASE/lib/ext to the server classpath.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables Graceful processing of requests

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables GzipHandler for dynamic gzip compression for the entire server.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Generates a warning that server has been run from $JETTY_HOME rather than from a $JETTY_BASE.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Adds HTTPS protocol support to the TLS(SSL) Connector.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables the InetAccessHandler.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables JAAS for deployed web applications.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables the java.sql JPMS module.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Creates an ini template for setting JVM arguments (eg -Xmx ).

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables a low resource monitor on the server.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables the Proxy Protocol on the TLS(SSL) Connector.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Logs requests using CustomRequestLog and AsyncRequestLogWriter.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
# tag::description[]

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enable SecuredRedirectHandler to redirect all http requests to https on the secure port configured in the server.ini file.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Adds core security handling to the classpath.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enable first level session cache.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
A SessionCache that does not actually cache sessions.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables caching of SessionData in front of a SessionDataStore.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables session persistent storage in files.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables JDBC persistent/distributed session storage.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables session management.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
JDBC Datasource connections for session storage.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
JDBC Driver connections for session storage.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Creates and updates state file used by jetty.sh

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Enables statistics collection for the server.

View File

@ -13,7 +13,16 @@ etc/jetty-threadpool-all-virtual.xml
[ini-template]
# tag::documentation[]
## Platform threads name prefix.
## Virtual threads name prefix.
#jetty.threadPool.namePrefix=vtp<hashCode>
## Maximum number of current virtual threads.
#jetty.threadPool.maxThreads=200
## Whether to track virtual threads so they appear
## in the dump even if they are unmounted.
#jetty.threadPool.tracking=false
## Whether to output virtual thread's stack traces in the dump.
#jetty.threadPool.detailedDump=false
# end::documentation[]

View File

@ -37,6 +37,10 @@ etc/jetty-threadpool-virtual.xml
## Virtual threads name prefix.
#jetty.threadPool.virtual.namePrefix=qtp<hashCode>-virtual-
## Whether virtual threads inherits the values of inheritable thread locals.
#jetty.threadPool.virtual.inheritInheritableThreadLocals=true
## Max number of current virtual threads.
#jetty.threadPool.virtual.maxThreads=200
## Whether to track virtual threads so they appear
## in the dump even if they are unmounted.
#jetty.threadPool.virtual.tracking=false
# end::documentation[]

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Serve static files from a directory for the "/.well-known" context path.

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/
[description]
Creates the $JETTY_BASE/work directory as a persistent temp directory.

Some files were not shown because too many files have changed in this diff Show More