]> git.sesse.net Git - cubemap/blobdiff - httpinput.cpp
Make the HTTP client send the right Host: header.
[cubemap] / httpinput.cpp
index 5a93969ff4801c425ca9dc418cc030147e12c808..9412e785b6b15fa41f889a6a6e6acc8fbde8dd86 100644 (file)
 
 using namespace std;
 
+namespace {
+
+string host_header(const string &host, const string &port)
+{
+       if (atoi(port.c_str()) == 80) {
+               return host;
+       } else {
+               return host + ":" + port;
+       }
+}
+
+}  // namespace
+
 extern ServerPool *servers;
 
 HTTPInput::HTTPInput(const string &url, Input::Encoding encoding)
@@ -339,7 +352,7 @@ void HTTPInput::do_work()
                                        state = CLOSING_SOCKET;
                                } else {
                                        state = SENDING_REQUEST;
-                                       request = "GET " + path + " HTTP/1.0\r\nUser-Agent: cubemap\r\n\r\n";
+                                       request = "GET " + path + " HTTP/1.0\r\nHost: " + host_header(host, port) + "\r\nUser-Agent: cubemap\r\n\r\n";
                                        request_bytes_sent = 0;
                                }