namespace http {
-void onPayload(std::shared_ptr<HTTPServerPublisher> &publisher, const uint8_t *buffer, std::size_t size) {
+void onPayload(std::shared_ptr<HTTPServerPublisher> &publisher, const uint8_t *buffer, std::size_t size, int request_id) {
char *string = (char *) buffer;
std::cout << "Received this content:" << std::endl;
void processResponse(std::string &name, HTTPResponse &&response) {
+ auto &payload = response.getPayload();
+
std::string filename = name.substr(1 + name.find_last_of("/"));
- std::cout << "Saving to: " << filename << " " << response.size() / 1024 << "kB" << std::endl;
+ std::cout << "Saving to: " << filename << " " << payload.size() / 1024 << "kB" << std::endl;
Time t3 = std::chrono::system_clock::now();;
std::ofstream file(filename.c_str(), std::ofstream::binary);
- file.write((char *) response.data(), response.size());
+ file.write((char *) payload.data(), payload.size());
file.close();
Time t2 = std::chrono::system_clock::now();;
TimeDuration dt = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1);
TimeDuration dt3 = std::chrono::duration_cast<std::chrono::milliseconds>(t3 - t1);
long msec = dt.count();
long msec3 = dt3.count();
- std::cout << "Elapsed Time: " << msec / 1000.0 << " seconds -- " << response.size() * 8 / msec / 1000.0
- << "[Mbps] -- " << response.size() * 8 / msec3 / 1000.0 << "[Mbps]" << std::endl;
+ std::cout << "Elapsed Time: " << msec / 1000.0 << " seconds -- " << payload.size() * 8 / msec / 1000.0
+ << "[Mbps] -- " << payload.size() * 8 / msec3 / 1000.0 << "[Mbps]" << std::endl;
}
http/icnet_http_client_connection.h
http/icnet_http_server_acceptor.h
http/icnet_http_server_publisher.h
+ http/icnet_http_message.h
http/icnet_http_request.h
+ http/icnet_http_response.h
http/icnet_http_facade.h)
set(HTTP_SOURCE_FILES
http/icnet_http_client_connection.cc
http/icnet_http_server_acceptor.cc
http/icnet_http_server_publisher.cc
- http/icnet_http_request.cc)
+ http/icnet_http_request.cc
+ http/icnet_http_response.cc)
set(UTILS_HEADER_FILES
utils/icnet_utils_array.h
utils/icnet_utils_uri.h
utils/icnet_utils_daemonizator.h
utils/icnet_utils_hash.h
- utils/icnet_utils_string_tokenizer.h)
+ utils/icnet_utils_string_tokenizer.h
+ utils/icnet_utils_sharable_vector.h)
set(UTILS_SOURCE_FILES
utils/icnet_utils_array.cc
#include "icnet_errors.h"
-namespace icnet {
-
namespace errors {
MalformedNameException::MalformedNameException()
return "Malformed IP address.";
}
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
#include <stdexcept>
-namespace icnet {
-
namespace errors {
class MalformedNameException : public std::runtime_error {
virtual char const *what() const noexcept override;
};
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
#include "icnet_errors_malformed_packet_exception.h"
-namespace icnet {
-
namespace errors {
MalformedPacketException::MalformedPacketException()
return "Malformed IP packet.";
}
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
#include <stdexcept>
-namespace icnet {
-
namespace errors {
class MalformedPacketException : public std::runtime_error {
virtual char const *what() const noexcept override;
};
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
#include "icnet_errors_not_implemented_exception.h"
-namespace icnet {
-
namespace errors {
NotImplementedException::NotImplementedException()
return "Function not yet implemented.";
}
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
#include <stdexcept>
-namespace icnet {
-
namespace errors {
class NotImplementedException : public std::logic_error {
virtual char const *what() const noexcept override;
};
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
#include "icnet_errors_runtime_exception.h"
-namespace icnet {
-
namespace errors {
RuntimeException::RuntimeException()
// return "Function not yet implemented.";
//}
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
#include <stdexcept>
#include <string>
-namespace icnet {
-
namespace errors {
class RuntimeException : public std::runtime_error {
: runtime_error(what) {};
};
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
#include "icnet_errors_tokenizer_exception.h"
-namespace icnet {
-
namespace errors {
TokenizerException::TokenizerException()
return "No more tokens available.";
}
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
#include <stdexcept>
-namespace icnet {
-
namespace errors {
class TokenizerException : public std::logic_error {
virtual char const *what() const noexcept override;
};
-} // end namespace errors
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace errors
\ No newline at end of file
using namespace transport;
HTTPClientConnection::HTTPClientConnection()
- : consumer_(Name("ccnx:"), transport::TransportProtocolAlgorithms::RAAQM) {
+ : consumer_(Name("ccnx:"), transport::TransportProtocolAlgorithms::RAAQM), timer_(nullptr),
+ response_(std::make_shared<HTTPResponse>()) {
consumer_.setSocketOption(ConsumerCallbacksOptions::CONTENT_OBJECT_TO_VERIFY,
(ConsumerContentObjectVerificationCallback) std::bind(&HTTPClientConnection::verifyData,
this,
std::placeholders::_1,
std::placeholders::_2));
+
+ std::shared_ptr<ccnx::Portal> portal;
+ consumer_.getSocketOption(GeneralTransportOptions::PORTAL, portal);
+ timer_.reset(new boost::asio::steady_timer(portal->getIoService()));
}
-HTTPClientConnection &HTTPClientConnection::get(std::string &url, HTTPHeaders headers, HTTPPayload payload) {
+HTTPClientConnection &HTTPClientConnection::get(const std::string &url,
+ HTTPHeaders headers,
+ HTTPPayload payload) {
HTTPRequest request(GET, url, headers, payload);
// Send content to producer piggybacking it through first interest (to fix)
- response_.clear();
+ response_->clear();
// Factor icn name
}
HTTPResponse &&HTTPClientConnection::response() {
- return std::move(response_);
+ return std::move(*response_);
}
void HTTPClientConnection::processPayload(transport::ConsumerSocket &c,
std::vector<uint8_t> &&payload) {
- response_ = std::move(payload);
+ *std::static_pointer_cast<std::vector<uint8_t>>(response_) = std::move(payload);
}
bool HTTPClientConnection::verifyData(transport::ConsumerSocket &c, const ContentObject &contentObject) {
void HTTPClientConnection::processLeavingInterest(transport::ConsumerSocket &c,
const Interest &interest,
std::string &payload) {
- if (interest.getName().get(-1).toSegment() == 0) {
+ // if (interest.getName().get(-1).toSegment() == 0) {
Interest &int2 = const_cast<Interest &>(interest);
int2.setPayload((const uint8_t *) payload.data(), payload.size());
- }
+ // }
}
HTTPClientConnection& HTTPClientConnection::stop() {
return consumer_;
}
+void HTTPClientConnection::setTimeout(const std::chrono::seconds &timeout) {
+ timer_->cancel();
+ timer_->expires_from_now(timeout);
+ timer_->async_wait([this](boost::system::error_code ec) {
+ if (!ec) {
+ consumer_.stop();
+ }
+ });
+}
+
}
}
#include "icnet_transport_socket_producer.h"
#include "icnet_utils_uri.h"
#include "icnet_http_request.h"
+#include "icnet_http_response.h"
#include "icnet_http_default_values.h"
#include <vector>
+#include <boost/asio/steady_timer.hpp>
#define HTTP_VERSION "1.0"
public:
HTTPClientConnection();
- HTTPClientConnection &get(std::string &url, HTTPHeaders headers = {}, HTTPPayload payload = {});
+ HTTPClientConnection &get(const std::string &url,
+ HTTPHeaders headers = {},
+ HTTPPayload payload = {});
HTTPResponse &&response();
transport::ConsumerSocket &getConsumer();
+ void setTimeout(const std::chrono::seconds &timeout);
+
private:
- void processPayload(transport::ConsumerSocket &c, std::vector<uint8_t> &&payload);
+ void processPayload(transport::ConsumerSocket &c, std::vector<uint8_t> &&response);
bool verifyData(transport::ConsumerSocket &c, const transport::ContentObject &contentObject);
void processLeavingInterest(transport::ConsumerSocket &c, const transport::Interest &interest, std::string &payload);
- HTTPResponse response_;
+ std::shared_ptr<HTTPResponse> response_;
transport::ConsumerSocket consumer_;
+ std::unique_ptr<boost::asio::steady_timer> timer_;
};
} // end namespace http
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include "icnet_utils_sharable_vector.h"
+
+#include <sstream>
+#include <vector>
+#include <map>
+
+#define HTTP_VERSION "1.0"
+
+namespace icnet {
+
+namespace http {
+
+typedef enum {
+ GET,
+ POST,
+ PUT,
+ PATCH,
+ DELETE
+} HTTPMethod;
+
+static std::map<HTTPMethod, std::string> method_map = {
+ {GET, "GET"}, {POST, "POST"}, {PUT, "PUT"}, {PATCH, "PATCH"}, {DELETE, "DELETE"},
+};
+
+typedef std::map<std::string, std::string> HTTPHeaders;
+typedef std::vector<uint8_t> HTTPPayload;
+
+class HTTPMessage {
+ public:
+
+ virtual ~HTTPMessage() = default;
+
+ virtual HTTPHeaders &getHeaders() = 0;
+
+ virtual HTTPPayload &getPayload() = 0;
+
+ virtual std::string &getHttpVersion() = 0;
+
+ protected:
+ HTTPHeaders headers_;
+ HTTPPayload payload_;
+ std::string http_version_;
+};
+
+} // end namespace http
+
+} // end namespace hicnet
\ No newline at end of file
namespace http {
-static std::map<HTTPMethod, std::string> method_map = {
- {GET, "GET"},
- {POST, "POST"},
- {PUT, "PUT"},
- {PATCH, "PATCH"},
- {DELETE, "DELETE"},
-};
-
-//std::map<HTTPMethod, std::string> method_map
-
-HTTPRequest::HTTPRequest(HTTPMethod method, std::string &url, HTTPHeaders &headers, HTTPPayload &payload) {
+HTTPRequest::HTTPRequest(HTTPMethod method,
+ const std::string &url,
+ const HTTPHeaders &headers,
+ const HTTPPayload &payload) {
utils::Uri uri;
uri.parse(url);
protocol_ = uri.getProtocol();
locator_ = uri.getLocator();
port_ = uri.getPort();
+ http_version_ = HTTP_VERSION;
headers_ = headers;
payload_ = payload;
return request_string_;
}
+std::string &HTTPRequest::getHttpVersion() {
+ return http_version_;
+}
+
}
}
\ No newline at end of file
#pragma once
+#include "icnet_utils_sharable_vector.h"
+#include "icnet_http_message.h"
+
#include <sstream>
#include <vector>
#include <map>
namespace http {
-typedef enum {
- GET,
- POST,
- PUT,
- PATCH,
- DELETE
-} HTTPMethod;
-
-typedef std::map<std::string, std::string> HTTPHeaders;
-typedef std::vector<uint8_t> HTTPPayload;
-typedef std::vector<uint8_t> HTTPResponse;
-
-class HTTPRequest {
+class HTTPRequest : public HTTPMessage {
public:
HTTPRequest(HTTPMethod method,
- std::string &url, HTTPHeaders &headers, HTTPPayload &payload);
+ const std::string &url, const HTTPHeaders &headers, const HTTPPayload &payload);
std::string &getQueryString();
std::string &getRequestString();
- HTTPHeaders &getHeaders();
+ HTTPHeaders &getHeaders() override;
+
+ HTTPPayload &getPayload() override;
- HTTPPayload &getPayload();
+ std::string &getHttpVersion() override;
private:
std::string query_string_, path_, protocol_, locator_, port_;
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "icnet_http_response.h"
+#include "icnet_errors.h"
+
+#include <algorithm>
+
+#include <cstring>
+
+namespace icnet {
+
+namespace http {
+
+HTTPResponse::HTTPResponse() {
+}
+
+HTTPResponse::HTTPResponse(const HTTPHeaders &headers, const HTTPPayload &payload) {
+ headers_ = headers;
+ payload_ = payload;
+}
+
+HTTPHeaders &HTTPResponse::getHeaders() {
+ parse();
+ return headers_;
+}
+
+HTTPPayload &HTTPResponse::getPayload() {
+ parse();
+ return payload_;
+}
+
+bool HTTPResponse::parseHeaders() {
+ const char *crlf2 = "\r\n\r\n";
+ auto it = std::search(this->begin(), this->end(), crlf2, crlf2 + strlen(crlf2));
+
+ if (it != end()) {
+ std::stringstream ss;
+ ss.str(std::string(begin(), it));
+
+ std::string line;
+ getline(ss, line);
+ std::istringstream line_s(line);
+ std::string _http_version;
+ std::string http_version;
+
+ line_s >> _http_version;
+ std::size_t separator;
+ if ((separator = _http_version.find('/')) != std::string::npos) {
+ if (_http_version.substr(0, separator) != "HTTP") {
+ return false;
+ }
+ http_version_ = line.substr(separator + 1, _http_version.length() - separator - 1);
+ } else {
+ return false;
+ }
+
+ std::string status_code, status_string;
+
+ line_s >> status_code_;
+ line_s >> status_string;
+
+ auto _it = std::search(line.begin(), line.end(), status_string.begin(), status_string.end());
+
+ status_string_ = std::string(_it, line.end() - 1);
+
+ std::size_t param_end;
+ std::size_t value_start;
+ while (getline(ss, line)) {
+ if ((param_end = line.find(':')) != std::string::npos) {
+ value_start = param_end + 1;
+ if ((value_start) < line.size()) {
+ if (line[value_start] == ' ') {
+ value_start++;
+ }
+ if (value_start < line.size()) {
+ headers_[line.substr(0, param_end)] = line.substr(value_start, line.size() - value_start - 1);
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+void HTTPResponse::parse() {
+ if (!parseHeaders()) {
+ throw errors::RuntimeException("Malformed HTTP response");
+ }
+
+ if (payload_.empty()) {
+ const char *crlf2 = "\r\n\r\n";
+ auto it = std::search(this->begin(), this->end(), crlf2, crlf2 + strlen(crlf2));
+
+ if (it != this->end()) {
+ erase(begin(), it + strlen(crlf2));
+ payload_ = std::move(*dynamic_cast<std::vector<uint8_t> *>(this));
+ }
+ }
+}
+
+std::string &HTTPResponse::getStatusCode() {
+ return status_code_;
+}
+
+std::string &HTTPResponse::getStatusString() {
+ return status_string_;
+}
+
+std::string &HTTPResponse::getHttpVersion() {
+ return http_version_;
+}
+
+}
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include "icnet_utils_sharable_vector.h"
+#include "icnet_http_message.h"
+#include "icnet_utils_array.h"
+
+#include <sstream>
+#include <vector>
+#include <map>
+
+namespace icnet {
+
+namespace http {
+
+class HTTPResponse : public HTTPMessage, public utils::SharableVector<uint8_t> {
+ public:
+
+ HTTPResponse(const HTTPHeaders &headers, const HTTPPayload &payload);
+
+ HTTPResponse();
+
+ HTTPHeaders &getHeaders() override;
+
+ HTTPPayload &getPayload() override;
+
+ std::string &getStatusCode();
+
+ std::string &getStatusString();
+
+ std::string &getHttpVersion() override;
+
+ void parse();
+
+ private:
+ bool parseHeaders();
+
+ private:
+ std::string status_code_;
+ std::string status_string_;
+};
+
+} // end namespace http
+
+} // end namespace hicnet
\ No newline at end of file
if (method == "GET") {
HTTPRequest request(GET, url, headers, payload);
- auto publisher = std::make_shared<HTTPServerPublisher>(request_name);
- callback_(publisher, (uint8_t *) request.getRequestString().data(), request.getRequestString().size());
+
+ int request_id = utils::Hash::hash32(request.getRequestString().data(), request.getRequestString().size());
+
+ if (publishers_.find(request_id) != publishers_.end()) {
+ if (publishers_[request_id]) {
+ publishers_[request_id]->getProducer().onInterest(interest.getName(), interest);
+ return;
+ }
+ } else {
+ std::cout << "Request ID" << request_id << std::endl;
+ }
+
+ publishers_[request_id] = std::make_shared<HTTPServerPublisher>(request_name);
+ callback_(publishers_[request_id],
+ (uint8_t *) request.getRequestString().data(),
+ request.getRequestString().size(),
+ request_id);
}
}
-//void HTTPServerConnection::sendResponse() {
-//
-// std::thread t([]() {
-//
-// // Get the name of the HTTP method to compute
-// std::string method = request_name.get(1).toString();
-// std::transform(method.begin(), method.end(), method.begin(), ::toupper);
-// std::string path;
-//
-// // This is done for getting rid of useless name components such as ccnx: or ndn:
-// if (request_name.getSegmentCount() > 2) {
-// std::string rawPath = request_name.getSubName(2).toString();
-// std::size_t pos = rawPath.find("/");
-// path = rawPath.substr(pos);
-// }
-//
-// // Create new producer
-//
-// // Create timer for response availability
-// std::shared_ptr<core::Portal> portal;
-// po->getSocketOption(icnet::GeneralTransportOptions::PORTAL, portal);
-// boost::asio::io_service &ioService = portal->getIoService();
-//
-// boost::asio::deadline_timer t(ioService, boost::posix_time::seconds(5));
-//
-// std::function<void(const boost::system::error_code e)>
-// wait_callback = [&ioService](const boost::system::error_code e) {
-// if (!e) {
-// // Be sure to delete the timer before the io_service, otherwise we'll get some strange behavior!
-// ioService.stop();
-// }
-// };
-//
-// std::function<void(transport::ProducerSocket, const core::Interest &interest)>
-// interest_enter_callback = [this, &wait_callback, &t]
-// (transport::ProducerSocket &p, const core::Interest &interest) {
-// t.cancel();
-// t.expires_from_now(boost::posix_time::seconds(5));
-// t.async_wait(wait_callback);
-// };
-//
-// p->setSocketOption(transport::ProducerCallbacksOptions::INTEREST_INPUT,
-// (transport::ProducerInterestCallback) interest_enter_callback);
-//
-// t.async_wait(wait_callback);
-//
-// p->serveForever();
-//
-// std::unique_lock<std::mutex> lock(thread_list_mtx_);
-// icn_producers_.erase(request_name);
-// });
-//
-// t.detach();
-//}
+std::map<int, std::shared_ptr<HTTPServerPublisher>>& HTTPServerAcceptor::getPublishers() {
+ return publishers_;
+}
}
//typedef std::vector<uint8_t> HTTPResponse;
typedef std::vector<uint8_t> HttpRequest;
-typedef std::function<void(std::shared_ptr<HTTPServerPublisher> &, const uint8_t *, std::size_t)> OnHttpRequest;
+typedef std::function<void(std::shared_ptr<HTTPServerPublisher> &, const uint8_t *, std::size_t, int request_id)> OnHttpRequest;
class HTTPServerAcceptor {
public:
HttpRequest &&request();
-// void asyncSendResponse();
-
-// HTTPClientConnection& get(std::string &url, HTTPHeaders headers = {}, HTTPPayload payload = {});
-//
-// HTTPResponse&& response();
+ std::map<int, std::shared_ptr<HTTPServerPublisher>>& getPublishers();
private:
OnHttpRequest callback_;
HttpRequest request_;
std::shared_ptr<transport::ProducerSocket> acceptor_producer_;
+
+ std::map<int, std::shared_ptr<HTTPServerPublisher>> publishers_;
};
} // end namespace http
return *this;
}
-HTTPServerPublisher &HTTPServerPublisher::setTimeout(uint32_t timeout) {
+transport::ProducerSocket& HTTPServerPublisher::getProducer() {
+ return *producer_;
+}
+
+HTTPServerPublisher &HTTPServerPublisher::setTimeout(const std::chrono::milliseconds &timeout, bool timeout_renewal) {
std::shared_ptr<transport::Portal> portal;
producer_->getSocketOption(transport::GeneralTransportOptions::PORTAL, portal);
- timer_ = std::unique_ptr<boost::asio::deadline_timer>(new boost::asio::deadline_timer(portal->getIoService(), boost::posix_time::seconds(timeout)));
+ timer_ = std::unique_ptr<boost::asio::steady_timer>(new boost::asio::steady_timer(portal->getIoService(), timeout));
wait_callback_ = [this](const boost::system::error_code e) {
if (!e) {
}
};
- interest_enter_callback_ = [this, timeout](transport::ProducerSocket &p, const transport::Interest &interest) {
- this->timer_->cancel();
- this->timer_->expires_from_now(boost::posix_time::seconds(timeout));
- this->timer_->async_wait(wait_callback_);
- };
+ if (timeout_renewal) {
+ interest_enter_callback_ = [this, timeout](transport::ProducerSocket &p, const transport::Interest &interest) {
+ this->timer_->cancel();
+ this->timer_->expires_from_now(timeout);
+ this->timer_->async_wait(wait_callback_);
+ };
- producer_->setSocketOption(transport::ProducerCallbacksOptions::INTEREST_INPUT,
- (transport::ProducerInterestCallback) interest_enter_callback_);
+ producer_->setSocketOption(transport::ProducerCallbacksOptions::INTEREST_INPUT,
+ (transport::ProducerInterestCallback) interest_enter_callback_);
+ }
timer_->async_wait(wait_callback_);
#include "icnet_http_default_values.h"
#include <vector>
+#include <boost/asio/steady_timer.hpp>
#include <functional>
#ifdef __ANDROID__
void stop();
- HTTPServerPublisher &setTimeout(uint32_t timeout);
+ HTTPServerPublisher &setTimeout(const std::chrono::milliseconds &timeout, bool timeout_renewal);
HTTPServerPublisher &attachPublisher();
+ transport::ProducerSocket& getProducer();
+
private:
void processIncomingInterest(transport::ProducerSocket &p, const transport::Interest &interest);
transport::Name content_name_;
- std::unique_ptr<boost::asio::deadline_timer> timer_;
+ std::unique_ptr<boost::asio::steady_timer> timer_;
std::unique_ptr<transport::ProducerSocket> producer_;
transport::ProducerInterestCallback interest_enter_callback_;
DeadlineTimerCallback wait_callback_;
#include "icnet_utils_array.h"
-namespace icnet {
-
namespace utils {
Array::Array(const void *array, size_t size) {
return *this;
}
-}
-
}
\ No newline at end of file
#include <cstddef>
-namespace icnet {
-
namespace utils {
class Array {
};
}
-
-}
#include <iostream>
#include <sys/stat.h>
-namespace icnet {
-
namespace utils {
void Daemonizator::daemonize() {
}
}
-
-}
#pragma once
-namespace icnet {
-
namespace utils {
class Daemonizator {
static void daemonize();
};
-}
-
}
\ No newline at end of file
#include "icnet_utils_hash.h"
-namespace icnet {
-
namespace utils {
uint32_t Hash::hash32(const void *data, std::size_t len) {
return hash;
}
-}
-
}
\ No newline at end of file
#include <cstdint>
#include <cstddef>
-namespace icnet {
-
namespace utils {
//const uint32_t FNV1A_PRIME_32 = 0x01000193;
};
-}
-
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <vector>
+#include <memory>
+
+namespace utils {
+
+template<class T>
+class SharableVector : public std::vector<T>, public std::enable_shared_from_this<SharableVector<T>> {
+ public:
+ virtual ~SharableVector() {};
+};
+
+}
#include "icnet_utils_string_tokenizer.h"
#include "icnet_errors.h"
-namespace icnet {
-
namespace utils {
StringTokenizer::StringTokenizer(const std::string &str)
return token;
}
-}
}
\ No newline at end of file
#include <string>
-namespace icnet {
-
namespace utils {
class StringTokenizer {
};
}
-
-}
#include "icnet_utils_uri.h"
#include "icnet_errors_runtime_exception.h"
-namespace icnet {
-
namespace utils {
Uri::Uri() {
return query_string_;
}
-} // end namespace utils
-
-} // end namespace icnet
\ No newline at end of file
+} // end namespace utils
\ No newline at end of file
#include <string>
#include <algorithm> // find
-namespace icnet {
-
namespace utils {
class Uri {
std::string query_string_, path_, protocol_, locator_, port_;
}; // uri
-}
-
}
\ No newline at end of file