Commit Graph

3357 Commits

Author SHA1 Message Date
Simone Bordet 0018c298dc
Merge pull request #4845 from eclipse/jetty-10.0.x-4808-review_httpclient_header_api
Fixes #4808 - Review HttpClient Request header APIs.
2020-05-08 17:52:51 +02:00
Lachlan 2e1c01ac8c
Merge pull request #4723 from eclipse/jetty-10.0.x-WebSocketServlet
Issue #4722 - remove websocket-servlet
2020-05-07 22:45:04 +10:00
Simone Bordet cf9df70935 Fixes #4808 - Review HttpClient Request header APIs.
Introduced:
* Request Request.headers(Consumer<HttpFields.Mutable>).
This allows applications to modify the headers, and chain calls.
It also delegates the precise semantic of put/add/remove/clear to HttpFields, so there is no API duplication.
* HttpRequest.header(HttpField) to efficiently add fields while normalizing the request (only used in implementation).

* HttpResponse.header(HttpField) to efficiently add fields while parsing the response (only used in implementation).
This pairs with HttpResponse.trailer(HttpField).
* HttpResponse.headers(Consumer<HttpFields.Mutable>) to modify the fields after they have been populated (only used in tests).

Removed:
* Request.[set,add,put,remove], replaced by headers(Consumer<HttpFields.Mutable>).

Deprecated:
* Request.header(String, String)
* Request.header(HttpHeader, String)
Both replaced by headers(Consumer<HttpFields.Mutable>) with clearer semantic for add/put/remove.

All the rest is code cleanup to remove the usage of the deprecated header() methods.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2020-05-04 23:16:59 +02:00
Lachlan Roberts e5cca92199 Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-10.0.x-WebSocketServlet
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-05-01 15:46:03 +10:00
Lachlan Roberts 9bc9082ff3 Fix broken WebSocket UTF-8 continuation test
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-05-01 13:01:40 +10:00
Lachlan Roberts 3a3c5e5df3 Fix broken OSGI tests due to websocket-util-server
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-05-01 01:35:19 +10:00
Lachlan Roberts b0e57ffd6d Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-10.0.x-LinkageErrorInvestigation 2020-04-29 22:52:33 +10:00
Lachlan Roberts bf5d4ea554 Issue #4800 - Revert MethodHandle changes & update DistributionTests
- It seems it is correct to use the `MethodHandles.publicLookup().in()`
but this does not work if same webapp is deployed twice, so the
MethodHandle changes have been reverted and the test has been disabled
until a resolution to https://bugs.openjdk.java.net/browse/JDK-8244090.

