// Path: http-builder-ng-core/src/main/java/groovyx/net/http/util/IoUtils.java
// public class IoUtils {
// 
//     /**
//      * Reads all bytes from the stream into a byte array.
//      *
//      * @param inputStream the {@link InputStream}
//      * @return the array of bytes from the stream
//      * @throws IOException if there is a problem reading the stream
//      */
//     public static byte[] streamToBytes(final InputStream inputStream) throws IOException {
//         return streamToBytes(inputStream, true);
//     }
// 
//     public static byte[] streamToBytes(final InputStream inputStream, boolean close) throws IOException {
//         try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
//             final byte[] bytes = new byte[2_048];
// 
//             int read;
//             while ((read = inputStream.read(bytes)) != -1) {
//                 outputStream.write(bytes, 0, read);
//             }
// 
//             return outputStream.toByteArray();
// 
//         } finally {
//             if (close) inputStream.close();
//         }
//     }
// 
//     /**
//      * Safely copies the contents of the {@link BufferedInputStream} to a {@link String} and resets the stream.
//      * This method is generally only useful for testing and logging purposes.
//      *
//      * @param inputStream the BufferedInputStream
//      * @return a String copy of the stream contents
//      * @throws IOException           if something goes wrong with the stream
//      * @throws IllegalStateException if the stream cannot be reset
//      */
//     public static String copyAsString(final BufferedInputStream inputStream) throws IOException, IllegalStateException {
//         if (inputStream == null) return null;
// 
//         try {
//             inputStream.mark(Integer.MAX_VALUE);
//             return new String(streamToBytes(inputStream, false));
//         } finally {
//             try {
//                 inputStream.reset();
//             } catch (IOException ioe) {
//                 throw new IllegalStateException("Unable to reset stream - original stream content may be corrupted");
//             }
//         }
//     }
// 
//     /**
//      * Transfers the contents of the {@link InputStream} into the {@link OutputStream}, optionally closing the stream.
//      *
//      * @param istream the input stream
//      * @param ostream the output stream
//      * @param close   whether or not to close the output stream
//      */
//     public static void transfer(final InputStream istream, final OutputStream ostream, final boolean close) {
//         try {
//             final byte[] bytes = new byte[2_048];
//             int read;
//             while ((read = istream.read(bytes)) != -1) {
//                 ostream.write(bytes, 0, read);
//             }
//         } catch (IOException e) {
//             throw new TransportingException(e);
//         } finally {
//             if (close) {
//                 try {
//                     ostream.close();
//                 } catch (IOException ioe) {
//                     throw new TransportingException(ioe);
//                 }
//             }
//         }
//     }
// }
// 
// Path: http-builder-ng-core/src/main/java/groovyx/net/http/HttpBuilder.java
// static final ResponseHandlerFunction HANDLER_FUNCTION = new ResponseHandlerFunction();


import java.util.function.Consumer;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
import static groovyx.net.http.HttpBuilder.ResponseHandlerFunction.HANDLER_FUNCTION;
import groovyx.net.http.util.IoUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.nio.charset.Charset;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
                    requestConfig.findEncoder().accept(requestConfig, j2s);
                }

                if (log.isDebugEnabled()) {
                    log.debug("Request-URI({}): {}", connection.getRequestMethod(), theUri);
                }

                addHeaders();

                connection.connect();

                if (j2s != null) {
                    if (contentLog.isDebugEnabled()) {
                        contentLog.debug("Request-Body({}): {}", requestConfig.getChainedRequest().actualContentType(), j2s.content());
                    }

                    j2s.transfer();

                }

                final JavaFromServer fromServer = new JavaFromServer(theUri);

                if (contentLog.isDebugEnabled()) {
                    contentLog.debug("Response-Body: {}", fromServer.content());
                }

                if (headerLog.isDebugEnabled()) {
                    fromServer.getHeaders().forEach(header -> headerLog.debug("Response-Header: {} -> {}", header.getKey(), header.getValue()));
                }

