// Path: cubano-httpeasy/src/main/java/org/concordion/cubano/driver/http/logging/LogManager.java
// public class LogManager {
//     private boolean logRequest;
//     private boolean logRequestDetails;
// 
//     private LogWriter logWriter;
//     private LogBuffer logBuffer = null;
// 
//     public LogManager(LogWriter logWriter, boolean logRequestDetails) {
//         if (logWriter == null) {
//             this.logRequest = false;
//             this.logRequestDetails = false;
//         } else {
//             this.logRequest = HttpEasyDefaults.getLogRequest() || logRequestDetails;
//             this.logRequestDetails = logRequestDetails;
//         }
// 
//         this.logWriter = logWriter;
//     }
// 
//     public boolean isLogRequestDetails() {
//         return logRequestDetails;
//     }
// 
//     public void info(String msg, Object... args) {
//         if (logWriter == null)
//             return;
// 
//         if (logRequest) {
//             logWriter.info(msg, args);
//         }
//     }
// 
//     public void error(String message, Throwable t) {
//         if (logWriter == null)
//             return;
// 
//         logWriter.error(message, t);
//     }
// 
//     public void flushInfo() {
//         if (logWriter != null) {
//             if (this.logRequest && logBuffer != null) {
//                 if (logBuffer.length() > 0) {
//                     logBuffer.trimNewLine();
// 
//                     String[] lines = logBuffer.toString().split("\\r?\\n");
// 
//                     for (String line : lines) {
//                         logWriter.info(line);
//                     }
//                 }
//             }
//         }
// 
//         logBuffer = null;
//     }
// 
//     public void flushRequest() {
//         if (logWriter != null) {
//             if (this.logRequestDetails && logBuffer != null) {
//                 if (logBuffer.length() > 0) {
//                     logBuffer.trimNewLine();
//                     logWriter.request(logBuffer.toString());
//                 }
//             }
//         }
// 
//         logBuffer = null;
//     }
// 
//     public void flushResponse() {
//         if (logWriter != null) {
//             if (this.logRequestDetails && logBuffer != null) {
//                 if (logBuffer.length() > 0) {
//                     logBuffer.trimNewLine();
//                     logWriter.response(logBuffer.toString());
//                 }
//             }
//         }
// 
//         logBuffer = null;
//     }
// 
//     public LogBuffer getBuffer() {
//         if (this.logBuffer == null) {
//             this.logBuffer = new LogBuffer();
//         }
// 
//         return this.logBuffer;
//     }
// }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import javax.xml.parsers.ParserConfigurationException;
import org.concordion.cubano.driver.http.logging.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
package org.concordion.cubano.driver.http;




/**
 * Response reader for HTTP requests, can parse JSON and XML and download files.
 *
 * @author Andrew Sumner
 */
public class HttpEasyReader {
    private HttpURLConnection connection;
    private String returned = null;

    private static final Logger LOGGER = LoggerFactory.getLogger(HttpEasyReader.class);

    /**
     * Create new HttpEasyReader.
     *
     * @param connection HttpURLConnection
     * @param request Request that is creating this reader
     * @throws HttpResponseException if request failed
     * @throws IOException for connection errors
     */
    public HttpEasyReader(HttpURLConnection connection, HttpEasy request) throws HttpResponseException, IOException {

        this.connection = connection;

        Family responseFamily = getResponseCodeFamily();

        logResponse(request);

        if (responseFamily != Family.SUCCESSFUL) {
            if (listContains(request.ignoreResponseCodes, getResponseCode())) {
                return;
            }

            if (listContains(request.ignoreResponseFamily, responseFamily)) {
                return;
            }

            throw new HttpResponseException(getResponseCode(),
                    "Server returned HTTP response code " + connection.getResponseCode() + ": " + connection.getResponseMessage() +
                            "\r\nResponse Content: " + asString());
        }
    }

