From 724ed6c46b13a5a511d1dbe1fc0f557189f9c798 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 8 Oct 2007 06:04:24 +0000 Subject: More updates, I'll doc them later, http works, client is less picky. --- src/client.cpp | 33 ++++++++++++++++++--------------- src/fstring.h | 2 ++ src/protocolhttp.cpp | 8 ++++---- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index ee301e9..b546deb 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -27,31 +27,34 @@ void Bu::Client::processInput() for(;;) { - nRead = pSocket->read( buf, nRead ); - if( nRead < 0 ) + try { - throw Bu::ConnectionException( - excodeReadError, - "Read error: %s", - strerror( errno ) - ); + nRead = pSocket->read( buf, RBS ); + + if( nRead == 0 ) + { + break; + } + else + { + nTotal += nRead; + sReadBuf.append( buf, nRead ); + if( !pSocket->canRead() ) + break; + } } - else if( nRead == 0 ) + catch( ConnectionException &e ) { + pSocket->close(); + bWantsDisconnect = true; break; } - else - { - nTotal += nRead; - sReadBuf.append( buf, nRead ); - if( !pSocket->canRead() ) - break; - } } if( nTotal == 0 ) { pSocket->close(); + bWantsDisconnect = true; } if( pProto && nTotal ) diff --git a/src/fstring.h b/src/fstring.h index 0306aa1..97959d3 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -444,6 +444,8 @@ namespace Bu if( pFirst == NULL ) { if( pData == NULL ) return true; + if( pData[0] == (chr)0 ) + return true; return false; } diff --git a/src/protocolhttp.cpp b/src/protocolhttp.cpp index e962b7a..ed303b6 100644 --- a/src/protocolhttp.cpp +++ b/src/protocolhttp.cpp @@ -25,17 +25,17 @@ void Bu::ProtocolHttp::onNewConnection( Bu::Client *pClient ) iState = 0; } -//#define SDB( i ) { } -#define SDB( i ) printf("state %d: %d, \"%s\"\n", i, tt, sToken.getStr() ) +#define SDB( i ) { } +//#define SDB( i ) printf("state %d: %d, \"%s\"\n", i, tt, sToken.getStr() ) void Bu::ProtocolHttp::onNewData( Bu::Client *pClient ) { - logHexDump( +/* logHexDump( 1, pClient->getInput().getStr(), pClient->getInput().getSize(), "input" - ); + );*/ for(;;) { -- cgit v1.2.3