// Path: opacclient/libopac/src/main/java/de/geeksfactory/opacclient/networking/HttpUtils.java
// public class HttpUtils {
//     /**
//      * Re-implementing EntityUtils.consume() as it is in different classes on Android and
//      * non-Android due to the Android backporting process of HttpClient 4
//      */
//     public static void consume(HttpEntity entity) throws IOException {
//         if (entity == null) {
//             return;
//         }
//         if (entity.isStreaming()) {
//             final InputStream instream = entity.getContent();
//             if (instream != null) {
//                 instream.close();
//             }
//         }
//     }
// }


import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.List;
import de.geeksfactory.opacclient.i18n.DummyStringProvider;
import de.geeksfactory.opacclient.networking.HttpClientFactory;
import de.geeksfactory.opacclient.networking.HttpUtils;
import de.geeksfactory.opacclient.networking.NotReachableException;
import de.geeksfactory.opacclient.networking.SSLSecurityException;
import de.geeksfactory.opacclient.objects.CoverHolder;
import de.geeksfactory.opacclient.objects.Library;
     * @param encoding      Expected encoding of the response body
     * @param ignore_errors If true, status codes above 400 do not raise an exception
     * @param cookieStore   If set, the given cookieStore is used instead of the built-in one.
     * @return Answer content
     * @throws NotReachableException Thrown when server returns a HTTP status code greater or equal
     *                               than 400.
     */
    public String httpGet(String url, String encoding, boolean ignore_errors,
            CookieStore cookieStore) throws
            IOException {

        HttpGet httpget = new HttpGet(cleanUrl(url));
        HttpResponse response;
        String html;
        httpget.setHeader("Accept", "*/*");

        try {
            if (cookieStore != null) {
                // Create local HTTP context
                HttpContext localContext = new BasicHttpContext();
                // Bind custom cookie store to the local context
                localContext.setAttribute(HttpClientContext.COOKIE_STORE,
                        cookieStore);

                response = http_client.execute(httpget, localContext);
            } else {
                response = http_client.execute(httpget);
            }

            if (!ignore_errors && response.getStatusLine().getStatusCode() >= 400) {
// Path: opacclient/libopac/src/main/java/de/geeksfactory/opacclient/networking/HttpUtils.java
// public class HttpUtils {
//     /**
//      * Re-implementing EntityUtils.consume() as it is in different classes on Android and
//      * non-Android due to the Android backporting process of HttpClient 4
//      */
//     public static void consume(HttpEntity entity) throws IOException {
//         if (entity == null) {
//             return;
//         }
//         if (entity.isStreaming()) {
//             final InputStream instream = entity.getContent();
//             if (instream != null) {
//                 instream.close();
//             }
//         }
//     }
// }


// Path: opacclient/libopac/src/main/java/de/geeksfactory/opacclient/apis/ApacheBaseApi.java
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.List;
import de.geeksfactory.opacclient.i18n.DummyStringProvider;
import de.geeksfactory.opacclient.networking.HttpClientFactory;
import de.geeksfactory.opacclient.networking.HttpUtils;
import de.geeksfactory.opacclient.networking.NotReachableException;
import de.geeksfactory.opacclient.networking.SSLSecurityException;
import de.geeksfactory.opacclient.objects.CoverHolder;
import de.geeksfactory.opacclient.objects.Library;

     * @param encoding      Expected encoding of the response body
     * @param ignore_errors If true, status codes above 400 do not raise an exception
     * @param cookieStore   If set, the given cookieStore is used instead of the built-in one.
     * @return Answer content
     * @throws NotReachableException Thrown when server returns a HTTP status code greater or equal
     *                               than 400.
     */
    public String httpGet(String url, String encoding, boolean ignore_errors,
            CookieStore cookieStore) throws
            IOException {

        HttpGet httpget = new HttpGet(cleanUrl(url));
        HttpResponse response;
        String html;
        httpget.setHeader("Accept", "*/*");

        try {
            if (cookieStore != null) {
                // Create local HTTP context
                HttpContext localContext = new BasicHttpContext();
                // Bind custom cookie store to the local context
                localContext.setAttribute(HttpClientContext.COOKIE_STORE,
                        cookieStore);

                response = http_client.execute(httpget, localContext);
            } else {
                response = http_client.execute(httpget);
            }

            if (!ignore_errors && response.getStatusLine().getStatusCode() >= 400) {
                HttpUtils.consume(response.getEntity());