From cc14855ba07908ad414639160a3fc2eb91519a77 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 26 Sep 2020 04:50:09 -0400 Subject: [PATCH] Fix #661 --- httplib.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/httplib.h b/httplib.h index 5c7b7f9..2a3d261 100644 --- a/httplib.h +++ b/httplib.h @@ -4653,7 +4653,17 @@ inline bool ClientImpl::read_response_line(Stream &strm, Response &res) { const static std::regex re("(HTTP/1\\.[01]) (\\d+) (.*?)\r\n"); std::cmatch m; - if (std::regex_match(line_reader.ptr(), m, re)) { + if (!std::regex_match(line_reader.ptr(), m, re)) { return false; } + res.version = std::string(m[1]); + res.status = std::stoi(std::string(m[2])); + res.reason = std::string(m[3]); + + // Ignore '100 Continue' + while (res.status == 100) { + if (!line_reader.getline()) { return false; } // CRLF + if (!line_reader.getline()) { return false; } // next response line + + if (!std::regex_match(line_reader.ptr(), m, re)) { return false; } res.version = std::string(m[1]); res.status = std::stoi(std::string(m[2])); res.reason = std::string(m[3]);