From 850d990264d7cd7ffe3e683e87f58ec8fb9c71bc Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Mon, 13 Apr 2020 21:58:00 +0200 Subject: [PATCH] fix available() == 0 for SSL streams --- test/de/inetsoftware/jwebassembly/WasmRule.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/test/de/inetsoftware/jwebassembly/WasmRule.java b/test/de/inetsoftware/jwebassembly/WasmRule.java index dbb3528..8511f6e 100644 --- a/test/de/inetsoftware/jwebassembly/WasmRule.java +++ b/test/de/inetsoftware/jwebassembly/WasmRule.java @@ -642,17 +642,13 @@ public class WasmRule extends TemporaryFolder { */ @SuppressWarnings( "resource" ) public static String readStream( InputStream input ) throws IOException { - if( input.available() > 0 ) { - byte[] bytes = new byte[ 8192 ]; - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - while( input.available() > 0 ) { - int count = input.read( bytes ); - stream.write( bytes, 0, count ); - } - return new String( stream.toByteArray() ); - } else { - return ""; + byte[] bytes = new byte[8192]; + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + int count; + while( (count = input.read( bytes )) > 0 ) { + stream.write( bytes, 0, count ); } + return new String( stream.toByteArray() ); } /**