Update response_parser.cc

compatible with response status line with empty reason
This commit is contained in:
Chunting Gu
2020-12-16 17:16:13 +08:00
committed by GitHub
parent 8fd353e8d5
commit 62ada53d64
+4 -2
View File
@@ -48,7 +48,7 @@ bool ResponseParser::ParseStartLine(const std::string& line) {
std::vector<std::string> parts; std::vector<std::string> parts;
SplitStartLine(line, &parts); SplitStartLine(line, &parts);
if (parts.size() != 3) { if (parts.size() < 2) {
LOG_ERRO("Invalid HTTP response status line: %s", line.c_str()); LOG_ERRO("Invalid HTTP response status line: %s", line.c_str());
return false; return false;
} }
@@ -65,7 +65,9 @@ bool ResponseParser::ParseStartLine(const std::string& line) {
return false; return false;
} }
response_->set_reason(parts[2]); if (parts.size() > 2) {
response_->set_reason(parts[2]);
}
return true; return true;
} }