From dedcc43216080ea20b4b6566a23d1636de3eb5d4 Mon Sep 17 00:00:00 2001 From: archivaldo Date: Thu, 7 Mar 2019 16:40:19 -0300 Subject: [PATCH 1/2] small fix to allow fronting --- httplib.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/httplib.h b/httplib.h index 250d4ca..0e88d8b 100644 --- a/httplib.h +++ b/httplib.h @@ -2066,19 +2066,22 @@ inline void Client::write_request(Stream& strm, Request& req) path.c_str()); // Headers - if (is_ssl()) { - if (port_ == 443) { - req.set_header("Host", host_.c_str()); - } else { - req.set_header("Host", host_and_port_.c_str()); - } - } else { - if (port_ == 80) { - req.set_header("Host", host_.c_str()); - } else { - req.set_header("Host", host_and_port_.c_str()); - } - } + if (!req.has_header("Host")) + { + if (is_ssl()) { + if (port_ == 443) { + req.set_header("Host", host_.c_str()); + } else { + req.set_header("Host", host_and_port_.c_str()); + } + } else { + if (port_ == 80) { + req.set_header("Host", host_.c_str()); + } else { + req.set_header("Host", host_and_port_.c_str()); + } + } + } if (!req.has_header("Accept")) { req.set_header("Accept", "*/*"); From c5264cea9caea7e7fb0b2e300a1157ae8821f1c8 Mon Sep 17 00:00:00 2001 From: archivaldo Date: Thu, 7 Mar 2019 19:03:18 -0300 Subject: [PATCH 2/2] Fix coding style --- httplib.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/httplib.h b/httplib.h index 0e88d8b..9669902 100644 --- a/httplib.h +++ b/httplib.h @@ -2066,12 +2066,11 @@ inline void Client::write_request(Stream& strm, Request& req) path.c_str()); // Headers - if (!req.has_header("Host")) - { - if (is_ssl()) { - if (port_ == 443) { + if (!req.has_header("Host")) { + if (is_ssl()) { + if (port_ == 443) { req.set_header("Host", host_.c_str()); - } else { + } else { req.set_header("Host", host_and_port_.c_str()); } } else { @@ -2080,8 +2079,8 @@ inline void Client::write_request(Stream& strm, Request& req) } else { req.set_header("Host", host_and_port_.c_str()); } - } - } + } + } if (!req.has_header("Accept")) { req.set_header("Accept", "*/*");