diff options
author | Mauro Sardara <msardara@cisco.com> | 2020-05-14 20:27:11 +0200 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2020-05-20 11:07:30 +0200 |
commit | a27536f3d1ce6c2f46aef61a29dd1f516644e663 (patch) | |
tree | abcf4c6285dbd824f21095d33293a48d58d74889 /apps/http-proxy/src/HTTP1.xMessageFastParser.cc | |
parent | 81fb39606b069fbece973995572fa7f90ea1950a (diff) |
[HICN-614] Add client HTTP proxy (TCP->hICN)
Change-Id: Ieaa875edff98404676083bab91233b98ce50c8d0
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'apps/http-proxy/src/HTTP1.xMessageFastParser.cc')
-rw-r--r-- | apps/http-proxy/src/HTTP1.xMessageFastParser.cc | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/apps/http-proxy/src/HTTP1.xMessageFastParser.cc b/apps/http-proxy/src/HTTP1.xMessageFastParser.cc index 729eb3aeb..d1271ebdf 100644 --- a/apps/http-proxy/src/HTTP1.xMessageFastParser.cc +++ b/apps/http-proxy/src/HTTP1.xMessageFastParser.cc @@ -15,6 +15,7 @@ #include "HTTP1.xMessageFastParser.h" +#include <hicn/transport/http/request.h> #include <hicn/transport/http/response.h> #include <experimental/algorithm> @@ -31,15 +32,27 @@ std::string HTTPMessageFastParser::connection = "Connection"; std::string HTTPMessageFastParser::separator = "\r\n\r\n"; HTTPHeaders HTTPMessageFastParser::getHeaders(const uint8_t *headers, - std::size_t length) { + std::size_t length, + bool request) { HTTPHeaders ret; std::string http_version; - std::string status_code; - std::string status_string; - if (transport::http::HTTPResponse::parseHeaders(headers, length, ret, http_version, - status_code, status_string)) { - return ret; + if (request) { + std::string method; + std::string url; + + if (transport::http::HTTPRequest::parseHeaders(headers, length, ret, + http_version, method, url)) { + return ret; + } + } else { + std::string status_code; + std::string status_string; + + if (transport::http::HTTPResponse::parseHeaders( + headers, length, ret, http_version, status_code, status_string)) { + return ret; + } } throw std::runtime_error("Error parsing response headers."); |