Fixed a bug in HTTP parsing if data did not arrive in a nice way.
This commit is contained in:
parent
ee034c363a
commit
619b9533bd
4 changed files with 45 additions and 0 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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){
|
||||
|
|
Loading…
Add table
Reference in a new issue