Bläddra i källkod

Addressing HTTP Header with empty values

Addressing an issue where an HTTP header might have key values pair in the format: "X-Custom-Header: "
web2098 2 år sedan
förälder
incheckning
03390adaac
1 ändrade filer med 5 tillägg och 1 borttagningar
  1. 5 1
      src/impl/wshandshake.cpp

+ 5 - 1
src/impl/wshandshake.cpp

@@ -262,7 +262,11 @@ std::multimap<string, string> WsHandshake::parseHttpHeaders(const std::list<stri
 	for (const auto &line : lines) {
 		if (size_t pos = line.find_first_of(':'); pos != string::npos) {
 			string key = line.substr(0, pos);
-			string value = line.substr(line.find_first_not_of(' ', pos + 1));
+			string value = "";
+			if (size_t subPos = line.find_first_not_of(' ', pos + 1); subPos != string::npos )
+			{
+				value = line.substr(subPos);
+			}
 			std::transform(key.begin(), key.end(), key.begin(),
 			               [](char c) { return std::tolower(c); });
 			headers.emplace(std::move(key), std::move(value));