Tomcat 8 如何处理 websocket 升级请求 [英] How Tomcat 8 Handles websocket upgrade request

查看:50
本文介绍了Tomcat 8 如何处理 websocket 升级请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解在 tomcat 中如何处理 websocket 升级请求?它是通过过滤器还是 servlet 完成的?TOmcat-8 如何处理 ws 升级请求.

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.

谢谢,
阿努伊

推荐答案

Tomcat 使用过滤器查找 HTTP 升级请求,该请求启动 WebSocket 连接,并在看到时将其传递给适当的处理程序.

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.

过滤器是使用 ServletContainerInitializer 配置的.过滤器的位置将取决于 Web 应用程序配置的其他过滤器以及 Web 应用程序将它们放置在 FilterChain 中的位置.例如,Web 应用程序可能希望在 Web Socket 过滤器之前放置一个安全过滤器,而 Tomcat 允许这样做.

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.

这篇关于Tomcat 8 如何处理 websocket 升级请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