Browse Source

Merge pull request #132 from archivaldo/fronting

small fix to allow fronting
yhirose 6 years ago
parent
commit
a86f6dfa76
1 changed files with 13 additions and 11 deletions
  1. 13 11
      httplib.h

+ 13 - 11
httplib.h

@@ -2066,17 +2066,19 @@ 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());
+			}
         }
     }