Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #3458 - jetty websocket upgrades without using websocket-servlet classes #3460

Merged

Conversation

lachlan-roberts
Copy link
Contributor

#3458

remove the dependence on jetty-servlet to use websocket server with the jetty-websocket-api
jetty-servlet exposes core classes as it is used by both the javax and jetty sides
a jetty-server WebSocketCreator can now be made and be mapped to a pathspec in JettyWebSocketServerContainer

jetty-websocket-api now defines interface ExtensionConfig which is implemented by JettyExtensionConfig in jetty-websocket-common which delegates to the core version, this is to not reimplement this in API and to also not expose the core classes

@lachlan-roberts lachlan-roberts changed the title Issue #3458 - jetty websocket upgrades without using websocket-server Issue #3458 - jetty websocket upgrades without using websocket-servlet classes Mar 13, 2019
ExtensionConfig parse(String parameterizedName);
List<ExtensionConfig> parseEnum(Enumeration<String> valuesEnum);
List<ExtensionConfig> parseList(String... rawSecWebSocketExtensions);
String toHeaderValue(List<ExtensionConfig> configs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are all these needed on the interface?

}

public ExtensionConfig(String parameterizedName)
static String toHeaderValue(List<ExtensionConfig> configs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed on the interface?

Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to have some examples of these classes actually being used by jetty API example code! Ideally tested as well!

@lachlan-roberts lachlan-roberts force-pushed the jetty-10.0.x-3458-jettyWebSocket-API branch from b704dea to 0c1e34d Compare March 14, 2019 03:27
@lachlan-roberts
Copy link
Contributor Author

@gregw i think it would be worth looking at the problems with internal extensions and changing extension parameters from the requested parameters in separate pull requests

}
catch (IllegalArgumentException e)
{
resp.setExtensions(List.of(permessageDeflate));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed.

assertEquals(req.getExtensions().stream().filter(e -> e.getName().equals("permessage-deflate")).count(), 1);
assertEquals(resp.getExtensions().stream().filter(e -> e.getName().equals("permessage-deflate")).count(), 1);

ExtensionConfig permessageDeflate = ExtensionConfig.parse("permessage-deflate");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should test setting parameters here!

@lachlan-roberts lachlan-roberts force-pushed the jetty-10.0.x-3458-jettyWebSocket-API branch from 0c1e34d to 89bee3f Compare March 14, 2019 05:46
@lachlan-roberts
Copy link
Contributor Author

@gregw I think ExtensionConfig needs further testing to test internal extensions (which are not currently implemented properly) and to test things like the client validation of the upgrade response (which currently has some bugs)

however i think these things are better to be tested in core, and this test should be more about whether extension config is wired up with the jetty-websocket-api rather than testing every case of ExtensionConfig

ExtensionConfig is now interface in jetty-websocket-api and
implemented in jetty-websocket-common, for its static methods it now
uses a ExtensionConfig.Parser found by the ServiceLoader

the api tests were moved to jetty-websocket-tests

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
websocket-servlet exposes core classes as it is used by the jetty and
javax sides, so this introduces a way to add websocket mappings
with jetty-server which does not depend on websocket-servlet

to set websocket mappings through the JettyWebSocketServerContainer
you now need to use the JettyWebSocketCreator which abstracts away
the core classes from use with the jetty websocket api

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
wire up the jetty-api extensions by copying the ExtensionConfig from
the jetty-api upgrade request to the core upgrade request

make UpgradeListener interface methods default for convenience

introduce test to test the functionality of API ExtensionConfig

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: lachan-roberts <lachlan@webtide.com>
@lachlan-roberts lachlan-roberts force-pushed the jetty-10.0.x-3458-jettyWebSocket-API branch from 7aa6c62 to dab3b64 Compare March 18, 2019 04:25
@gregw
Copy link
Contributor

gregw commented Mar 18, 2019

The force push makes it very hard to review the changes.... but as WS is still a WIP, I willl merge.

@gregw gregw merged commit 012b9e5 into jetty:jetty-10.0.x Mar 18, 2019
@lachlan-roberts lachlan-roberts deleted the jetty-10.0.x-3458-jettyWebSocket-API branch July 1, 2019 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants