protected void loadResponseText() throws IOException { if (_responseText != null) throw new IllegalStateException( "May only invoke loadResponseText once" ); _responseText = ""; InputStream inputStream = getInputStream(); try { final int contentLength = this.encodedUsingGZIP() ? -1 : getContentLength(); int bytesRemaining = contentLength < 0 ? Integer.MAX_VALUE : contentLength; byte[] bytes = readFromStream( inputStream, bytesRemaining ); readTags( bytes ); _responseText = new String( bytes, getCharacterSet() ); _inputStream = new ByteArrayInputStream( bytes ); if (HttpUnitOptions.isCheckContentLength() && contentLength >= 0 && bytes.length != contentLength) { throw new IOException("Truncated message. Expected length: " + contentLength + ", Actual length: " + bytes.length); } } finally { inputStream.close(); } }
protected void loadResponseText() throws IOException { if (_responseText != null) throw new IllegalStateException( "May only invoke loadResponseText once" ); _responseText = ""; InputStream inputStream = getInputStream(); try { final int contentLength = this.encodedUsingGZIP() ? -1 : getContentLength(); int bytesRemaining = contentLength < 0 ? Integer.MAX_VALUE : contentLength; byte[] bytes = readFromStream( inputStream, bytesRemaining ); readTags( bytes ); _responseText = new String( bytes, getCharacterSet() ); _inputStream = new ByteArrayInputStream( bytes ); if (HttpUnitOptions.isCheckContentLength() && contentLength >= 0 && bytes.length != contentLength) { throw new IOException("Truncated message. Expected length: " + contentLength + ", Actual length: " + bytes.length); } } finally { inputStream.close(); } }
protected void loadResponseText() throws IOException { if (_responseText != null) throw new IllegalStateException( "May only invoke loadResponseText once" ); _responseText = ""; InputStream inputStream = getInputStream(); try { final int contentLength = this.encodedUsingGZIP() ? -1 : getContentLength(); int bytesRemaining = contentLength < 0 ? Integer.MAX_VALUE : contentLength; byte[] bytes = readFromStream( inputStream, bytesRemaining ); readTags( bytes ); _responseText = new String( bytes, getCharacterSet() ); _inputStream = new ByteArrayInputStream( bytes ); if (HttpUnitOptions.isCheckContentLength() && contentLength >= 0 && bytes.length != contentLength) { throw new IOException("Truncated message. Expected length: " + contentLength + ", Actual length: " + bytes.length); } } finally { inputStream.close(); } }