From 94023176e2717944eded901a60daa4a62808d3bd Mon Sep 17 00:00:00 2001 From: "rpotts%netscape.com" Date: Tue, 5 Oct 1999 05:02:56 +0000 Subject: [PATCH] Fixed up broken test case while investigating bug #14181... --- netwerk/test/TestProtocols.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/netwerk/test/TestProtocols.cpp b/netwerk/test/TestProtocols.cpp index 88a3125dcd0f..6ade921ff077 100644 --- a/netwerk/test/TestProtocols.cpp +++ b/netwerk/test/TestProtocols.cpp @@ -306,14 +306,19 @@ InputTestConsumer::OnDataAvailable(nsIChannel* channel, PRUint32 aLength) { char buf[1025]; - PRUint32 amt; + PRUint32 amt, size; nsresult rv; URLLoadInfo* info = (URLLoadInfo*)context; - do { - rv = aIStream->Read(buf, 1024, &amt); - if (NS_FAILED(rv)) return rv; - if (amt == 0) break; + while (aLength) { + size = min(aLength, sizeof(buf)); + + rv = aIStream->Read(buf, size, &amt); + if (NS_FAILED(rv)) { + NS_ASSERTION((NS_BASE_STREAM_WOULD_BLOCK != rv), + "The stream should never block."); + return rv; + } if (gVerbose) { buf[amt] = '\0'; puts(buf); @@ -321,8 +326,9 @@ InputTestConsumer::OnDataAvailable(nsIChannel* channel, if (info) { info->mBytesRead += amt; } - } while (amt); + aLength -= amt; + } return NS_OK; }