/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  android.util.Log
 *  java.io.BufferedReader
 *  java.io.InputStream
 *  java.io.InputStreamReader
 *  java.io.Reader
 *  java.lang.Exception
 *  java.lang.Object
 *  java.lang.RuntimeException
 *  java.lang.String
 *  java.lang.Throwable
 *  java.net.HttpURLConnection
 *  java.net.URL
 *  java.net.URLConnection
 *  java.util.List
 *  org.apache.http.HttpEntity
 *  org.apache.http.HttpResponse
 *  org.apache.http.StatusLine
 *  org.apache.http.client.entity.UrlEncodedFormEntity
 *  org.apache.http.client.methods.HttpGet
 *  org.apache.http.client.methods.HttpPost
 *  org.apache.http.client.methods.HttpUriRequest
 *  org.apache.http.impl.client.DefaultHttpClient
 *  org.apache.http.params.HttpParams
 *  org.apache.http.util.EntityUtils
 */
package com.xinli.portalclient.util;

import android.util.Log;
import com.google.code.microlog4android.Logger;
import com.google.code.microlog4android.LoggerFactory;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
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.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EntityUtils;

public class HttpUtils {
    private static String USER_AGENT = "wifikeeper/0.9.1 ( linux; u: android ; build :cs)";
    private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);

    /*
     * Loose catch block
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     * Lifted jumps to return sites
     */
    public static String getContentByHttp(String string2) {
        String string3 = "";
        URL uRL = new URL(string2);
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection)uRL.openConnection();
            InputStreamReader inputStreamReader = new InputStreamReader(httpURLConnection.getInputStream());
            BufferedReader bufferedReader = new BufferedReader((Reader)inputStreamReader);
            do {
                String string4;
                String string5;
                if ((string5 = bufferedReader.readLine()) == null) {
                    inputStreamReader.close();
                    httpURLConnection.disconnect();
                    return string3;
                }
                string3 = string4 = String.valueOf((Object)string3) + string5;
            } while (true);
        }
        catch (Exception var3_9) {
            return string3;
        }
        catch (Exception exception) {
            return string3;
        }
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    public static String requestHttpGet(String string2, String string3, String string4) {
        Log.v((String)"client", (String)("\u6d4b\u8bd5\u8c03\u7528HTTPClient\u5411\u670d\u52a1\u5668\u53d1\u9001\u6570\u636e\uff01" + string2));
        try {
            HttpGet httpGet = new HttpGet(String.valueOf((Object)string2) + string4);
            httpGet.setHeader("Cookie", string3);
            DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
            defaultHttpClient.getParams().setParameter("http.connection.timeout", (Object)5000);
            defaultHttpClient.getParams().setParameter("http.socket.timeout", (Object)10000);
            HttpResponse httpResponse = defaultHttpClient.execute((HttpUriRequest)httpGet);
            logger.debug("getStatusCode()====" + httpResponse.getStatusLine().getStatusCode());
            if (httpResponse.getStatusLine().getStatusCode() == 200) {
                String string5 = EntityUtils.toString((HttpEntity)httpResponse.getEntity(), (String)"GBK");
                logger.info("\u8bf7\u6c42\u8fd4\u56de\u7ed3\u679c\u6210\u529f\uff1a" + string5);
                Log.v((String)"client", (String)"HttpGet\u65b9\u5f0f\u8bf7\u6c42\u6210\u529f!");
                return string5;
            }
            logger.info("\u8bf7\u6c42\u8fd4\u56de\u7ed3\u679c\u5931\u8d25");
            Log.v((String)"client", (String)"HttpGet\u65b9\u5f0f\u8bf7\u6c42\u5931\u8d25");
            return null;
        }
        catch (Exception var5_7) {
            logger.error("\u8bf7\u6c42\u53d1\u751f\u5f02\u5e38\uff1a" + (Object)var5_7);
            var5_7.printStackTrace();
            throw new RuntimeException(var5_7.getMessage());
        }
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    public static String sendContentByHttpClient(String string2, String string3, List list) throws Exception {
        Log.v((String)"client", (String)("\u5411\u670d\u52a1\u5668\u53d1\u9001\u6570\u636e\uff01" + string2));
        logger.info("\u5411\u670d\u52a1\u5668\u53d1\u9001\u6570\u636e\uff01" + string2);
        HttpPost httpPost = new HttpPost(string2);
        try {
            httpPost.setEntity((HttpEntity)new UrlEncodedFormEntity(list, "UTF-8"));
            httpPost.setHeader("Cookie", string3);
            DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
            defaultHttpClient.getParams().setParameter("http.connection.timeout", (Object)5000);
            defaultHttpClient.getParams().setParameter("http.socket.timeout", (Object)10000);
            HttpResponse httpResponse = defaultHttpClient.execute((HttpUriRequest)httpPost);
            if (httpResponse.getStatusLine().getStatusCode() == 200) {
                String string4 = EntityUtils.toString((HttpEntity)httpResponse.getEntity(), (String)"GBK");
                Log.v((String)"client", (String)"HttpPost\u65b9\u5f0f\u8bf7\u6c42\u6210\u529f!");
                return string4;
            }
            Log.v((String)"client", (String)"HttpPost\u65b9\u5f0f\u8bf7\u6c42\u5931\u8d25");
            return null;
        }
        catch (Exception var5_7) {
            logger.info("\u8bf7\u6c42\u670d\u52a1\u5f02\u5e38" + (Object)var5_7);
            Log.e((String)"\u8bf7\u6c42\u670d\u52a1\u5f02\u5e38", (String)var5_7.getCause().toString());
            throw new RuntimeException(var5_7.getMessage());
        }
    }
}

