GitHub user isapir opened a pull request:

    https://github.com/apache/tomcat/pull/76

    added SessionInitializerFilter

    This Filter initializes the HttpSession object for the Request, which is 
required for certain operations with WebSocket requests where it is too late to 
initialize the HttpSession, but the HttpSession object is required to retrieve 
information during the Handshake process.
    
    One common use case is to retrieve the `ServletContext` by calling 
`handshakeRequest.getHttpSession.getServletContext()`.  According to the 
WebSocket specification a call to getHttpSession() should not initialize one if 
one does not exist.  If the HttpSession is not initalized then this call throws 
an NPE.
    
    Hopefully the WebSocket EG will offer a better way in the future, but until 
such time the HttpSession needs to be initialized by a Filter like this one,or 
a Listener which will run for all URIs and is therefore less optimal.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/isapir/tomcat update-03

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tomcat/pull/76.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #76
    
----
commit 7f155de0d026b0254b973646e88dde70bb1f8ab6
Author: Igal Sapir <d...@21solutions.net>
Date:   2017-10-05T17:49:19Z

    added SessionInitializerFilter
    
    This Filter initializes the HttpSession object for the Request, which is 
required for certain operations with WebSocket requests where it is too late to 
initialize the HttpSession, but the HttpSession object is required to retrieve 
information during the Handshake process.
    
    One common use case is to retrieve the `ServletContext` by calling 
`handshakeRequest.getHttpSession.getServletContext()`.  According to the 
WebSocket specification a call to getHttpSession() should not initialize one if 
one does not exist.  If the HttpSession is not initalized then this call throws 
an NPE.
    
    Hopefully the WebSocket EG will offer a better way in the future, but until 
such time the HttpSession needs to be initialized by a Filter like this one,or 
a Listener which will run for all URIs and is therefore less optimal.

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to