Browse Source

small fix to allow fronting

archivaldo 6 years ago
parent
commit
dedcc43216
1 changed files with 16 additions and 13 deletions
  1. 16 13
      httplib.h

+ 16 - 13
httplib.h

@@ -2066,19 +2066,22 @@ inline void Client::write_request(Stream& strm, Request& req)
         path.c_str());
         path.c_str());
 
 
     // Headers
     // 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")) {
     if (!req.has_header("Accept")) {
         req.set_header("Accept", "*/*");
         req.set_header("Accept", "*/*");