Skip to content

Commit cc14855

Browse files
committed
Fix #661
1 parent 56c4187 commit cc14855

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

httplib.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4653,7 +4653,17 @@ inline bool ClientImpl::read_response_line(Stream &strm, Response &res) {
46534653
const static std::regex re("(HTTP/1\\.[01]) (\\d+) (.*?)\r\n");
46544654

46554655
std::cmatch m;
4656-
if (std::regex_match(line_reader.ptr(), m, re)) {
4656+
if (!std::regex_match(line_reader.ptr(), m, re)) { return false; }
4657+
res.version = std::string(m[1]);
4658+
res.status = std::stoi(std::string(m[2]));
4659+
res.reason = std::string(m[3]);
4660+
4661+
// Ignore '100 Continue'
4662+
while (res.status == 100) {
4663+
if (!line_reader.getline()) { return false; } // CRLF
4664+
if (!line_reader.getline()) { return false; } // next response line
4665+
4666+
if (!std::regex_match(line_reader.ptr(), m, re)) { return false; }
46574667
res.version = std::string(m[1]);
46584668
res.status = std::stoi(std::string(m[2]));
46594669
res.reason = std::string(m[3]);

0 commit comments

Comments
 (0)