Skip to content

Commit 69e75f4

Browse files
authored
Fix yhirose#635. HTTPS request stucked with proxy (yhirose#637)
1 parent b0fd4be commit 69e75f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

httplib.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ struct Request {
384384
struct Response {
385385
std::string version;
386386
int status = -1;
387+
std::string reason;
387388
Headers headers;
388389
std::string body;
389390

@@ -4621,12 +4622,13 @@ inline bool ClientImpl::read_response_line(Stream &strm, Response &res) {
46214622

46224623
if (!line_reader.getline()) { return false; }
46234624

4624-
const static std::regex re("(HTTP/1\\.[01]) (\\d+).*?\r\n");
4625+
const static std::regex re("(HTTP/1\\.[01]) (\\d+) (.*?)\r\n");
46254626

46264627
std::cmatch m;
46274628
if (std::regex_match(line_reader.ptr(), m, re)) {
46284629
res.version = std::string(m[1]);
46294630
res.status = std::stoi(std::string(m[2]));
4631+
res.reason = std::string(m[3]);
46304632
}
46314633

46324634
return true;
@@ -5035,7 +5037,7 @@ inline bool ClientImpl::process_request(Stream &strm, const Request &req,
50355037
}
50365038

50375039
if (res.get_header_value("Connection") == "close" ||
5038-
res.version == "HTTP/1.0") {
5040+
(res.version == "HTTP/1.0" && res.reason != "Connection established")) {
50395041
stop_core();
50405042
}
50415043

0 commit comments

Comments
 (0)