diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-05-24 18:09:43 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2019-05-24 18:09:43 +0000 |
commit | cb549cad953a0578f6908382a90e4eb01b2b26a6 (patch) | |
tree | a4754b49f1a7020f65be645f86b917fcd0811db3 /libtransport/src | |
parent | 052cc4a393236f0433c61cc1d10c6d90f0194321 (diff) | |
parent | 2f57713f83d686cca0419f294e0bc421dda693e1 (diff) |
Merge "[HICN-206] Customize first part of the name for HTTP."
Diffstat (limited to 'libtransport/src')
-rw-r--r-- | libtransport/src/hicn/transport/http/client_connection.cc | 16 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/http/client_connection.h | 9 |
2 files changed, 15 insertions, 10 deletions
diff --git a/libtransport/src/hicn/transport/http/client_connection.cc b/libtransport/src/hicn/transport/http/client_connection.cc index fadf0ae44..32269d49d 100644 --- a/libtransport/src/hicn/transport/http/client_connection.cc +++ b/libtransport/src/hicn/transport/http/client_connection.cc @@ -47,15 +47,16 @@ HTTPClientConnection::HTTPClientConnection() HTTPClientConnection::RC HTTPClientConnection::get( const std::string &url, HTTPHeaders headers, HTTPPayload payload, - std::shared_ptr<HTTPResponse> response, ReadBytesCallback *callback) { - return sendRequest(url, HTTPMethod::GET, headers, payload, response, - callback); + std::shared_ptr<HTTPResponse> response, ReadBytesCallback *callback, + std::string ipv6_first_word) { + return sendRequest(url, HTTPMethod::GET, headers, payload, response, callback, + ipv6_first_word); } HTTPClientConnection::RC HTTPClientConnection::sendRequest( const std::string &url, HTTPMethod method, HTTPHeaders headers, HTTPPayload payload, std::shared_ptr<HTTPResponse> response, - ReadBytesCallback *callback) { + ReadBytesCallback *callback, std::string ipv6_first_word) { current_url_ = url; read_bytes_callback_ = callback; if (!response) { @@ -82,12 +83,13 @@ HTTPClientConnection::RC HTTPClientConnection::sendRequest( return response; }; - sendRequestGetReply(request, response); + sendRequestGetReply(request, response, ipv6_first_word); return return_code_; } void HTTPClientConnection::sendRequestGetReply( - const HTTPRequest &request, std::shared_ptr<HTTPResponse> &response) { + const HTTPRequest &request, std::shared_ptr<HTTPResponse> &response, + std::string &ipv6_first_word) { const std::string &request_string = request.getRequestString(); const std::string &locator = request.getLocator(); @@ -107,7 +109,7 @@ void HTTPClientConnection::sendRequestGetReply( // Factor hicn name using hash name_.str(""); - name_ << std::hex << http::default_values::ipv6_first_word << ":"; + name_ << ipv6_first_word << ":"; for (uint16_t *word = (uint16_t *)&locator_hash; std::size_t(word) < (std::size_t(&locator_hash) + sizeof(locator_hash)); diff --git a/libtransport/src/hicn/transport/http/client_connection.h b/libtransport/src/hicn/transport/http/client_connection.h index d0624702f..5bcf9c4c7 100644 --- a/libtransport/src/hicn/transport/http/client_connection.h +++ b/libtransport/src/hicn/transport/http/client_connection.h @@ -49,12 +49,14 @@ class HTTPClientConnection : public ConsumerSocket::ReadCallback { RC get(const std::string &url, HTTPHeaders headers = {}, HTTPPayload payload = {}, std::shared_ptr<HTTPResponse> response = nullptr, - ReadBytesCallback *callback = nullptr); + ReadBytesCallback *callback = nullptr, + std::string ipv6_first_word = "b001"); RC sendRequest(const std::string &url, HTTPMethod method, HTTPHeaders headers = {}, HTTPPayload payload = {}, std::shared_ptr<HTTPResponse> response = nullptr, - ReadBytesCallback *callback = nullptr); + ReadBytesCallback *callback = nullptr, + std::string ipv6_first_word = "b001"); HTTPResponse response(); @@ -68,7 +70,8 @@ class HTTPClientConnection : public ConsumerSocket::ReadCallback { private: void sendRequestGetReply(const HTTPRequest &request, - std::shared_ptr<HTTPResponse> &response); + std::shared_ptr<HTTPResponse> &response, + std::string &ipv6_first_word); bool verifyData(interface::ConsumerSocket &c, const core::ContentObject &contentObject); |