- The DistributionTest has been changed to properly reproduce the issue.
There must be a class in the signature of the websocket endpoint which
is available to both webapps and the client must send and receive an echo
message to ensure that the onOpen MethodHandle is actually invoked.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-29 22:52:26 +10:00
Greg Wilkins 8c7e34f37d
Jetty 10.0.x immutable meta data (#4777)
Made HttpURI, HttpFields and MetaData immutable.  The first two follow the same builder pattern and MetaData is constructor injection only.

* Immutable version of HttpFields

Preserve API and usage of HttpFields class while providing a read only interface and immutable implementation.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable version of HttpFields

Use an ArrayList in HttpFields. While slightly slower than the array, it will mostly be used as a builder pattern for an Immutable

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable version of HttpFields

Fixed exception type.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable version of HttpFields

asImmutable method

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

Made HttpURIU immutable with a builder pattern.
MetaData immutable and working within http module.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

Fixes from review

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

Passing tests upto and including jetty-server

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

Cleanup of HttpURI.Builder API as suggested in PR.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

Added builder for MetaData.Request

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

more api fixes

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

WIP making HttpFiels itself immutable.  Currently working up to jetty-servlet.

Need to consider if content-length really is meta data and how much and when can we trust it.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

WIP

Need to consider if content-length really is meta data and how much and when can we trust it. Also need to consider difference between h2 and h1 authority in metadata.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

jetty-client and jetty-servlet passing tests.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

Better align the style of immutability between `HttpFields` and `HttpURI`.
They both now have static build() and from() methods, plus Builder and Immutable implementations.
Potentially `Builder` could be renamed as `Mutable`

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

http2-server tests passed

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

http2-client tests passed

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

cleann build?

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

fix

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

more test fixes

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

Cleanups, mostly using EMPTY when appropriate.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

Cleanups, use immutable

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

No trailers for connect

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

Fix CONNECT path handling

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

fixed rewrite query handling

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

rename Builders to Muttables

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

misc cleanups

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

Revert to using arrays due to garbage generated by streams and iterators (12% of a simple benchmark!).
Even if this garbage is an artifact of the JIT being disabled by observation, it can hide other allocations, so best to just use simple arrays!

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

More optimizations and better test coverage.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable Metadata

various cleanups

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

More optimizations

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

review changes

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

changes after review:
 + less usage of Mutable
 + more usage of EMPTY
 + restored fragment handling

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

changes after review:
 + less usage of Mutable
 + less usage of asImmutable

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData WIP

changes after review:
 + less usage of Mutable

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

changes after review:
 + better handling of URI in ContextHandler

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

changes after review:
 + downcast in test to access mutable response headers.

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Immutable MetaData

changes after review:
 + use put instead of add for one time headers

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* private

Signed-off-by: Greg Wilkins <gregw@webtide.com>
2020-04-28 13:36:44 +02:00
Lachlan Roberts 64beae3382 Issue #4800 - test both cases individually
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-24 20:16:19 +10:00
Lachlan Roberts fb85c71f8d Issue #4800 - invalid PathParam types should be reported at Deployment
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-24 17:11:23 +10:00
Lachlan Roberts 870a765464 Issue #4800 - prevent LinkageErrors for WS lookup on JDK 14
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-24 13:31:29 +10:00
Lachlan Roberts f5b0dc56d2 Issue #4800 - Reproduce LinkageError in WebSocket unit test
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-24 13:14:42 +10:00
Lachlan Roberts 7c2d804ce9 Change the WSServer to allow deployment of multiple webapps
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-24 10:18:24 +10:00
Lachlan Roberts 6ee0f2ebbc Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-10.0.x-WebSocketServlet 2020-04-23 13:53:10 +10:00
Lachlan Roberts 33a5db0618 Issue #4722 - fix typo for websocket-util-server jar
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-22 21:27:25 +10:00
Lachlan Roberts c6e58e693b Issue #4747 - changes from review
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-22 18:10:49 +10:00
Lachlan Roberts b58697817f Issue #4722 - create new module websocket-util-server
- This module contains the WebSocketUpgradeFilter.
- Also has an internal package with the components used
  to implement websocket upgrades common to both the
  jetty and javax websocket implementations.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-22 17:26:46 +10:00
Joakim Erdfelt d1163261a0
Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-10.0.x-4747-WebSocketTCK 2020-04-21 09:07:31 -05:00
Lachlan Roberts e189691917 Issue #4722 - fix build, websocket util exporting jetty servlet with jpms
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-20 09:22:01 +10:00
Lachlan f23236b09d
Merge pull request #4775 from eclipse/jetty-10.0.x-4771-WebSocketMessageHandlerTests
Issue #4771 - cleanup and add tests for the unused ws message handlers
2020-04-20 08:43:39 +10:00
Lachlan Roberts 213e157f42 Issue #4722 - changes from review
- Fix packages exposed in the websocket configuration
- Make servlet dependency for websocket-util optional

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-17 07:50:14 +10:00
Greg Wilkins 2addb6a655
Jetty 10.0.x use HandlerList instead of HandlerCollection (#4757)
* Use HandlerList instead of HandlerCollection

Signed-off-by: Greg Wilkins <gregw@webtide.com>

* Use HandlerList instead of HandlerCollection

Signed-off-by: Greg Wilkins <gregw@webtide.com>
2020-04-15 18:42:28 +02:00
Lachlan Roberts 4047e31ce7 Issue #4771 - cleanup and add tests for the different ws message handlers
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-15 10:50:27 +10:00
Lachlan Roberts 45f822ed32 Issue #4747 - server is allowed to not select a websocket subprotocol
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-08 17:08:52 +10:00
Lachlan Roberts 4e69b48344 Issue #4747 - filter out synthetic annotated methods
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-08 15:31:42 +10:00
Lachlan Roberts 3d40e0e25d Issue #4747 - correctly copy headers in websocket JsrUpgradeListener
Headers with the same name may not have been copied properly for
header values inspected and modified with a Configurator.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-07 15:06:25 +10:00
Lachlan Roberts 625dfd1a4d Issue #4747 - Fix WS path params to work within a context path
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-07 12:18:29 +10:00
Lachlan Roberts 54ee3f3939 Issue #4747 - Throwing in onClose now calls onError
- This applies to the javax onClose method not the core onClosed method.
- Also fixes a bug where onClosed may never be called if onFrame throws.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-06 20:28:57 +10:00
Lachlan Roberts 2028b99e83 Issue #4747 - SessionID should return same String instance
Using the object hash code is not random enough to use as a unique ID.
Now using UUID.randomUUID() instead which sufficiently random.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-06 11:54:16 +10:00
Lachlan Roberts 664cb81e6d Issue #4747 - Default close status code should be normal status
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-04-06 07:48:14 +10:00
Simone Bordet 51c42f2849 Improvements to the Jetty client documentation, protocols section.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2020-04-03 15:48:54 +02:00
Lachlan Roberts 9298883627 Issue #4722 - fix typo in JavaxWebSocketConfiguration
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-03-30 10:19:37 +11:00
Lachlan Roberts 89c4504d07 Issue #4722 - remove websocket-servlet
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-03-27 16:31:37 +11:00
Lachlan d595c59622
Merge pull request #4702 from eclipse/jetty-10.0.x-4603-WS_HTTP2_NPE
Issue #4603 - avoid NPE during websocket HTTP/2 upgrade
2020-03-27 09:44:24 +11:00
Lachlan Roberts 85ea14e33d Issue #4603 - clarifications in comments and improve test
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-03-25 22:43:43 +11:00
Lachlan ea80253cca
Merge pull request #4694 from eclipse/jetty-10.0.x-4691-consistent_methodhandles_lookup
Issue #4691 - use static methods with javadoc to get MethodHandle lookups
2020-03-25 10:31:37 +11:00
Lachlan af899b0e68
Merge pull request #4602 from eclipse/jetty-10.0.x-4340-ServiceLoader
Issue #4340 - Continue after ServiceLoader ServiceConfigurationError
2020-03-25 10:30:38 +11:00
Lachlan Roberts c0b6d9f677 Issue #4691 - changes from review
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-03-24 14:30:02 +11:00
Lachlan Roberts 04cc21fe40 Issue #4691 - use static methods with javadoc to get MethodHandle lookup
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-03-23 16:43:09 +11:00
Lachlan Roberts d4c2893843 Issue #4691 - Remove unnecessary throws from getMethodHandleLookup.
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-03-23 11:44:06 +11:00
Simone Bordet 10f4fda0de Issue #4691 - Use MethodHandles.lookup() consistently in WebSocket code.
* Using MethodHandles.publicLookup().in(...) instead of privateLookupIn(...).
* Moved test WebSocket EndPoint classes into the proper package, otherwise
  they would not be accessible because the test package is not exported.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
2020-03-22 16:42:13 +01:00
Joakim Erdfelt e385dea838
Do not deploy websocket test projects
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2020-03-20 14:04:04 -05:00
Joakim Erdfelt 7e0fff9a89
Merge pull request #4686 from eclipse/jetty-10.0.x-4685-slf4j-impl-not-included
Issue #4685 - jetty-slf4j-impl not a compile/runtime dependency.
2020-03-20 12:04:32 -05:00
Joakim Erdfelt 43419802b7
Issue #4685 - Declare <scope> for jetty-slf4j-impl everywhere
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2020-03-20 11:12:08 -05:00
Joakim Erdfelt 99f1f8b897
Issue #4685 - Cleanup from review
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2020-03-20 11:07:25 -05:00
Joakim Erdfelt 9492a5379c
Issue #4685 - eliminate <version> in jetty-slf4j-impl
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2020-03-20 10:42:36 -05:00
Joakim Erdfelt 2c600f2b68
Issue #4685 - Mark jetty-slf4j-impl as test scope by default
+ Update logging in test-hazelcast-sessions
+ Update logging in test-infinispan-sessions

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2020-03-20 09:55:15 -05:00
Lachlan Roberts 04cecaaaef Issue #4340 - Change usages to more closely follow previous behaviours
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
2020-03-20 17:02:49 +11:00
Joakim Erdfelt a16abe1693
Issue #4685 - jetty-slf4j-impl not a compile/runtime dependency.
+ Mark as a test dependency

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
2020-03-19 17:46:41 -05:00