diff --git a/src/conn_http.cpp b/src/conn_http.cpp index dd22b8a3..b2e857ce 100644 --- a/src/conn_http.cpp +++ b/src/conn_http.cpp @@ -241,6 +241,15 @@ namespace Connector_HTTP{ while (connconn.count(uid) && connconn[uid]->conn->connected() && conn->connected()){ conn->spool(); if (connconn[uid]->conn->Received().size() || connconn[uid]->conn->spool()){ + //make sure we end in a \n + if (*(connconn[uid]->conn->Received().get().rbegin()) != '\n'){ + std::string tmp = connconn[uid]->conn->Received().get(); + connconn[uid]->conn->Received().get().clear(); + if (connconn[uid]->conn->Received().size()){ + connconn[uid]->conn->Received().get().insert(0, tmp); + } + continue; + } //check if the whole response was received if (H.Read(connconn[uid]->conn->Received().get())){ break;//continue down below this while loop @@ -330,6 +339,15 @@ namespace Connector_HTTP{ HTTP::Parser Client; while (conn->connected()){ if (conn->Received().size() || conn->spool()){ + //make sure it ends in a \n + if (*(conn->Received().get().rbegin()) != '\n'){ + std::string tmp = conn->Received().get(); + conn->Received().get().clear(); + if (conn->Received().size()){ + conn->Received().get().insert(0, tmp); + } + continue; + } if (Client.Read(conn->Received().get())){ std::string handler = getHTTPType(Client); long long int startms = Util::getMS(); diff --git a/src/conn_http_dynamic.cpp b/src/conn_http_dynamic.cpp index 7edddbc5..a996213b 100644 --- a/src/conn_http_dynamic.cpp +++ b/src/conn_http_dynamic.cpp @@ -180,6 +180,15 @@ namespace Connector_HTTP{ while (conn.connected()){ if (conn.spool() || conn.Received().size()){ + //make sure it ends in a \n + if (*(conn.Received().get().rbegin()) != '\n'){ + std::string tmp = conn.Received().get(); + conn.Received().get().clear(); + if (conn.Received().size()){ + conn.Received().get().insert(0, tmp); + } + continue; + } if (HTTP_R.Read(conn.Received().get())){ #if DEBUG >= 4 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; diff --git a/src/conn_http_progressive.cpp b/src/conn_http_progressive.cpp index 9e6283a2..82a62e26 100644 --- a/src/conn_http_progressive.cpp +++ b/src/conn_http_progressive.cpp @@ -42,6 +42,15 @@ namespace Connector_HTTP{ //only parse input if available or not yet init'ed if (!inited){ if (conn.Received().size() || conn.spool()){ + //make sure it ends in a \n + if (*(conn.Received().get().rbegin()) != '\n'){ + std::string tmp = conn.Received().get(); + conn.Received().get().clear(); + if (conn.Received().size()){ + conn.Received().get().insert(0, tmp); + } + continue; + } if (HTTP_R.Read(conn.Received().get())){ #if DEBUG >= 4 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; diff --git a/src/controller.cpp b/src/controller.cpp index fc3213b7..a968e381 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -497,6 +497,15 @@ int main(int argc, char ** argv){ break; } if (it->C.spool() || it->C.Received().size()){ + if (*(it->C.Received().get().rbegin()) != '\n'){ + std::string tmp = it->C.Received().get(); + it->C.Received().get().clear(); + if (it->C.Received().size()){ + it->C.Received().get().insert(0, tmp); + } + continue; + } + if (it->H.Read(it->C.Received().get())){ Response.null(); //make sure no data leaks from previous requests if (it->clientMode){