소스 검색

Merge pull request #812 from web2098/AllowEmptyValueHeaders

Addressing HTTP Header with empty values
Paul-Louis Ageneau 2 년 전
부모
커밋
d16c25058f
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  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));