Skip to content

Commit ceca92c

Browse files
gregwlachlan-robertssbordetlorban
authoredNov 17, 2024··
EagerContentHandler. #9051 (#12077)
Fix #9051 with EagerContentHandler to replace DelayedHandler The make the EagerContentHandler.RetainedContentLoader work efficiently this PR adjusted the buffering strategy of h1, h2 and h3 to keep and reuse a retained buffer until it is mostly full. Also fixed several bugs in XmlConfiguration: + A Set could not be used with a builder style method (kind of missing feature more than a bug) + If a property element was used in a Set it could only be a string and the type element was ignored. + When trying to find a native match, the vClass local variable was overwritten with the native TYPE being tried. This affected subsequent match attempts using the wrong vClass --------- Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com> Signed-off-by: gregw <gregw@webtide.com> Signed-off-by: Simone Bordet <simone.bordet@gmail.com> Co-authored-by: Lachlan Roberts <lachlan.p.roberts@gmail.com> Co-authored-by: Simone Bordet <simone.bordet@gmail.com> Co-authored-by: Ludovic Orban <lorban@bitronix.be>
1 parent 350944b commit ceca92c

File tree

59 files changed

+2076
-756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2076
-756
lines changed
 

‎documentation/jetty/modules/operations-guide/pages/modules/standard.adoc

+15
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,21 @@ The module properties are:
129129
include::{jetty-home}/modules/debuglog.mod[tags=documentation]
130130
----
131131

132+
[[eager-content]]
133+
== Module `eager-content`
134+
135+
The `eager-content` module installs the `org.eclipse.jetty.server.handler.EagerContentHandler` at the root of the `Handler` tree.
136+
137+
The `EagerContentHandler` can eagerly load request content, asynchronously, before calling the next `Handler`.
138+
For more information see xref:programming-guide:server/http.adoc#handler-use-eager[this section].
139+
140+
`EagerContentHandler` can eagerly load content for form uploads, multipart uploads and any request content, and you can configure it with different properties for these three cases.
141+
142+
The module properties are:
143+
144+
----
145+
include::{jetty-home}/modules/eager-content.mod[tags=documentation]
146+
----
132147

133148
[[eeN-deploy]]
134149
== Module `{ee-all}-deploy`

‎documentation/jetty/modules/programming-guide/pages/server/http.adoc

+38
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,44 @@ In the example above, `ContextHandlerCollection` will try to match a request to
11981198
NOTE: `DefaultHandler` just sends a nicer HTTP `404` response in case of wrong requests from clients.
11991199
Jetty will send an HTTP `404` response anyway if `DefaultHandler` has not been set.
12001200

1201+
[[handler-use-eager]]
1202+
==== EagerContentHandler
1203+
1204+
`EagerContentHandler` reads eagerly the HTTP request content, and invokes the next `Handler` in the `Handler` tree when the request content has been read.
1205+
1206+
`EagerContentHandler` should be installed when web applications use blocking I/O to read the request content, which is the typical case for Servlet or RESTful (JAX-RS) web applications.
1207+
1208+
Because the request content is read eagerly and asynchronously, the web application will never (or rarely) block while reading the request content.
1209+
In this way, the application obtains the benefits of asynchronous I/O without forcing web application developers to use more complicated asynchronous I/O APIs.
1210+
1211+
The `Handler` tree structure looks like the following:
1212+
1213+
[,screen]
1214+
----
1215+
Server
1216+
└── (GzipHandler) // optional
1217+
└── EagerContentHandler
1218+
└── ContextHandler /app
1219+
└── AppHandler
1220+
----
1221+
1222+
`EagerContentHandler` should be installed in the `Handler` tree _after_ other ``Handler``s that may modify or transform the request content, like for example the `GzipHandler`.
1223+
1224+
`EagerContentHandler` eagerly reads request content in the following cases:
1225+
1226+
* Form request content.
1227+
* MultiPart request content.
1228+
* Any other type of request content.
1229+
1230+
For Form request content, `EagerContentHandler` reads the whole request content, parses it into a `Fields` object, and then invokes the next `Handler`.
1231+
This allows web applications that use blocking API calls such as `HttpServletRequest.getParameterMap()` to avoid blocking, since they can directly use the already created `Fields` object.
1232+
1233+
Similarly, for MultiPart request content, `EagerContentHandler` reads the whole request content, parses it into `MultiPartFormData.Parts`, and then invokes the next `Handler`.
1234+
This allows web applications that use blocking API calls such as `HttpServletRequest.getParts()` to avoid blocking, since the can directly use the already created `MultiPartFormData.Parts` object.
1235+
1236+
For other types of request content, `EagerContentHandler` reads and retains request content bytes up to a configurable amount, and then invokes the next `Handler`, without any further processing of the request content bytes.
1237+
This allows web applications that use blocking API calls such as `HttpServletRequest.getInputStream()` to avoid blocking in most cases (if the request is smaller than what has been configured in `EagerContentHandler`).
1238+
12011239
[[handler-use-servlet]]
12021240
=== Servlet API Handlers
12031241

0 commit comments

Comments
 (0)