aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/http/response.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/src/http/response.cc')
-rw-r--r--libtransport/src/http/response.cc19
1 files changed, 7 insertions, 12 deletions
diff --git a/libtransport/src/http/response.cc b/libtransport/src/http/response.cc
index 409992835..c665fbc5f 100644
--- a/libtransport/src/http/response.cc
+++ b/libtransport/src/http/response.cc
@@ -17,9 +17,8 @@
#include <hicn/transport/http/response.h>
#include <algorithm>
-#include <functional>
-
#include <cstring>
+#include <functional>
namespace transport {
@@ -67,7 +66,7 @@ std::size_t HTTPResponse::parseHeaders(const uint8_t *buffer, std::size_t size,
auto it = std::search(begin, end, begincrlf2, endcrlf2);
if (it != end) {
std::stringstream ss;
- ss.str(std::string(begin, it));
+ ss.str(std::string(begin, it + 2));
std::string line;
getline(ss, line);
@@ -86,15 +85,8 @@ std::size_t HTTPResponse::parseHeaders(const uint8_t *buffer, std::size_t size,
return 0;
}
- std::string _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);
+ line_s >> status_string;
std::size_t param_end;
std::size_t value_start;
@@ -106,7 +98,10 @@ std::size_t HTTPResponse::parseHeaders(const uint8_t *buffer, std::size_t size,
value_start++;
}
if (value_start < line.size()) {
- headers[line.substr(0, param_end)] =
+ auto header = line.substr(0, param_end);
+ std::transform(header.begin(), header.end(), header.begin(),
+ [](unsigned char c) { return std::tolower(c); });
+ headers[header] =
line.substr(value_start, line.size() - value_start - 1);
}
}