projects
/
cubemap
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make the HTTP client send the right Host: header.
[cubemap]
/
httpinput.cpp
diff --git
a/httpinput.cpp
b/httpinput.cpp
index
5a93969
..
9412e78
100644
(file)
--- a/
httpinput.cpp
+++ b/
httpinput.cpp
@@
-30,6
+30,19
@@
using namespace std;
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)
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;
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\n
Host: " + host_header(host, port) + "\r\n
User-Agent: cubemap\r\n\r\n";
request_bytes_sent = 0;
}
request_bytes_sent = 0;
}