How Tomcat 8 Handles websocket upgrade request

后端 未结 2 1360
傲寒
傲寒 2021-01-26 01:46

I want to understand handling of websocket upgrade request in tomcat ? Is it done via filters or servlets ? How the ws upgrade request is handled by TOmcat-8.

Thanks,

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-26 02:20

    Tomcat uses a filter to look for the HTTP upgrade request that starts a WebSocket connection and passes it the the appropriate handler if it sees one.

    The Filter is configured using a ServletContainerInitializer. The location of the Filter will depend on what other Filters are configured by the web application and where the web application places them in the FilterChain. It is possible, for example, that a web application would wish to place a security filter before the Web Socket filter and Tomcat allows this.

提交回复
热议问题