// Path: src/main/java/de/galan/commons/io/streams/IOSupport.java
// public class IOSupport {
// 
// 	public static String inputstreamToString(InputStream is) throws IOException {
// 		return inputstreamToString(is, StandardCharsets.UTF_8);
// 	}
// 
// 
// 	public static String inputstreamToString(InputStream is, Charset charset) throws IOException {
// 		ByteSource byteSource = new ByteSource() {
// 
// 			@Override
// 			public InputStream openStream() throws IOException {
// 				return is;
// 			}
// 		};
// 		return byteSource.asCharSource(charset).read();
// 	}
// 
// }
// 
// Path: src/main/java/de/galan/commons/logging/Logr.java
// public class Logr {
// 
// 	private static final StackWalker WALKER = StackWalker.getInstance(Sets.newHashSet(RETAIN_CLASS_REFERENCE));
// 
// 
// 	/**
// 	 * To be used to get the Log4j2 Logger in a class, eg. <code>private final static Logger LOG = Logr.get();</code>.
// 	 * To avoid the Logger declaration completely, use the class <code>Say</code>.
// 	 */
// 	public static Logger get() {
// 		return LogManager.getLogger(WALKER.getCallerClass(), PayloadMessageFactory.INSTANCE);
// 	}
// 
// }


import static org.apache.commons.lang3.StringUtils.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.apache.logging.log4j.Logger;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteSink;
import com.google.common.io.Files;
import de.galan.commons.io.streams.IOSupport;
import de.galan.commons.logging.Logr;
package de.galan.commons.net.flux;







/**
 * Represents the reponse to a http service.
 */
public class Response implements AutoCloseable {

	private static final Logger LOG = Logr.get();

	private final static Map<String, String> EMPTY_HEADERS = ImmutableMap.of();

	private final InputStream dataStream;
	private final int statusCode;
	private final String contentEncoding;
	private final String contentType;
	private final HttpURLConnection connection;
	private final Map<String, String> headerFields;

	public Response(HttpURLConnection connection, InputStream dataStream, int statusCode, String contentEncoding, String contentType, Map<String, String> headerFields) {
		this.connection = connection;
		this.dataStream = dataStream;
		this.statusCode = statusCode;
		this.contentEncoding = contentEncoding;
		this.contentType = contentType;
// Path: src/main/java/de/galan/commons/io/streams/IOSupport.java
// public class IOSupport {
// 
// 	public static String inputstreamToString(InputStream is) throws IOException {
// 		return inputstreamToString(is, StandardCharsets.UTF_8);
// 	}
// 
// 
// 	public static String inputstreamToString(InputStream is, Charset charset) throws IOException {
// 		ByteSource byteSource = new ByteSource() {
// 
// 			@Override
// 			public InputStream openStream() throws IOException {
// 				return is;
// 			}
// 		};
// 		return byteSource.asCharSource(charset).read();
// 	}
// 
// }
// 
// Path: src/main/java/de/galan/commons/logging/Logr.java
// public class Logr {
// 
// 	private static final StackWalker WALKER = StackWalker.getInstance(Sets.newHashSet(RETAIN_CLASS_REFERENCE));
// 
// 
// 	/**
// 	 * To be used to get the Log4j2 Logger in a class, eg. <code>private final static Logger LOG = Logr.get();</code>.
// 	 * To avoid the Logger declaration completely, use the class <code>Say</code>.
// 	 */
// 	public static Logger get() {
// 		return LogManager.getLogger(WALKER.getCallerClass(), PayloadMessageFactory.INSTANCE);
// 	}
// 
// }


// Path: src/main/java/de/galan/commons/net/flux/Response.java
import static org.apache.commons.lang3.StringUtils.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.apache.logging.log4j.Logger;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteSink;
import com.google.common.io.Files;
import de.galan.commons.io.streams.IOSupport;
import de.galan.commons.logging.Logr;

package de.galan.commons.net.flux;







/**
 * Represents the reponse to a http service.
 */
public class Response implements AutoCloseable {

	private static final Logger LOG = Logr.get();

	private final static Map<String, String> EMPTY_HEADERS = ImmutableMap.of();

	private final InputStream dataStream;
	private final int statusCode;
	private final String contentEncoding;
	private final String contentType;
	private final HttpURLConnection connection;
	private final Map<String, String> headerFields;

	public Response(HttpURLConnection connection, InputStream dataStream, int statusCode, String contentEncoding, String contentType, Map<String, String> headerFields) {
		this.connection = connection;
		this.dataStream = dataStream;
		this.statusCode = statusCode;
		this.contentEncoding = contentEncoding;
		this.contentType = contentType;
		this.headerFields = (headerFields != null) ? headerFields : EMPTY_HEADERS;