From 4624155351a9f9b78c531b5de230ceec599954d4 Mon Sep 17 00:00:00 2001 From: Fred Nicolson Date: Mon, 13 Jan 2020 10:52:33 +0000 Subject: [PATCH] Fix CI. Http parsing optimisation. --- include/frnetlib/Http.h | 8 +------- include/frnetlib/WebFrame.h | 2 +- src/HttpRequest.cpp | 5 ++--- src/HttpResponse.cpp | 2 +- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/include/frnetlib/Http.h b/include/frnetlib/Http.h index e10da39..80ae13f 100644 --- a/include/frnetlib/Http.h +++ b/include/frnetlib/Http.h @@ -13,17 +13,11 @@ #include "Socket.h" #include "Sendable.h" -#ifdef ENABLE_TESTING -#include -#endif - namespace fr { class Http : public Sendable { -#ifdef ENABLE_TESTING - FRIEND_TEST(HttpTest, test_string_split); -#endif + friend class HttpTest_test_string_split_Test; public: enum class RequestVersion { diff --git a/include/frnetlib/WebFrame.h b/include/frnetlib/WebFrame.h index 1209273..2dd7e13 100644 --- a/include/frnetlib/WebFrame.h +++ b/include/frnetlib/WebFrame.h @@ -121,7 +121,7 @@ namespace fr private: mutable std::string payload; Opcode opcode; - bool final; + uint8_t final; static uint32_t current_mask_key; }; } diff --git a/src/HttpRequest.cpp b/src/HttpRequest.cpp index 7f83832..b6a0b5a 100644 --- a/src/HttpRequest.cpp +++ b/src/HttpRequest.cpp @@ -16,7 +16,7 @@ namespace fr fr::Socket::Status HttpRequest::parse(const char *request, size_t requestsz) { - body += std::string(request, requestsz); + body.append(request, requestsz); //Ensure that the whole header has been parsed first if(!header_ended) @@ -182,8 +182,7 @@ namespace fr auto post = parse_argument_list(body.substr(post_begin, body.size() - post_begin - (body.size() - post_end))); for(auto &c : post) { - std::transform(c.first.begin(), c.first.end(), c.first.begin(), ::tolower); - post_data.emplace(std::move(c.first), std::move(c.second)); + this->post(std::move(c.first)) = std::move(c.second); } } diff --git a/src/HttpResponse.cpp b/src/HttpResponse.cpp index 5fe390e..cda31b6 100644 --- a/src/HttpResponse.cpp +++ b/src/HttpResponse.cpp @@ -9,7 +9,7 @@ namespace fr { fr::Socket::Status HttpResponse::parse(const char *response_data, size_t datasz) { - body += std::string(response_data, datasz); + body.append(response_data, datasz); //Ensure that the whole header has been parsed first if(!header_ended)