From 9ff67b96fd0aa2a7a72bc45e006d56b395a31a7a Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 18 Apr 2011 16:08:55 +0200 Subject: [PATCH] Hopelijk laatste socket fix --- util/http_parser.cpp | 9 ++++----- util/http_parser.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) 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);