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 #5868 - allow request attributes to be set in websocket upgrade #5935

Merged

Conversation

lachlan-roberts
Copy link
Contributor

@lachlan-roberts lachlan-roberts commented Feb 2, 2021

Issue #5868 & #5865

We now remove references to the HttpServletRequest and HttpServletResponse after the websocket upgrade, and allow access to the request attribute setters during and after the websocket upgrade.

After the upgrade all relevant information from the request & response are copied locally into UpgradeHttpServletRequest and UpgradeHttpServletResponse before they are recycled.

@Override
public String getRequestedSessionId()
{
throw new UnsupportedOperationException(UNSUPPORTED_WITH_WEBSOCKET_UPGRADE);
throw new UnsupportedOperationException(UNSUPPORTED_AFTER_WEBSOCKET_UPGRADE);
Copy link
Contributor

Choose a reason for hiding this comment

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

All these methods could use the request object while not null and only throw once it is null.

@@ -400,13 +406,17 @@ public String getRemoteHost()
@Override
public void setAttribute(String name, Object value)
{
throw new UnsupportedOperationException(UNSUPPORTED_WITH_WEBSOCKET_UPGRADE);
if (request == null)
throw new UnsupportedOperationException(UNSUPPORTED_AFTER_WEBSOCKET_UPGRADE);
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 what the OP requested. If request is null, then the attribute needs to be removed from the copy of the attributes.

Signed-off-by: Lachlan Roberts <[email protected]>
@joakime
Copy link
Contributor

joakime commented Feb 9, 2021

@lachlan-roberts don't forget to set labels, projects, linked issues, etc ...

@lachlan-roberts lachlan-roberts merged commit 2549df9 into jetty-10.0.x Feb 9, 2021
@lachlan-roberts lachlan-roberts deleted the jetty-10.0.x-5868-WSUpgradeRequestResponse branch February 9, 2021 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants