aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2020-02-18 17:34:12 +0000
committerGerrit Code Review <gerrit@fd.io>2020-02-18 17:34:12 +0000
commit94cccc7a047c871103785b295d4e5c4df58f4f74 (patch)
tree2b74210a0086b44b92992e66041a1ed3b71f6f25
parent41b77dd35b3ffd5363a350b3fc3d548298dbcc98 (diff)
parent0f41a0646ab2083b7ed64c61ac5175f325e7ad3e (diff)
Merge "[HICN-529] Fix viper API to work with hicn and cicn." into viper/master
-rw-r--r--Input/ICNConnectionConsumerApi.cpp22
-rw-r--r--Input/ICNConnectionConsumerApi.h6
2 files changed, 22 insertions, 6 deletions
diff --git a/Input/ICNConnectionConsumerApi.cpp b/Input/ICNConnectionConsumerApi.cpp
index 362c849c..9068c86d 100644
--- a/Input/ICNConnectionConsumerApi.cpp
+++ b/Input/ICNConnectionConsumerApi.cpp
@@ -148,24 +148,36 @@ int ICNConnectionConsumerApi::Read(uint8_t *data, size_t len)
{"Connection", "Keep-Alive"}};
std::string s(m_name.c_str());
hTTPClientConnection->get(s, headers, {}, nullptr, nullptr, this->v6FirstWord);
+#ifdef HICNET
+ response = hTTPClientConnection->response()->getPayload();
+#else
response = hTTPClientConnection->response();
+#endif
this->res = true;
this->dataPos = 0;
}
- if (response.getPayload().size() - this->dataPos > (int)len)
+#ifdef HICNET
+ char * bytes = (char*)response->writableData();
+ std::size_t size = response->length();
+#else
+ char *bytes = response.getPayload().data();
+ std::size_t size = response.getPayload().size();
+#endif
+
+ if (size - this->dataPos > (int)len)
{
- memcpy(data, (char*)response.getPayload().data() + this->dataPos, len);
+ memcpy(data, bytes + this->dataPos, len);
this->dataPos += len;
return len;
} else
{
- memcpy(data, (char*)response.getPayload().data() + this->dataPos, response.getPayload().size() - this->dataPos);
- int length = response.getPayload().size() - this->dataPos;
+ memcpy(data, bytes + this->dataPos, size - this->dataPos);
+ int length = size - this->dataPos;
if (length == 0)
{
this->res = false;
}
- this->dataPos = response.getPayload().size();
+ this->dataPos = size;
return length;
}
}
diff --git a/Input/ICNConnectionConsumerApi.h b/Input/ICNConnectionConsumerApi.h
index c4e89926..539e2e0f 100644
--- a/Input/ICNConnectionConsumerApi.h
+++ b/Input/ICNConnectionConsumerApi.h
@@ -96,7 +96,11 @@ public:
private:
libl4::http::HTTPClientConnection *hTTPClientConnection;
- libl4::http::HTTPResponse response;
+#ifdef HICNET
+ libl4::http::HTTPPayload response;
+#else
+ std::shared_ptr<libl4::http::HTTPResponse> response;
+#endif
float beta;
float drop;
std::string v6FirstWord;