Explorar el Código

修复Host字段带端口问题

NH hace 1 año
padre
commit
632f977c5f
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  1. 4 1
      src/net/http_client_plus.cpp

+ 4 - 1
src/net/http_client_plus.cpp

@@ -584,7 +584,10 @@ bool ylib::network::http::client_plus::request()
 		}
 		if (m_headers_request.exist("Host") == false)
 		{
-			m_headers_request.set("Host", m_ipaddress+(m_port==80?"":(":"+std::to_string(m_port))));
+			std::string header_host = m_ipaddress;
+			if (m_port != 80 && m_port != 443)
+				header_host += (":" + std::to_string(m_port));
+			m_headers_request.set("Host", header_host);
 		}
 			
 	}