    private void logResponse(HttpEasy request) throws IOException {
        if (!request.getLogManager().isLogRequestDetails()) {
            return;
        }

// Path: cubano-httpeasy/src/main/java/org/concordion/cubano/driver/http/logging/LogManager.java
// public class LogManager {
//     private boolean logRequest;
//     private boolean logRequestDetails;
// 
//     private LogWriter logWriter;
//     private LogBuffer logBuffer = null;
// 
//     public LogManager(LogWriter logWriter, boolean logRequestDetails) {
//         if (logWriter == null) {
//             this.logRequest = false;
//             this.logRequestDetails = false;
//         } else {
//             this.logRequest = HttpEasyDefaults.getLogRequest() || logRequestDetails;
//             this.logRequestDetails = logRequestDetails;
//         }
// 
//         this.logWriter = logWriter;
//     }
// 
//     public boolean isLogRequestDetails() {
//         return logRequestDetails;
//     }
// 
//     public void info(String msg, Object... args) {
//         if (logWriter == null)
//             return;
// 
//         if (logRequest) {
//             logWriter.info(msg, args);
//         }
//     }
// 
//     public void error(String message, Throwable t) {
//         if (logWriter == null)
//             return;
// 
//         logWriter.error(message, t);
//     }
// 
//     public void flushInfo() {
//         if (logWriter != null) {
//             if (this.logRequest && logBuffer != null) {
//                 if (logBuffer.length() > 0) {
//                     logBuffer.trimNewLine();
// 
//                     String[] lines = logBuffer.toString().split("\\r?\\n");
// 
//                     for (String line : lines) {
//                         logWriter.info(line);
//                     }
//                 }
//             }
//         }
// 
//         logBuffer = null;
//     }
// 
//     public void flushRequest() {
//         if (logWriter != null) {
//             if (this.logRequestDetails && logBuffer != null) {
//                 if (logBuffer.length() > 0) {
//                     logBuffer.trimNewLine();
//                     logWriter.request(logBuffer.toString());
//                 }
//             }
//         }
// 
//         logBuffer = null;
//     }
// 
//     public void flushResponse() {
//         if (logWriter != null) {
//             if (this.logRequestDetails && logBuffer != null) {
//                 if (logBuffer.length() > 0) {
//                     logBuffer.trimNewLine();
//                     logWriter.response(logBuffer.toString());
//                 }
//             }
//         }
// 
//         logBuffer = null;
//     }
// 
//     public LogBuffer getBuffer() {
//         if (this.logBuffer == null) {
//             this.logBuffer = new LogBuffer();
//         }
// 
//         return this.logBuffer;
//     }
// }


// Path: cubano-httpeasy/src/main/java/org/concordion/cubano/driver/http/HttpEasyReader.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import javax.xml.parsers.ParserConfigurationException;
import org.concordion.cubano.driver.http.logging.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

package org.concordion.cubano.driver.http;




/**
 * Response reader for HTTP requests, can parse JSON and XML and download files.
 *
 * @author Andrew Sumner
 */
public class HttpEasyReader {
    private HttpURLConnection connection;
    private String returned = null;

    private static final Logger LOGGER = LoggerFactory.getLogger(HttpEasyReader.class);

    /**
     * Create new HttpEasyReader.
     *
     * @param connection HttpURLConnection
     * @param request Request that is creating this reader
     * @throws HttpResponseException if request failed
     * @throws IOException for connection errors
     */
    public HttpEasyReader(HttpURLConnection connection, HttpEasy request) throws HttpResponseException, IOException {

        this.connection = connection;

        Family responseFamily = getResponseCodeFamily();

        logResponse(request);

        if (responseFamily != Family.SUCCESSFUL) {
            if (listContains(request.ignoreResponseCodes, getResponseCode())) {
                return;
            }

            if (listContains(request.ignoreResponseFamily, responseFamily)) {
                return;
            }

            throw new HttpResponseException(getResponseCode(),
                    "Server returned HTTP response code " + connection.getResponseCode() + ": " + connection.getResponseMessage() +
                            "\r\nResponse Content: " + asString());
        }
    }

    private void logResponse(HttpEasy request) throws IOException {
        if (!request.getLogManager().isLogRequestDetails()) {
            return;
        }

        LogManager logger = request.getLogManager();