// Path: src/com/pocketreddit/library/Constants.java
// public class Constants {
//     private Constants() {
//     }
//     
//     public static final String SYSTEM_PROPERTY_USER_AGENT = "com.pocketreddit.library.useragent";
// }
// 
// Path: src/com/pocketreddit/library/utils/StreamUtils.java
// public class StreamUtils {
//     private static StreamUtils instance;
// 
//     private StreamUtils() {
//     }
// 
//     public static StreamUtils getInstance() {
//         if (instance == null) {
//             instance = new StreamUtils();
//         }
// 
//         return instance;
//     }
// 
//     public String convertStreamToString(InputStream is) throws UtilsException {
//         BufferedReader reader = new BufferedReader(new InputStreamReader(is));
//         String line;
//         StringBuilder sb = new StringBuilder();
// 
//         try {
//             while ((line = reader.readLine()) != null) {
//                 sb.append(line + "\n");
//             }
//         } catch (IOException e) {
//             throw new UtilsException("Couldn't read line from stream.", e);
//         } finally {
//             try {
//                 if (is != null)
//                     is.close();
//             } catch (IOException e) {
//                 // TODO Auto-generated catch block
//                 e.printStackTrace();
//             }
//         }
// 
//         return sb.toString();
//     }
// }
// 
// Path: src/com/pocketreddit/library/utils/UtilsException.java
// public class UtilsException extends Exception {
//     private static final long serialVersionUID = 1L;
// 
//     public UtilsException(String message) {
//         super(message);
//     }
// 
//     public UtilsException(String message, Throwable throwable) {
//         super(message, throwable);
//     }
// }


import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.List;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
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.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.SingleClientConnManager;
import org.apache.http.params.CoreProtocolPNames;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.util.Log;
import com.pocketreddit.library.Constants;
import com.pocketreddit.library.utils.StreamUtils;
import com.pocketreddit.library.utils.UtilsException;

    private JSONArray getJsonArrayFromResponse(HttpResponse response) throws IllegalStateException,
            JSONException, IOException, UtilsException {
        return new JSONArray(responseToString(response));
    }

    private String responseToString(HttpResponse response) throws IOException,
            IllegalStateException, UtilsException {
        InputStream is = null;
        try {
            is = response.getEntity().getContent();
            String content = StreamUtils.getInstance().convertStreamToString(is);

            String contentSnippet;
            if (content.length() > 250) {
                contentSnippet = content.substring(0, 100) + "###SNIPPET###"
                        + content.substring(content.length() - 100);
            } else {
                contentSnippet = content;
            }

            Log.v(TAG, "stream content: " + contentSnippet);
            return content;
        } finally {
            if (is != null)
                is.close();
        }
    }

    private JSONObject getJsonObjectFromResponse(HttpResponse response)
// Path: src/com/pocketreddit/library/Constants.java
// public class Constants {
//     private Constants() {
//     }
//     
//     public static final String SYSTEM_PROPERTY_USER_AGENT = "com.pocketreddit.library.useragent";
// }
// 
// Path: src/com/pocketreddit/library/utils/StreamUtils.java
// public class StreamUtils {
//     private static StreamUtils instance;
// 
//     private StreamUtils() {
//     }
// 
//     public static StreamUtils getInstance() {
//         if (instance == null) {
//             instance = new StreamUtils();
//         }
// 
//         return instance;
//     }
// 
//     public String convertStreamToString(InputStream is) throws UtilsException {
//         BufferedReader reader = new BufferedReader(new InputStreamReader(is));
//         String line;
//         StringBuilder sb = new StringBuilder();
// 
//         try {
//             while ((line = reader.readLine()) != null) {
//                 sb.append(line + "\n");
//             }
//         } catch (IOException e) {
//             throw new UtilsException("Couldn't read line from stream.", e);
//         } finally {
//             try {
//                 if (is != null)
//                     is.close();
//             } catch (IOException e) {
//                 // TODO Auto-generated catch block
//                 e.printStackTrace();
//             }
//         }
// 
//         return sb.toString();
//     }
// }
// 
// Path: src/com/pocketreddit/library/utils/UtilsException.java
// public class UtilsException extends Exception {
//     private static final long serialVersionUID = 1L;
// 
//     public UtilsException(String message) {
//         super(message);
//     }
// 
//     public UtilsException(String message, Throwable throwable) {
//         super(message, throwable);
//     }
// }


// Path: src/com/pocketreddit/library/net/HttpHelper.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.List;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
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.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.SingleClientConnManager;
import org.apache.http.params.CoreProtocolPNames;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.util.Log;
import com.pocketreddit.library.Constants;
import com.pocketreddit.library.utils.StreamUtils;
import com.pocketreddit.library.utils.UtilsException;


    private JSONArray getJsonArrayFromResponse(HttpResponse response) throws IllegalStateException,
            JSONException, IOException, UtilsException {
        return new JSONArray(responseToString(response));
    }

    private String responseToString(HttpResponse response) throws IOException,
            IllegalStateException, UtilsException {
        InputStream is = null;
        try {
            is = response.getEntity().getContent();
            String content = StreamUtils.getInstance().convertStreamToString(is);

            String contentSnippet;
            if (content.length() > 250) {
                contentSnippet = content.substring(0, 100) + "###SNIPPET###"
                        + content.substring(content.length() - 100);
            } else {
                contentSnippet = content;
            }

            Log.v(TAG, "stream content: " + contentSnippet);
            return content;
        } finally {
            if (is != null)
                is.close();
        }
    }

    private JSONObject getJsonObjectFromResponse(HttpResponse response)
            throws IllegalStateException, IOException, JSONException, UtilsException {