// Path: http-builder-ng-core/src/main/java/groovyx/net/http/util/IoUtils.java
// public class IoUtils {
// 
//     /**
//      * Reads all bytes from the stream into a byte array.
//      *
//      * @param inputStream the {@link InputStream}
//      * @return the array of bytes from the stream
//      * @throws IOException if there is a problem reading the stream
//      */
//     public static byte[] streamToBytes(final InputStream inputStream) throws IOException {
//         return streamToBytes(inputStream, true);
//     }
// 
//     public static byte[] streamToBytes(final InputStream inputStream, boolean close) throws IOException {
//         try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
//             final byte[] bytes = new byte[2_048];
// 
//             int read;
//             while ((read = inputStream.read(bytes)) != -1) {
//                 outputStream.write(bytes, 0, read);
//             }
// 
//             return outputStream.toByteArray();
// 
//         } finally {
//             if (close) inputStream.close();
//         }
//     }
// 
//     /**
//      * Safely copies the contents of the {@link BufferedInputStream} to a {@link String} and resets the stream.
//      * This method is generally only useful for testing and logging purposes.
//      *
//      * @param inputStream the BufferedInputStream
//      * @return a String copy of the stream contents
//      * @throws IOException           if something goes wrong with the stream
//      * @throws IllegalStateException if the stream cannot be reset
//      */
//     public static String copyAsString(final BufferedInputStream inputStream) throws IOException, IllegalStateException {
//         if (inputStream == null) return null;
// 
//         try {
//             inputStream.mark(Integer.MAX_VALUE);
//             return new String(streamToBytes(inputStream, false));
//         } finally {
//             try {
//                 inputStream.reset();
//             } catch (IOException ioe) {
//                 throw new IllegalStateException("Unable to reset stream - original stream content may be corrupted");
//             }
//         }
//     }
// 
//     /**
//      * Transfers the contents of the {@link InputStream} into the {@link OutputStream}, optionally closing the stream.
//      *
//      * @param istream the input stream
//      * @param ostream the output stream
//      * @param close   whether or not to close the output stream
//      */
//     public static void transfer(final InputStream istream, final OutputStream ostream, final boolean close) {
//         try {
//             final byte[] bytes = new byte[2_048];
//             int read;
//             while ((read = istream.read(bytes)) != -1) {
//                 ostream.write(bytes, 0, read);
//             }
//         } catch (IOException e) {
//             throw new TransportingException(e);
//         } finally {
//             if (close) {
//                 try {
//                     ostream.close();
//                 } catch (IOException ioe) {
//                     throw new TransportingException(ioe);
//                 }
//             }
//         }
//     }
// }
// 
// Path: http-builder-ng-core/src/main/java/groovyx/net/http/HttpBuilder.java
// static final ResponseHandlerFunction HANDLER_FUNCTION = new ResponseHandlerFunction();


// Path: http-builder-ng-core/src/main/java/groovyx/net/http/JavaHttpBuilder.java
import java.util.function.Consumer;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
import static groovyx.net.http.HttpBuilder.ResponseHandlerFunction.HANDLER_FUNCTION;
import groovyx.net.http.util.IoUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.nio.charset.Charset;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;

                    requestConfig.findEncoder().accept(requestConfig, j2s);
                }

                if (log.isDebugEnabled()) {
                    log.debug("Request-URI({}): {}", connection.getRequestMethod(), theUri);
                }

                addHeaders();

                connection.connect();

                if (j2s != null) {
                    if (contentLog.isDebugEnabled()) {
                        contentLog.debug("Request-Body({}): {}", requestConfig.getChainedRequest().actualContentType(), j2s.content());
                    }

                    j2s.transfer();

                }

                final JavaFromServer fromServer = new JavaFromServer(theUri);

                if (contentLog.isDebugEnabled()) {
                    contentLog.debug("Response-Body: {}", fromServer.content());
                }

                if (headerLog.isDebugEnabled()) {
                    fromServer.getHeaders().forEach(header -> headerLog.debug("Response-Header: {} -> {}", header.getKey(), header.getValue()));
                }

                return HANDLER_FUNCTION.apply(requestConfig, fromServer);