diff --git a/Connector_HTTP/main.cpp b/Connector_HTTP/main.cpp index a7fbf0e3..4ba94342 100644 --- a/Connector_HTTP/main.cpp +++ b/Connector_HTTP/main.cpp @@ -160,7 +160,7 @@ namespace Connector_HTTP{ while (conn.connected() && !FLV::Parse_Error){ //only parse input if available or not yet init'ed - if (HTTP_R.Read(conn)){ + if (HTTP_R.Read(conn, ready4data)){ handler = HANDLER_PROGRESSIVE; if ((HTTP_R.url.find("Seg") != std::string::npos) && (HTTP_R.url.find("Frag") != std::string::npos)){handler = HANDLER_FLASH;} if (HTTP_R.url.find("f4m") != std::string::npos){handler = HANDLER_FLASH;} @@ -174,7 +174,7 @@ namespace Connector_HTTP{ printf("Sending crossdomain.xml file\n"); #endif } - if(handler == HANDLER_FLASH){ + if (handler == HANDLER_FLASH){ if (HTTP_R.url.find("f4m") == std::string::npos){ Movie = HTTP_R.url.substr(1); Movie = Movie.substr(0,Movie.find("/")); diff --git a/util/http_parser.cpp b/util/http_parser.cpp index 8c9ed2db..4fe7b94f 100644 --- a/util/http_parser.cpp +++ b/util/http_parser.cpp @@ -128,12 +128,11 @@ void HTTP::Parser::SetVar(std::string i, std::string v){ } /// Attempt to read a whole HTTP request or response from DDV::Socket sock. +/// \param sock The socket to use. +/// \param nonblock When true, will not block even if the socket is blocking. /// \return True of a whole request or response was read, false otherwise. -bool HTTP::Parser::Read(DDV::Socket & sock){ - //returned true als hele http packet gelezen is - int r = 0; - int b = 0; - char buffer[500]; +bool HTTP::Parser::Read(DDV::Socket & sock, bool nonblock){ + if (nonblock && (sock.ready() < 1)){return parse();} sock.read(HTTPbuffer); return parse(); }//HTTPReader::ReadSocket diff --git a/util/http_parser.h b/util/http_parser.h index d08cadef..ed8f64fe 100644 --- a/util/http_parser.h +++ b/util/http_parser.h @@ -14,7 +14,7 @@ namespace HTTP{ class Parser{ public: Parser(); - bool Read(DDV::Socket & sock); + bool Read(DDV::Socket & sock, bool nonblock = true); bool Read(FILE * F); std::string GetHeader(std::string i); std::string GetVar(std::string i);