diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-06-14 23:15:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-14 23:15:38 +0200 |
commit | 108d8bcfc00ec123e020a78474c0bfb544ea8a5a (patch) | |
tree | d80b693a966455c10199ad54d4883dbf8a5239f4 | |
parent | 19017a760cbddee9bf0b40824ae9fbf5ca6d9042 (diff) | |
parent | 5cabe5f0fcdf10eb025f24adfbf7f6864465f8f0 (diff) |
Merge pull request #9157 from capnm/fix-https-request
Don't append standard ports to the request header.
-rw-r--r-- | core/io/http_client.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 899f3b3b2d..0c84a5213f 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -96,7 +96,12 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector }; String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1\r\n"; - request += "Host: " + conn_host + ":" + itos(conn_port) + "\r\n"; + if ((ssl && conn_port == 443) || (!ssl && conn_port == 80)) { + // don't append the standard ports + request += "Host: " + conn_host + "\r\n"; + } else { + request += "Host: " + conn_host + ":" + itos(conn_port) + "\r\n"; + } bool add_clen = p_body.size() > 0; for (int i = 0; i < p_headers.size(); i++) { request += p_headers[i] + "\r\n"; @@ -151,7 +156,12 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str }; String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1\r\n"; - request += "Host: " + conn_host + ":" + itos(conn_port) + "\r\n"; + if ((ssl && conn_port == 443) || (!ssl && conn_port == 80)) { + // don't append the standard ports + request += "Host: " + conn_host + "\r\n"; + } else { + request += "Host: " + conn_host + ":" + itos(conn_port) + "\r\n"; + } bool add_clen = p_body.length() > 0; for (int i = 0; i < p_headers.size(); i++) { request += p_headers[i] + "\r\n"; |