diff options
author | Mauro Sardara <msardara+fdio@cisco.com> | 2017-07-28 19:37:14 +0200 |
---|---|---|
committer | Mauro Sardara <msardara+fdio@cisco.com> | 2017-07-28 19:37:14 +0200 |
commit | 4bd049e639d80028ccdc909c0fef2de4e810cf50 (patch) | |
tree | 3d134c5061dabd2a0207a78a68d6bd2677e0253c /icnet/http | |
parent | 12b835ddd5a431ef1bcd1bd2c89e8f92256ec435 (diff) |
Adding possibility to set lifetime when publishing content using the http helper.
Change-Id: I0107bb216e961c189a62f5c6bb3b22fc563919a7
Signed-off-by: Mauro Sardara <msardara+fdio@cisco.com>
Diffstat (limited to 'icnet/http')
-rw-r--r-- | icnet/http/icnet_http_server_publisher.cc | 4 | ||||
-rw-r--r-- | icnet/http/icnet_http_server_publisher.h | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/icnet/http/icnet_http_server_publisher.cc b/icnet/http/icnet_http_server_publisher.cc index 92b41e6c..e42154b2 100644 --- a/icnet/http/icnet_http_server_publisher.cc +++ b/icnet/http/icnet_http_server_publisher.cc @@ -63,13 +63,15 @@ HTTPServerPublisher &HTTPServerPublisher::setTimeout(uint32_t timeout) { return *this; } -void HTTPServerPublisher::publishContent(const uint8_t *buf, size_t buffer_size, const int response_id, bool is_last) { +void HTTPServerPublisher::publishContent(const uint8_t *buf, size_t buffer_size, std::chrono::milliseconds content_lifetime, const int response_id, bool is_last) { if (producer_) { #ifdef __ANDROID__ __android_log_print(ANDROID_LOG_DEBUG, "HTTP_SERVER_PUBLISHER", "Replying to %s", const_cast<transport::Name &>(content_name_).toString().c_str()); #else std::cout << "Replying to " << content_name_ << std::endl; #endif + producer_->setSocketOption(transport::GeneralTransportOptions::CONTENT_OBJECT_EXPIRY_TIME, static_cast<int>(content_lifetime.count())); + producer_->produce(content_name_, buf, buffer_size, response_id, is_last); } } diff --git a/icnet/http/icnet_http_server_publisher.h b/icnet/http/icnet_http_server_publisher.h index a1c1c91a..7162f4d1 100644 --- a/icnet/http/icnet_http_server_publisher.h +++ b/icnet/http/icnet_http_server_publisher.h @@ -43,6 +43,7 @@ class HTTPServerPublisher { void publishContent(const uint8_t *buf, size_t buffer_size, + std::chrono::milliseconds content_lifetime, const int response_id, bool is_last); |