diff --git a/httplib.h b/httplib.h index c21b25e..8caa93c 100644 --- a/httplib.h +++ b/httplib.h @@ -5257,7 +5257,7 @@ inline bool ClientImpl::read_response_line(Stream &strm, const Request &req, if (!line_reader.getline()) { return false; } - const static std::regex re("(HTTP/1\\.[01]) (\\d{3}) (.*?)\r\n"); + const static std::regex re("(HTTP/1\\.[01]) (\\d{3})(?: (.*?))?\r\n"); std::cmatch m; if (!std::regex_match(line_reader.ptr(), m, re)) { diff --git a/test/test.cc b/test/test.cc index 0cafe92..fe35d75 100644 --- a/test/test.cc +++ b/test/test.cc @@ -1644,6 +1644,7 @@ TEST_F(ServerTest, GetMethod200) { ASSERT_TRUE(res); EXPECT_EQ("HTTP/1.1", res->version); EXPECT_EQ(200, res->status); + EXPECT_EQ("OK", res->reason); EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); EXPECT_EQ(1, res->get_header_value_count("Content-Type")); EXPECT_EQ("Hello World!", res->body);