diff --git a/src/connectors/conn_http.cpp b/src/connectors/conn_http.cpp index a8539abe..8b01c7f6 100644 --- a/src/connectors/conn_http.cpp +++ b/src/connectors/conn_http.cpp @@ -463,9 +463,8 @@ namespace Connector_HTTP { //wait for a response while (myCConn->conn->connected() && conn.connected()){ conn.spool(); - if (myCConn->conn->Received().size() || myCConn->conn->spool()){ //check if the whole header was received - if (H.Read(*(myCConn->conn))){ + if (myCConn->conn->spool() && H.Read(*(myCConn->conn))){ //208 means the fragment is too new, retry in 3s if (H.url == "208"){ while (myCConn->conn->Received().size() > 0){ @@ -488,7 +487,6 @@ namespace Connector_HTTP { continue; } break; //continue down below this while loop - } } //keep trying unless the timeout triggers if (timeout++ > 4000){ @@ -632,8 +630,7 @@ namespace Connector_HTTP { conn.setBlocking(false); //do not block on conn.spool() when no data is available HTTP::Parser Client; while (conn.connected()){ - if (conn.spool() || conn.Received().size()){ - if (Client.Read(conn)){ + if (conn.spool() && Client.Read(conn)){ std::string handler = proxyGetHandleType(Client); DEBUG_MSG(DLVL_HIGH, "Received request: %s (%d) => %s (%s)", Client.getUrl().c_str(), conn.getSocket(), handler.c_str(), Client.GetVar("stream").c_str()); #if DEBUG >= DLVL_HIGH @@ -665,7 +662,6 @@ namespace Connector_HTTP { break; } Client.Clean(); //clean for any possible next requests - } }else{ Util::sleep(10); //sleep 10ms } diff --git a/src/connectors/conn_http_dynamic.cpp b/src/connectors/conn_http_dynamic.cpp index 75898226..cea7caa5 100644 --- a/src/connectors/conn_http_dynamic.cpp +++ b/src/connectors/conn_http_dynamic.cpp @@ -163,8 +163,7 @@ namespace Connector_HTTP { while (conn.connected()){ if ( !handlingRequest){ - if (conn.spool() || conn.Received().size()){ - if (HTTP_R.Read(conn)){ + if (conn.spool() && HTTP_R.Read(conn)){ #if DEBUG >= 5 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; #endif @@ -267,7 +266,6 @@ namespace Connector_HTTP { HTTP_S.SendResponse("200", "OK", conn); } HTTP_R.Clean(); //clean for any possible next requests - } }else{ //sleep for 250ms before next attempt Util::sleep(250); diff --git a/src/connectors/conn_http_json.cpp b/src/connectors/conn_http_json.cpp index f5865c9e..5c36e107 100644 --- a/src/connectors/conn_http_json.cpp +++ b/src/connectors/conn_http_json.cpp @@ -44,18 +44,7 @@ namespace Connector_HTTP { while (conn.connected()){ //Only attempt to parse input when 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); - }else{ - conn.Received().append(tmp); - } - } - if (HTTP_R.Read(conn.Received().get())){ + if (conn.spool() && HTTP_R.Read(conn)){ #if DEBUG >= 5 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; #endif @@ -142,7 +131,6 @@ namespace Connector_HTTP { inited = true; } - } } if (inited){ diff --git a/src/connectors/conn_http_live.cpp b/src/connectors/conn_http_live.cpp index 48ad9b87..a0956c9f 100644 --- a/src/connectors/conn_http_live.cpp +++ b/src/connectors/conn_http_live.cpp @@ -128,8 +128,7 @@ namespace Connector_HTTP { while (conn.connected()){ if ( !handlingRequest){ - if (conn.spool() || conn.Received().size()){ - if (HTTP_R.Read(conn)){ + if (conn.spool() && HTTP_R.Read(conn)){ #if DEBUG >= 5 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; #endif @@ -217,7 +216,6 @@ namespace Connector_HTTP { } ready4data = true; HTTP_R.Clean(); //clean for any possible next requests - } }else{ Util::sleep(250); } diff --git a/src/connectors/conn_http_progressive_flv.cpp b/src/connectors/conn_http_progressive_flv.cpp index 71cd3829..9ec8ff23 100644 --- a/src/connectors/conn_http_progressive_flv.cpp +++ b/src/connectors/conn_http_progressive_flv.cpp @@ -46,8 +46,7 @@ namespace Connector_HTTP { while (conn.connected()){ //Only attempt to parse input when not yet init'ed. if ( !inited){ - if (conn.Received().size() || conn.spool()){ - if (HTTP_R.Read(conn)){ + if (conn.spool() && HTTP_R.Read(conn)){ #if DEBUG >= 5 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; #endif @@ -80,7 +79,6 @@ namespace Connector_HTTP { ready4data = true; HTTP_R.Clean(); //clean for any possible next requests } - } } if (ready4data){ if ( !inited){ diff --git a/src/connectors/conn_http_progressive_mp3.cpp b/src/connectors/conn_http_progressive_mp3.cpp index 51f819e4..21a335f6 100644 --- a/src/connectors/conn_http_progressive_mp3.cpp +++ b/src/connectors/conn_http_progressive_mp3.cpp @@ -45,8 +45,7 @@ namespace Connector_HTTP { while (conn.connected()){ //Only attempt to parse input when not yet init'ed. if ( !inited){ - if (conn.Received().size() || conn.spool()){ - if (HTTP_R.Read(conn)){ + if (conn.spool() && HTTP_R.Read(conn)){ #if DEBUG >= 5 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; #endif @@ -77,7 +76,6 @@ namespace Connector_HTTP { ready4data = true; HTTP_R.Clean(); //clean for any possible next requests } - } } if (ready4data){ if ( !inited){ diff --git a/src/connectors/conn_http_progressive_mp4.cpp b/src/connectors/conn_http_progressive_mp4.cpp index cd34a532..4a458be2 100644 --- a/src/connectors/conn_http_progressive_mp4.cpp +++ b/src/connectors/conn_http_progressive_mp4.cpp @@ -445,8 +445,7 @@ namespace Connector_HTTP { while (conn.connected()){ //Only attempt to parse input when not yet init'ed. if ( !inited){ - if (conn.Received().size() || conn.spool()){ - if (HTTP_R.Read(conn)){ + if (conn.spool() && HTTP_R.Read(conn)){ DEBUG_MSG(DLVL_DEVEL, "Received request: %s", HTTP_R.getUrl().c_str()); conn.setHost(HTTP_R.GetHeader("X-Origin")); streamname = HTTP_R.GetHeader("X-Stream"); @@ -559,7 +558,6 @@ namespace Connector_HTTP { sortSet.insert(temp); } inited = true; - } } }else{ unsigned int now = Util::epoch(); diff --git a/src/connectors/conn_http_progressive_ogg.cpp b/src/connectors/conn_http_progressive_ogg.cpp index 003a58e4..6f12d2c8 100644 --- a/src/connectors/conn_http_progressive_ogg.cpp +++ b/src/connectors/conn_http_progressive_ogg.cpp @@ -53,8 +53,7 @@ namespace Connector_HTTP { while (conn.connected()){ //Only attempt to parse input when not yet init'ed. if ( !inited){ - if (conn.Received().size() || conn.spool()){ - if (HTTP_R.Read(conn)){ + if (conn.spool() && HTTP_R.Read(conn)){ #if DEBUG >= 5 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; #endif @@ -62,7 +61,6 @@ namespace Connector_HTTP { streamname = HTTP_R.GetHeader("X-Stream"); ready4data = true; HTTP_R.Clean(); //clean for any possible next requests - } } } if (ready4data){ diff --git a/src/connectors/conn_http_smooth.cpp b/src/connectors/conn_http_smooth.cpp index 9519e19a..c269c7da 100644 --- a/src/connectors/conn_http_smooth.cpp +++ b/src/connectors/conn_http_smooth.cpp @@ -217,8 +217,7 @@ namespace Connector_HTTP { while (conn.connected()){ if ( !handlingRequest){ - if (conn.spool() || conn.Received().size()){ - if (HTTP_R.Read(conn)){ + if (conn.spool() && HTTP_R.Read(conn)){ #if DEBUG >= 5 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; #endif @@ -443,8 +442,6 @@ namespace Connector_HTTP { ready4data = true; //Clean for any possible next requests HTTP_R.Clean(); - } - }else{ //Wait 250ms before checking for new data. Util::sleep(250); diff --git a/src/connectors/conn_http_srt.cpp b/src/connectors/conn_http_srt.cpp index e386e637..cbb8513e 100644 --- a/src/connectors/conn_http_srt.cpp +++ b/src/connectors/conn_http_srt.cpp @@ -47,8 +47,7 @@ namespace Connector_HTTP { while (conn.connected()){ //Only attempt to parse input when not yet init'ed. if ( !inited){ - if (conn.Received().size() || conn.spool()){ - if (HTTP_R.Read(conn)){ + if (conn.spool() && HTTP_R.Read(conn)){ #if DEBUG >= 5 std::cout << "Received request: " << HTTP_R.getUrl() << std::endl; #endif @@ -142,7 +141,6 @@ namespace Connector_HTTP { srtdata.clear(); curIndex = 1; // set to 1, first srt 'track' } - } } unsigned int now = Util::epoch();