-
Notifications
You must be signed in to change notification settings - Fork 43
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
The HttpSession is hard to retrieve: Add getHttpSession method to Session #218
Comments
@glassfishrobot Commented |
@glassfishrobot Commented Maybe if we stash the session into a ThreadLocal it would work? |
@glassfishrobot Commented Example: Some current implementations make any Servlet HttpSession accessed during an HTTP Upgrade essentially immutable/read-only during the lifetime of the WebSocket. Meaning changes to that HttpSession are not persisted, and information contained in that HttpSession are not updated from events outside of the WebSocket. Also: Eclipse Jetty (and apparently Apache Tomcat) implement HttpSession access in the current JSR356 api/spec as outlined at |
@glassfishrobot Commented |
@glassfishrobot Commented |
|
The request here is covered by #238. |
Currently, the only way to retrieve the HTTP session (such as the Servlet API's HttpSession) is to call HandshakeRequest's getHttpSession method. Getting the HTTP session is very often required within a WebSocket, and this design means every server endpoint must have the following configurator to expose the session to the rest of the endpoint methods:
And then later in an endpoint method:
I suggest that the HandshakeRequest isn't the only interface that needs a getHttpSession method. We should add an Object getHttpSession() method to the Session interface as well. I'm aware that the HTTP session can time out before the Session, but the fact remains that there is never more than one HTTP session per Session, that the HTTP session never changes during the life of the Session, and that when the Session is initially created during the HTTP request an HTTP session may exist for that HTTP request.
Like its counterpart on HandshakeRequest, Session's getHttpSession method should return null if no HTTP session existed when the WebSocket connection was opened.
Affected Versions
[2.0]
The text was updated successfully, but these errors were encountered: