Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对这个 Boost.Beast 示例有疑问:
https://github.com/boostorg/beast/blob/908f84cb3c023ed7c5bd19e2e5283d3218a6d820/example/advanced/server/advanced_server.cpp
在第 643 行,WebSocket 升级完成。但是,如果我理解正确的话,队列中可能仍然有异步执行的 HTTP 写入命令。因此,它们与当前的 WebSocket 通信并行执行。那合法吗?还是我还没有完全理解这个例子?
在已经发送 101 Switching Protocols 响应之后发送 HTTP 响应是不合法的。但这不可能发生,因为一旦服务器收到升级 HTTP 请求,它将遵循升级过程。在发送升级请求后发送另一个正常 HTTP 请求的客户端将出错。