fix available() == 0 for SSL streams

This commit is contained in:
Volker Berlin 2020-04-13 21:58:00 +02:00
parent 25423c6bb8
commit 850d990264

View File

@ -642,17 +642,13 @@ public class WasmRule extends TemporaryFolder {
*/ */
@SuppressWarnings( "resource" ) @SuppressWarnings( "resource" )
public static String readStream( InputStream input ) throws IOException { public static String readStream( InputStream input ) throws IOException {
if( input.available() > 0 ) {
byte[] bytes = new byte[8192]; byte[] bytes = new byte[8192];
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
while( input.available() > 0 ) { int count;
int count = input.read( bytes ); while( (count = input.read( bytes )) > 0 ) {
stream.write( bytes, 0, count ); stream.write( bytes, 0, count );
} }
return new String( stream.toByteArray() ); return new String( stream.toByteArray() );
} else {
return "";
}
} }
/** /**