mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-08-19 08:35:02 +00:00
* Match the Connection "Upgrade" token exactly in WebSocket handshakes The server and the client both looked for "upgrade" as a substring of the Connection field value, so "notupgrade", "upgrade-not" and "xupgrade" all passed as the standalone token the handshake requires. RFC 6455 4.2.1 asks for an ASCII case-insensitive token match, and a value split across several Connection lines was missed entirely because only the first line was read. Parse the field as the comma-separated token list it is, across every line, and reuse the same helper for the server request check and the client response check. Reported by gb1dev. * Tidy up the Connection token helper Move has_header_token() out of the WebSocket-only detail block and next to the other header field helpers, forward-declaring it beside split(). Use the existing split_find(), which drops the manual found flag and stops at the first matching token. Drive the client-side test from an ordinary Server route answering 101 with a bad Connection value, rather than the hand-rolled listening socket copied from the test above it. * Keep the Connection token helper out of the split build's ABI The split build strips inline from everything below the border line, so a helper defined there becomes an exported symbol of the shared library and abidiff reports it as an added function. The tests also could not see is_websocket_upgrade() or websocket_accept_key(), since neither is declared in the part of the header that survives the split. Define has_header_token() as a static inline above the border, next to the split() declarations its two call sites already sit below, and declare the two WebSocket helpers the way ws::impl::read_websocket_frame() already is. The shared library's exported symbols are now identical to master's.