mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-01 05:02:29 +07:00
The WebSocket upgrade path matched the route and switched protocols without setting req.matched_route or calling pre_request_handler, so a check placed there (e.g. authentication) never ran for WebSocket routes. Set matched_route and run the handler before the upgrade; if it handles the request, reply with a regular HTTP response instead of 101. Also write rejected upgrade responses (from pre_routing_handler too) with write_response_with_content, so they carry Content-Length. Without it, a client reading the body waited until the keep-alive timeout.