mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-21 20:01:46 +00:00
Accept an uppercase URL scheme
parse_url rejected any scheme containing an uppercase letter, so
Client("HTTPS://..."), WebSocketClient("WSS://...") and a redirect to
"Location: HTTPS://..." failed, although the scheme is case-insensitive
(RFC 3986 3.1). Lowercase the scheme in parse_url so that every caller
compares one canonical form and selects TLS for it.
This commit is contained in:
1 parent
a6ab971a3f
commit
726e4583ef
2 files changed
+59
-2
No files matched your search
@@ -914,7 +914,8 @@ inline bool parse_url(const std::string &url, UrlComponents &uc) {
|
||||
|
||||
auto sep = url.find("://");
|
||||
if (sep != std::string::npos) {
|
||||
uc.scheme = url.substr(0, sep);
|
||||
// Schemes are case-insensitive (RFC 3986 3.1)
|
||||
uc.scheme = case_ignore::to_lower(url.substr(0, sep));
|
||||
|
||||
// Scheme must be [a-z]+ only
|
||||
if (uc.scheme.empty()) { return false; }
|
||||
|
||||
Reference in new issue
Block a user