X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=httpinput.cpp;h=78e73a10eb9afeb5724ebbaa4efa6b0d9cb36f57;hp=5fb55b378610e846f2d74f6074f82f1f95ee58b7;hb=c1bfe37ff48881cfd44d4bf2952e9f9a1cdabb12;hpb=6544fa0ec3f3a501bcb89ea977756911bd7f3ebd diff --git a/httpinput.cpp b/httpinput.cpp index 5fb55b3..78e73a1 100644 --- a/httpinput.cpp +++ b/httpinput.cpp @@ -30,6 +30,19 @@ using namespace std; +namespace { + +string host_header(const string &host, const string &port) +{ + if (port == "http" || 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; } @@ -482,7 +495,6 @@ void HTTPInput::do_work() void HTTPInput::process_data(char *ptr, size_t bytes) { - pending_data.insert(pending_data.end(), ptr, ptr + bytes); { MutexLock mutex(&stats_mutex); stats.bytes_received += bytes; @@ -490,12 +502,13 @@ void HTTPInput::process_data(char *ptr, size_t bytes) if (encoding == Input::INPUT_ENCODING_RAW) { for (size_t i = 0; i < stream_indices.size(); ++i) { - servers->add_data(stream_indices[i], ptr, bytes, SUITABLE_FOR_STREAM_START); + servers->add_data(stream_indices[i], ptr, bytes, /*metacube_flags=*/0); } return; } assert(encoding == Input::INPUT_ENCODING_METACUBE); + pending_data.insert(pending_data.end(), ptr, ptr + bytes); for ( ;; ) { // If we don't have enough data (yet) for even the Metacube header, just return. @@ -568,16 +581,9 @@ void HTTPInput::process_data(char *ptr, size_t bytes) for (size_t i = 0; i < stream_indices.size(); ++i) { servers->set_header(stream_indices[i], http_header, stream_header); } - } else { - StreamStartSuitability suitable_for_stream_start; - if (flags & METACUBE_FLAGS_NOT_SUITABLE_FOR_STREAM_START) { - suitable_for_stream_start = NOT_SUITABLE_FOR_STREAM_START; - } else { - suitable_for_stream_start = SUITABLE_FOR_STREAM_START; - } - for (size_t i = 0; i < stream_indices.size(); ++i) { - servers->add_data(stream_indices[i], inner_data, size, suitable_for_stream_start); - } + } + for (size_t i = 0; i < stream_indices.size(); ++i) { + servers->add_data(stream_indices[i], inner_data, size, flags); } // Consume the block. This isn't the most efficient way of dealing with things