-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Issue #5868 - allow request attributes to be set in websocket upgrade #5935
Issue #5868 - allow request attributes to be set in websocket upgrade #5935
Conversation
…dshake Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
...-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/ServerUpgradeRequest.java
Show resolved
Hide resolved
@Override | ||
public String getRequestedSessionId() | ||
{ | ||
throw new UnsupportedOperationException(UNSUPPORTED_WITH_WEBSOCKET_UPGRADE); | ||
throw new UnsupportedOperationException(UNSUPPORTED_AFTER_WEBSOCKET_UPGRADE); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 <lachlan@webtide.com>
@lachlan-roberts don't forget to set labels, projects, linked issues, etc ... |
Issue #5868 & #5865
We now remove references to the
HttpServletRequest
andHttpServletResponse
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
andUpgradeHttpServletResponse
before they are recycled.