/** * <p> * Return response body data from server as a byte array. * </p> * <p> * <b>Important:</b> you must call <code>execute()</code> before calling this method. * </p> * * @return Byte array of response body data from server, if any * @throws IOException if there was a problem reading data from the server */ public byte[] responseAsBytes() throws IOException { InputStream is = responseAsInputStream(); try { return IOUtils.toByteArray(is); } finally { Utils.close(is); disconnect(); } }