From 4bd049e639d80028ccdc909c0fef2de4e810cf50 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Fri, 28 Jul 2017 19:37:14 +0200 Subject: Adding possibility to set lifetime when publishing content using the http helper. Change-Id: I0107bb216e961c189a62f5c6bb3b22fc563919a7 Signed-off-by: Mauro Sardara --- apps/http/icnet_http_echo_server.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apps/http/icnet_http_echo_server.cc') diff --git a/apps/http/icnet_http_echo_server.cc b/apps/http/icnet_http_echo_server.cc index 17bdb693..223646a2 100644 --- a/apps/http/icnet_http_echo_server.cc +++ b/apps/http/icnet_http_echo_server.cc @@ -26,11 +26,17 @@ void onPayload(std::shared_ptr &publisher, const uint8_t *b std::cout << string << std::endl; std::stringstream response; - response << "HTTP/1.0 200 OK\r\n" << "Content-Length: " << size << "\r\n\r\n" << string; + response << "HTTP/1.1 200 OK\r\n" << "Content-Length: " << size << "\r\n\r\n" << string; std::string response_string = response.str(); + std::chrono::milliseconds expiry_time(std::chrono::milliseconds(4000 * 1000)); + std::thread t([publisher, response_string]() { - publisher->publishContent((uint8_t *) response_string.data(), response_string.size(), 0, true); + publisher->publishContent((uint8_t *) response_string.data(), + response_string.size(), + std::chrono::milliseconds(transport::default_values::content_object_expiry_time), + 0, + true); publisher->serveClients(); }); -- cgit 1.2.3-korg