From: Steinar H. Gunderson Date: Thu, 18 Apr 2013 19:28:10 +0000 (+0200) Subject: Fix an issue where new UDP streams would be without HTTP headers. X-Git-Tag: 1.0.0~77 X-Git-Url: https://git.sesse.net/?p=cubemap;a=commitdiff_plain;h=3b8ad87137cff7522ed12f4675d5ff26933bc94a Fix an issue where new UDP streams would be without HTTP headers. --- diff --git a/udpinput.cpp b/udpinput.cpp index ae4f288..8659141 100644 --- a/udpinput.cpp +++ b/udpinput.cpp @@ -66,14 +66,17 @@ void UDPInput::close_socket() void UDPInput::construct_header() { - string header = + http_header = "HTTP/1.0 200 OK\r\n" "Content-type: application/octet-stream\r\n" "Cache-control: no-cache\r\n" "Server: " SERVER_IDENTIFICATION "\r\n"; - for (size_t i = 0; i < stream_ids.size(); ++i) { - servers->set_header(stream_ids[i], header, ""); - } +} + +void UDPInput::add_destination(const string &stream_id) +{ + stream_ids.push_back(stream_id); + servers->set_header(stream_id, http_header, ""); } void UDPInput::do_work() diff --git a/udpinput.h b/udpinput.h index dc91bc2..481b006 100644 --- a/udpinput.h +++ b/udpinput.h @@ -19,10 +19,7 @@ public: virtual std::string get_url() const { return url; } virtual void close_socket(); - virtual void add_destination(const std::string &stream_id) - { - stream_ids.push_back(stream_id); - } + virtual void add_destination(const std::string &stream_id); private: // Actually gets the packets. @@ -37,6 +34,9 @@ private: std::string url; std::string host, port, path; + // The HTTP header we're sending to clients. + std::string http_header; + // The socket we are receiving on (or -1). int sock; };