From cbc04c22d00db043716fc695d40937252ebbf9ee Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Tue, 8 Aug 2017 20:12:39 +0200 Subject: - Send proxied response sequentially - Set mpd lifetime to 1 second - Change default lifetime for a generic content Change-Id: I43fd9e61d5cba059e32f67665d0ac22ce04682de Signed-off-by: Mauro Sardara --- CMakeLists.txt | 2 +- http-client/http_client.cc | 7 +++++-- http-server/response.cc | 2 +- main.cc | 4 ++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14e7db16..8b51e1b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ endif() configure_file("${PROJECT_SOURCE_DIR}/config.h.in" "${CMAKE_BINARY_DIR}/config.h") -include_directories(${LIB${TRANSPORT_LIBRARY}_INCLUDE_DIRS}) +include_directories(${LIB${TRANSPORT_LIBRARY}_INCLUDE_DIRS} http-server http-client) find_package(Threads REQUIRED) diff --git a/http-client/http_client.cc b/http-client/http_client.cc index 221e7bbe..a2e9800b 100644 --- a/http-client/http_client.cc +++ b/http-client/http_client.cc @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "response.h" #include "http_client.h" #include @@ -20,9 +21,11 @@ #include using namespace std; +using namespace icn_httpserver; size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) { - ((ostream*) stream)->write((const char*)ptr, size * nmemb); + ((Response*) stream)->write((const char*)ptr, size * nmemb); + ((Response*) stream)->send(); return size * nmemb; } @@ -56,4 +59,4 @@ bool HTTPClient::download(const std::string& url, std::ostream& out) { } return true; -} \ No newline at end of file +} diff --git a/http-server/response.cc b/http-server/response.cc index 779ecedc..ca8dfea2 100644 --- a/http-server/response.cc +++ b/http-server/response.cc @@ -16,7 +16,7 @@ #include "common.h" #include "response.h" -#define DEFAULT_LIFETIME 1024 * 1024 +#define DEFAULT_LIFETIME 1000 * 1000 namespace icn_httpserver { diff --git a/main.cc b/main.cc index c222db20..56e8fedc 100644 --- a/main.cc +++ b/main.cc @@ -157,6 +157,10 @@ int main(int argc, char **argv) { path = boost::filesystem::canonical(path); + if (path.extension().string() == ".mpd") { + response->setResponseLifetime(std::chrono::milliseconds(1000)); + } + //Check if path is within web_root_path if (distance(web_root_path.begin(), web_root_path.end()) <= distance(path.begin(), path.end()) && equal(web_root_path.begin(), web_root_path.end(), path.begin())) { -- cgit 1.2.3-korg