Wrong URI parsing if no path and query string is present (wss://host?query)
Author: murillo128Created Aug 20, 2020Updated Dec 17, 2025
The URI parser extracts the host part until a / or : is found, but if the url does not contain a path or port but it does have a query string, then the host part is parsed incorrectly and the query string is appended to the host part. That makes the connection to fail
https://github.com/zaphoyd/websocketpp/blob/master/websocketpp/uri.hpp#L127
for example wss://host?query will fail but wss://host/?query will work.
According to https://tools.ietf.org/html/rfc6455 the wss path can be empty
This specification defines two URI schemes, using the ABNF syntax
defined in RFC 5234 [RFC5234], and terminology and ABNF productions
defined by the URI specification RFC 3986 [RFC3986].
ws-URI = "ws:" "//" host [ ":" port ] path [ "?" query ]
wss-URI = "wss:" "//" host [ ":" port ] path [ "?" query ]
host = <host, defined in [RFC3986], Section 3.2.2>
port = <port, defined in [RFC3986], Section 3.2.3>
path = <path-abempty, defined in [RFC3986], Section 3.3>
query = <query, defined in [RFC3986], Section 3.4>
The port component is OPTIONAL; the default for "ws" is port 80,
while the default for "wss" is port 443.
The URI is called "secure" (and it is said that "the secure flag is
set") if the scheme component matches "wss" case-insensitively.
The "resource-name" (also known as /resource name/ in Section 4.1)
can be constructed by concatenating the following:
o "/" if the path component is empty
in rfc 3986:
path = path-abempty ; begins with "/" or is empty
/ path-absolute ; begins with "/" but not "//"
/ path-noscheme ; begins with a non-colon segment
/ path-rootless ; begins with a segment
/ path-empty ; zero characters
path-abempty = *( "/" segment )
path-absolute = "/" [ segment-nz *( "/" segment ) ]
path-noscheme = segment-nz-nc *( "/" segment )
path-rootless = segment-nz *( "/" segment )
path-empty = 0<pchar>
Source: zaphoyd/websocketpp