HTTP usage optimizes
This commit is contained in:
parent
7a7e860bf2
commit
8cba8e597c
10 changed files with 11 additions and 44 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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){
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue