aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMauro Sardara <msardara+fdio@cisco.com>2018-02-16 17:22:53 +0100
committerMauro Sardara <msardara+fdio@cisco.com>2018-02-16 17:22:53 +0100
commit953f18b834951680c738e9ce367b5a3eff91ccda (patch)
tree52bc181e53b9c76db1e14e693f473ca8cfca7250 /apps
parentc5e952d1cadbdf85c976e88ba97ea8bee7e422ab (diff)
Improvements for HTTP messages processing
Change-Id: Iefcbfa1820bd47fd52475780c68c363a2baa2568 Signed-off-by: Mauro Sardara <msardara+fdio@cisco.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/http/icnet_http_echo_server.cc2
-rw-r--r--apps/http/icnet_iget.cc10
2 files changed, 7 insertions, 5 deletions
diff --git a/apps/http/icnet_http_echo_server.cc b/apps/http/icnet_http_echo_server.cc
index 223646a2..961c44fd 100644
--- a/apps/http/icnet_http_echo_server.cc
+++ b/apps/http/icnet_http_echo_server.cc
@@ -19,7 +19,7 @@ namespace icnet {
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;
diff --git a/apps/http/icnet_iget.cc b/apps/http/icnet_iget.cc
index d322cc35..4a507864 100644
--- a/apps/http/icnet_iget.cc
+++ b/apps/http/icnet_iget.cc
@@ -29,19 +29,21 @@ namespace http {
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;
}