Commit Graph

264 Commits

Author SHA1 Message Date
Jan Bartel 810eccaeea Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.1.x 2024-05-28 10:23:00 +10:00
Simone Bordet 36cdc12ab7 Fixed JPMS declarations.
Some require transitive was missing, and has been added.
In other cases, making a field private (e.g. for log instances) made the warning go away.
In another case, removed explicit dependency on websocket core exception, as it was not necessary.

Clean up the POMs for jetty-eeN-annotations, that had unnecessary dependencies.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2024-05-23 22:06:01 +02:00
Greg Wilkins 10d0898460
Fix #11811 insensitive header name set (#11823)
* Fix #11811 insensitive header name set

Fix #11811 insensitive header name set by:
 + Using a EnumSet and TreeSet to ensure no duplicates in the set
 + Using an ArrayList to preserve the ordering (not necessary, but useful).

* updates from review
2024-05-23 06:42:01 +10:00
gregw f684b69977 Merge branch 'jetty-12.0.x' into jetty-12.1.x 2024-05-22 15:42:00 +10:00
Greg Wilkins a1b3acb08a
Fixed header cache for unknown values (#11808)
Avoid adding the unknown marker into the CACHE index. Issue introduced in #11661 fixing #11659
2024-05-21 10:40:43 +10:00
Greg Wilkins 4c1c6a2652
Implemented servlet 6.1 redirect with content (#11743)
* Implemented servlet 6.1 redirect with content

Added option for server to generate a short html redirect body content, as per RFC9110 (default false)
Allowed an aggregated servlet response content to be used if clear is false.

* Redirect is a noop in include

* Fixed init order

This style of extensibility (calling virtuals from constructors) is very fragile.

* Update javadoc from review

Also update EE10 to also noop included response methods

* Update javadoc from review

Also update EE10 to also noop included response methods

* Update javadoc from review

Also update EE10 to also noop included response methods

* Update jetty-ee11/jetty-ee11-servlet/src/main/java/org/eclipse/jetty/ee11/servlet/ServletApiResponse.java

Co-authored-by: Jan Bartel <janb@webtide.com>

* Updating ee11 jsp-impl to 11.0.0-M19

* Updates from review

* updates from review

* Update jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java

Co-authored-by: Simone Bordet <simone.bordet@gmail.com>

---------

Co-authored-by: Jan Bartel <janb@webtide.com>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
2024-05-20 23:20:24 +10:00
Joakim Erdfelt 9160108b6b Issue #11776 - NPE proteection in Request.getServerPort
If the HttpURI is scheme-less, the attempt to get the port can result in a NPE
2024-05-14 09:37:08 +02:00
Lachlan Roberts 932c03bcab Issue #11748 - fix in PathMappings for websocket pathParam matching
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2024-05-06 16:41:03 +10:00
Ludovic Orban bb633b8a0f
Fix `HttpFields.Mutable.Wrapper.computeField()` (#11688)
* #11687 make HttpFields.Mutable.Wrapper.computeField() call onRemoveField() and remove the field when null is returned by computeFn
* #11687 replace IAE with NPE
* #11687 replace collect(Collectors.toList()) with toList()

---------

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
2024-04-23 18:13:01 -05:00
Joakim Erdfelt 4cc938429f
Issue #11648 - Introducing HttpDateTime class. (#11672)
+ Introduces HTTP (and Cookie) Date/Time parsing
  according to spec algorithms.
+ Introduces formatting according to spec
  mandated preferred RFC 1123 format.
+ Deprecate DateParser
2024-04-23 17:17:59 -05:00
Joakim Erdfelt 8b1c6bcd06
Issue #11659 - Properly ignore OWS before field values. (#11661)
* implemented changes to CACHE and parseFields to handle OWS properly for all UNMATCHED_VALUE headers.
* added 3 new OWS test cases (that fail in 12.0.x HEAD btw) to handle this OWS case.
2024-04-18 20:33:25 -05:00
Greg Wilkins 33feac33e7
Revert "Revert NON_POOLING change" (#11649)
This reverts commit 2bf7d6cecc.
2024-04-18 15:52:03 +10:00
Joakim Erdfelt 6320839bff
Issue #11488 - unset port is -1 to be compatible with Java classlib (#11578)
+ Changing unset port in HttpURI to -1 (from 0)
+ Changing unset port in HostPort to -1 (from 0)
2024-04-04 10:26:15 -05:00
Greg Wilkins 9b6944e04a
Remove usages of URIUtil.toURI and URIUtil.split (#11577)
* Issue #11567 - fix relative path for resourceBase set in DefaultServlet

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>

* Remove the ResourceFactory adaption from between baseResource and a HttpContent.Factory

* Remove toURI usage

* ensure ee9 DefaultServlet encodes the pathInContext

* Moved toURI functionality to ResourceFactory

* use context baseResource if baseResource not set

* removed usages of URIUtil.split

* fixed javadoc

* updates from review

* updates from review

* updates from review

* updates from review

* fixed resource leak in test

* fixed resource leak in test

* updates from review

* Fixes to URIUtil for Windows (#11585)

* Fixes for Windows
* Remove test that is not needed

* inlined resolveOrNew

---------

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2024-03-28 16:32:03 +01:00
Ludovic Orban 89c41b2550
Cleanup Resource IO (#11364)
Refactorings to rationalize and simplify how we do IO with resources internally by introducing the IOResources helper.

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
2024-03-28 11:08:44 +01:00
Joakim Erdfelt 05aa1e1b08
Issue #11495 - Add UriCompliance rules that follow the HTTP / URI / Servlet specs for illegal & suspicious characters (#11496)
* Issue #11495 - Add UriCompliance rules that follow the HTTP / URI / Servlet specs for illegal & suspicious characters
* more illegalPathCharacterData test cases
* Correcting SUSPICIOUS_PATH_CHARACTERS semantic (encoded and decoded)
* Check for illegal and suspicious characters as we are parsing the path.
* Only look for ambiguous paths if we know there are dots or encodings.

---------
Co-authored-by: gregw <gregw@webtide.com>
2024-03-27 09:28:30 -05:00
Jan Bartel 2fc7ad87d8
Reintroduce Cross Context Dispatch in Jetty 12 (#11451)
Re-introduce some support for cross context dispatch
2024-03-25 18:44:44 +01:00
Greg Wilkins 51fc906d37
Optimized ReservedThreadExecutor with ThreadIdPool (#11498)
* Introduced ThreadIdPool and replaced ThreadLocal with it
 * Modified ReservedThreadExecutor to be backed by a ThreadIdPool of semaphores

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: gregw <gregw@webtide.com>
Co-authored-by: Ludovic Orban <lorban@bitronix.be>
2024-03-21 16:53:14 +01:00
Greg Wilkins c25e1aa7ff
Fix PerfRegression by preparing field cache (#11517)
Fix #11513 by preparing the field cache
2024-03-13 21:42:14 +01:00
Greg Wilkins ffb5458720
Restored removed constructor (#11512)
Fix #11509 by restoring removed constructor as deprecated
2024-03-13 17:49:58 +01:00
Greg Wilkins 80f912a121
Improve HTTP parsing long look-ahead (#11486)
Use ByteBuffer.getLong to look for entire request (GET / HTTP/1.1) or response (HTTP/1.1 200 OK) line with 2 long lookups.  Failing that, a single long lookup is sufficient to determine the common methods and/or HttpVersion.

* Cleanup generator also

* Added a fallback int lookup
2024-03-05 17:34:14 +01:00
Greg Wilkins 56e05a973f
HttpURI toURI passes all info (#11468)
* HttpURI toURI passes all info

Fix #11465 and #7750
HttpURI.toURI user and fragment are retained.
Use to URI(String) constructor, as all URI constructors will parse the URI anyway.

* HttpURI toURI passes all info

Fix #11465 and #7750
HttpURI.toURI user and fragment are retained.
Use to URI(String) constructor, as all URI constructors will parse the URI anyway.
2024-02-29 17:46:06 +01:00
Joakim Erdfelt 97cb50ead9
Improve Error messages for Ambiguous URIs (#11457)
* Some testing of HttpURI for Issue #11448
* Issue #11448 - improved stacktrace message for ambiguous URI
2024-02-28 06:15:56 -06:00
Joakim Erdfelt 98ceb73cc6
Issue #11387: Reintroduce MultiPartCompliance.LEGACY in ee9/ee8 (#11388)
* Issue #11387: Reintroduce MultiPartCompliance.LEGACY in ee9/ee8
* Correcting javadoc
* Updating MultiPartCaptureTest to ...
  * Test with MultiPartFormData.Parser and MultiPart.Parser
 * Enable all test cases
    * base64 behaviors modified to not auto-decode base64 content
    * forms submitted without `_charset_` part (some using a different
       charset than UTF-8, like `Shift_JIS`)
* Fixing checkstyle warning
* Re-enable Part-ContainsContents expectations
* Rename MultiPartCompliance.NO_CRLF_AFTER_PREAMBLE to WHITESPACE_BEFORE_BOUNDARY to fit spec better
* Make ee9/ee8 legacy parser use legacy tokenization
* Testing ee9/ee8 legacy parser base64 auto-decoding behaviors
* Cleanup jetty-test-multipart class naming
* Adding ee10 tests against raw multipart examples
* Adding shorter whitespace multipart test
* Adding jetty-core version of failing ee10 tests
* Fixed missed notification for CR content in case of 1 chunk ending with CR and the next chunk ending with LF.
* Removed internal unused class MultiPartParser.
* Adding MultiPartCompliance.Violation events
  + in MultiPart.Parser
  + in MultiPartFormData.Parser
* lenient mode behavior
* new name fits violation better
+ adding violation to MultiPart.Parser.parseHeaderStart
* some simple cleanup of new ee9 code

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
2024-02-27 15:09:26 -06:00
Joakim Erdfelt 866f44584c
Issue #11361 - UriCompliance.checkUriCompliance improvements (#11444)
* Issue #11361 - UriCompliance.checkUriCompliance improvements
2024-02-27 06:32:07 -06:00
Joakim Erdfelt 2d51170be2
Fixes #11310 - multipart parser dropping some relevant CR bytes in parts (#11409)
Fixed case in MultiPart.Parser where a small chunk contains part of the boundary.

Added and fixed related tests.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
2024-02-21 21:43:26 +01:00
Greg Wilkins f07d812698
Fix #11414 URI schema and port normalization (#11416)
* Issue #11414 - use HttpURI instead of URIUtil to have a single point of spec behavior

* Issue #11414 - enforce lowercase scheme in HttpConfiguration.secureScheme

* Issue #11414 - Scheme produced on `Location` header is lowercase

* Issue #11414 - Scheme to lowercase

* Issue #11414 - Scheme to lowercase

* Revert change to HttpClient

* Added schema port knowledge to URIUtil

* Fixed tests for normalized URIs

* updates from review

* updates from review

* Fix tests

* Restored methods as deprecated

* More testing

---------

Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2024-02-20 20:12:55 +01:00
Greg Wilkins 08174a3042
Fix #11401 StringBuilder rather than StringBuffer (#11406) 2024-02-19 14:52:17 +00:00
Simone Bordet 4e28331595
Fixes #11095 - IllegalStateException for completed requests with GzipHandler (#11210)
* In ServletChannel, in COMPLETE state, there was a check comparing the number of bytes written with that declared by Content-Length.
Unfortunately the check was wrong in case of gzip, because it was comparing the application length with the gzipped length, resulting in a late sendErrorOrAbort() that was an abort() because the response was already fully sent.
Furthermore, if sendErrorOrAbort() was actually an abort(), there was an unnecessary attempt to complete the output.
* In GzipHandlerResponseAndCallback there were 2 last writes: one when the application calls output.close(), and one when the callback is succeeded.
Furthermore, when no content needs to be written, it was still compressed, causing an IOException in ChannelResponse (again when double-checking the bytes written, since Content-Length was 0, but the gzip header and trailer were written).
* Updates semantic of when to add the "Vary" header.
Now it is always only added by GzipHandler, when it would be possible to generate a response that might be compressed (even if it will not).
* Added *.bz2 mime-type.
Updated GzipHandler with the correct mime-type for *.bz2: application/x-bzip2.
* Improved checks for the number of bytes written against declared content-length.
This is necessary because welcome files are written by DefaultServlet (most of the times) bypassing the Servlet classes, using ServletContextResponse directly.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2024-01-27 10:50:30 +01:00
Greg Wilkins c6c5f07d51
Fixes for Spring core integration (#11288)
* Cleanup of HttpFields to improve spring integration

* Fixed Subscriber for spring integration

* Fixed implementation of ContentSinkSubscriber.
Added comment to clarify behavior of ContentSinkPublisher.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>

* Apply suggestions from code review

Co-authored-by: Simone Bordet <simone.bordet@gmail.com>

* updates from review

* updates from review

* updates from review

* updates from review

* fix canRetain

* updates from review

---------

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2024-01-26 12:18:51 +09:00
Joakim Erdfelt 08af80329b
Issue #11281 - fix two NPEs seen during MultiPart with DEBUG enabled (#11313) 2024-01-25 07:43:11 -06:00
Joakim Erdfelt 3853628074
Issue #11253 - Cleanup ComplianceViolation behavior to allow Cookie / URI / MultiPart compliance to also receive listener events. (#11254)
+ Introduce new events on `ComplianceViolation.Listener`
+ Introduce new `ComplianceViolation.Listener.initialize()` to allow for a new Listener at the appropriate time (to support per-request listeners)
+ Introduce new `ComplianceViolation.CapturingListener`
+ Introduce new `HttpConfiguration.(add/remove/get)ComplianceViolationListener()` methods.
+ Deprecate/Remove handling of `recordComplianceViolations` in `HttpConnection` and `HttpConnectionFactory` classes.
+ Produce warnings if use of `ComplianceViolation.Listener` as beans is still present.
+ Add `ComplianceViolation.Listener` support to `UriCompliance` locations.
+ Add `ComplianceViolation.Listener` support to `MultiPartCompliance` locations.
+ Add `ComplianceViolation.Listener` support to `CookieCompliance` locations.
+ Add `ComplianceViolation.Listener` support to `HttpCompliance` locations in HTTP/2 and HTTP/3

---------

Co-authored-by: gregw <gregw@webtide.com>
2024-01-24 08:24:05 -06:00
Greg Wilkins a2d86c7f67
Fix #11290 empty field (#11291)
Fixed cacheable empty field for #11290
2024-01-18 22:21:43 +00:00
Joakim Erdfelt 2c7e07e516
Merge pull request #11262 from jetty/fix/12.0.x/javadoc-typos
Correct some javadoc typos
2024-01-12 08:12:58 -06:00
Simone Bordet a9e564ad8c
Fixes #10220 - Implement CrossOriginHandler. (#11093)
Introduced CrossOriginHandler.
Added cross-origin Jetty module.
Added CrossOriginHandler documentation to the programming guide.
Added CrossOriginHandler documentation to the operations guide.
Added cross-origin headers to the HttpHeader enum.
Added test cases.
Deprecated ee10 CrossOriginFilter.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2024-01-12 09:57:21 +01:00
Joakim Erdfelt c8914c081a
Adding missing javadoc 2024-01-11 11:27:57 -06:00
Joakim Erdfelt 3a867c40f5
Fix javadoc typos 2024-01-11 11:26:20 -06:00
Simone Bordet 581f9ae9f4
Merged branch 'jetty-11.0.x' into 'jetty-12.0.x'.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2024-01-08 10:19:20 +01:00
Lachlan Roberts 592ccf7da0 Issue #11080 - copy ByteBuffer for non-retainable chunks
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2023-12-19 15:11:43 +11:00
Simone Bordet 8f019b96b0 Fixes #11064 - Jetty 12: NPE if MultiPartFormData.setFilesDirectory() is not called.
Now trying to use $JETTY_BASE/work, otherwise throwing IllegalArgumentException with a descriptive message.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2023-12-14 19:44:05 +01:00
Greg Wilkins b0d259118c
Fixes #10956 - Reviewed Expect 100 Continue Handler (#10957)
Removed duplicate handling from servlet. Now only handled in core in HttpChannelState and protected it from concurrent writes.
Added additional tests.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
2023-12-12 16:01:11 +01:00
Simone Bordet 82fbf3d4e9
Merged branch 'jetty-11.0.x' into 'jetty-12.0.x'.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2023-11-29 13:54:49 +01:00
Simone Bordet a15a4b0a23
Fixes #10919 - EE10 multipart parsing may include '\r' at the front under certain conditions (#10921)
Setting MultiPart.Parser.crContent=false when the boundary is matched.
This is necessary when a read chunk ends with \r\n, and then matches the boundary on the next read chunk, and avoids to emit the CR as part content.

Fixed case of a chunk ending with \r.

Fixed case where a CR in a previous chunk is followed by a boundary at index 0 in the next chunk.
The CR should not be emitted as content, and crContent reset to false.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2023-11-29 09:17:04 +01:00
Greg Wilkins 7dcab84b91
Fix jetty 12.0.x transient timeouts (#10844)
Fixes #10234

* Introduced transient failures in reads where a failure chunk has last=false.
* Transient failure now do not fail the handler callback.
* Improve eeN ContentProducer to more carefully assert transient and terminal errors + enable HttpInputIntegrationTest
* Do not add connection: close to the response when the error is transient
* Rework ChunksContentSource to support null chunks
* Added tests to verify the new transient failure cases
* Review all code that handles failure, and handling correctly transient failure, either by making them fatal, and/or by failing Content.Source.

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Co-authored-by: Ludovic Orban <lorban@bitronix.be>
Co-authored-by: Olivier Lamy <olamy@apache.org>
Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Co-authored-by: Chad Wilson <chadw@thoughtworks.com>
Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
2023-11-23 15:25:03 +01:00
Simone Bordet e933116997
Merged branch 'jetty-11.0.x' into 'jetty-12.0.x'.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2023-11-19 22:09:10 +01:00
Jan Bartel 467f026d37
Jetty 12.0.x 10716 charset printwriter (#10737)
* Issue #10716 tck compliance for setting response charset

---------

Co-authored-by: gregw <gregw@webtide.com>
2023-10-19 05:09:42 +02:00
Greg Wilkins ffe80cd1f2
MutableHttpFields.asImmutable avoids copy (#10651)
* Avoid a copy in MutableHttpFields.asImmutable if the mutable is never mutated again.
* reduce instance creations needed for iterations
---------
Co-authored-by: Ludovic Orban <lorban@bitronix.be>
2023-10-17 08:58:19 +11:00
Greg Wilkins 8331809c40
Fix getCharacterEncoding issue with #10563 (#10650)
Do not persist a defaulted charset used in the request.
Throw `UnsupportedEncodingException` from `getReader`
2023-10-03 12:45:40 +11:00
Greg Wilkins 1a207dbeea
An omnibus PR for changes needed to support webfunctions (#10563)
Web functions are currently supported with servlets. These changes add/move utility classes to core to better support direct usage of core APIs
 * increase usage of Charset in request
 * Added flush mechanism to BufferedContentSink
2023-09-27 09:29:15 +10:00
Greg Wilkins f9ca02c393
ConditionalHandler (#10492)
Added a Conditional Handler

Co-authored-by: Jan Bartel <janb@webtide.com>
2023-09-22 09:25:24 +10:00