Example usage for org.apache.http.params CoreConnectionPNames CONNECTION_TIMEOUT

List of usage examples for org.apache.http.params CoreConnectionPNames CONNECTION_TIMEOUT

Introduction

In this page you can find the example usage for org.apache.http.params CoreConnectionPNames CONNECTION_TIMEOUT.

Prototype

String CONNECTION_TIMEOUT

To view the source code for org.apache.http.params CoreConnectionPNames CONNECTION_TIMEOUT.

Click Source Link

Usage

From source file:com.norconex.collector.http.client.impl.DefaultHttpClientInitializer.java

@Override
public void initializeHTTPClient(DefaultHttpClient httpClient) {

    // Time out after 30 seconds.
    //TODO Make configurable.
    httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, CONNECTION_TIMEOUT);

    // Add support for FTP websites (FTP served by HTTP server).
    Scheme ftp = new Scheme("ftp", FTP_PORT, new PlainSocketFactory());
    httpClient.getConnectionManager().getSchemeRegistry().register(ftp);

    //TODO make charset configurable instead since UTF-8 is not right
    // charset for URL specifications.  It is used here to overcome
    // so invalid redirect errors, where the redirect target URL is not 
    // URL-Encoded and has non-ascii values, and fails
    // (e.g. like ja.wikipedia.org).
    // Can consider a custom RedirectStrategy too if need be.
    httpClient.getParams().setParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET, "UTF-8");

    if (StringUtils.isNotBlank(proxyHost)) {
        httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxyHost, proxyPort));
        if (StringUtils.isNotBlank(proxyUsername)) {
            httpClient.getCredentialsProvider().setCredentials(new AuthScope(proxyHost, proxyPort),
                    new UsernamePasswordCredentials(proxyUsername, proxyPassword));
        }/*from  w  w  w .j av  a  2s  .  com*/
    }

    if (!cookiesDisabled) {
        httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
    }
    if (AUTH_METHOD_FORM.equalsIgnoreCase(authMethod)) {
        authenticateUsingForm(httpClient);
    } else if (AUTH_METHOD_BASIC.equalsIgnoreCase(authMethod)) {
        setupBasicDigestAuth(httpClient);
    } else if (AUTH_METHOD_DIGEST.equalsIgnoreCase(authMethod)) {
        setupBasicDigestAuth(httpClient);
    }
    if (userAgent != null) {
        httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, userAgent);
    }
}

From source file:com.investoday.code.util.aliyun.api.gateway.util.HttpUtil.java

/**
 * Http POST /*from   w  w w  .j a  v  a  2  s.  c o  m*/
 *
 * @param url                  http://host+path+query
 * @param headers              Http
 * @param body                 
 * @param appKey               APP KEY
 * @param appSecret            APP
 * @param timeout              
 * @param signHeaderPrefixList ???Header?
 * @return 
 * @throws Exception
 */
public static HttpResponse httpPost(String url, Map<String, String> headers, String body, String appKey,
        String appSecret, int timeout, List<String> signHeaderPrefixList) throws Exception {
    headers = initialBasicHeader(headers, appKey, appSecret, HttpMethod.POST, url, null, signHeaderPrefixList);
    HttpClient httpClient = new DefaultHttpClient();
    httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, getTimeout(timeout));

    HttpPost post = new HttpPost(url);
    for (Map.Entry<String, String> e : headers.entrySet()) {
        post.addHeader(e.getKey(), e.getValue());
    }

    if (StringUtils.isNotBlank(body)) {
        post.setEntity(new StringEntity(body, Constants.ENCODING));

    }

    return httpClient.execute(post);
}

From source file:jp.ne.sakura.kkkon.android.exceptionhandler.DefaultUploaderWeb.java

public static void upload(final Context context, final File file, final String url) {
    terminate();//from   w w  w  .  j ava 2s.  com

    thread = new Thread(new Runnable() {

        @Override
        public void run() {
            Log.d(TAG, "upload thread tid=" + android.os.Process.myTid());
            try {
                //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS)
                Log.d(TAG, "fng=" + Build.FINGERPRINT);
                final List<NameValuePair> list = new ArrayList<NameValuePair>(16);
                list.add(new BasicNameValuePair("fng", Build.FINGERPRINT));

                HttpPost httpPost = new HttpPost(url);
                //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) );
                httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8));
                DefaultHttpClient httpClient = new DefaultHttpClient();
                Log.d(TAG, "socket.timeout="
                        + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                Log.d(TAG, "connection.timeout="
                        + httpClient.getParams().getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(5 * 1000));
                httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                        new Integer(5 * 1000));
                Log.d(TAG, "socket.timeout="
                        + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                Log.d(TAG, "connection.timeout="
                        + httpClient.getParams().getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                // <uses-permission android:name="android.permission.INTERNET"/>
                // got android.os.NetworkOnMainThreadException, run at UI Main Thread
                HttpResponse response = httpClient.execute(httpPost);
                Log.d(TAG, "response=" + response.getStatusLine().getStatusCode());
            } catch (Exception e) {
                Log.d(TAG, "got Exception. msg=" + e.getMessage(), e);
            } finally {
                ExceptionHandler.clearReport();
            }
            Log.d(TAG, "upload finish");
        }
    });
    thread.setName("upload crash");

    thread.start();
    if (USE_DIALOG) {
        final AlertDialog.Builder alertDialogBuilder = setupAlertDialog(context);
        if (null != alertDialogBuilder) {
            alertDialogBuilder.setCancelable(false);

            final AlertDialog alertDialog = alertDialogBuilder.show();

            /*
            while ( thread.isAlive() )
            {
            Log.d( TAG, "thread tid=" + android.os.Process.myTid() + ",state=" + thread.getState() );
            if ( ! thread.isAlive() )
            {
                break;
            }
                    
            {
                try
                {
                    Thread.sleep( 1 * 1000 );
                }
                catch ( InterruptedException e )
                {
                    Log.d( TAG, "got exception", e );
                }
            }
                    
            if ( null != alertDialog )
            {
                if ( alertDialog.isShowing() )
                {
                }
                else
                {
                    if ( ! thread.isAlive() )
                    {
                        break;
                    }
                    alertDialog.show();
                }
            }
                    
            if ( ! Thread.State.RUNNABLE.equals(thread.getState()) )
            {
                break;
            }
                    
            }
                    
            if ( null != alertDialog )
            {
            alertDialog.dismiss();
            }
            */
        }

        try {
            thread.join(); // must call. leak handle...
            thread = null;
        } catch (InterruptedException e) {
            Log.d(TAG, "got Exception", e);
        }
    }

}

From source file:org.apache.marmotta.ldclient.services.ldclient.LDClient.java

public LDClient(ClientConfiguration config) {
    log.info("Initialising Linked Data Client Service ...");

    this.config = config;

    endpoints = new ArrayList<>();
    for (Endpoint endpoint : defaultEndpoints) {
        endpoints.add(endpoint);/*from   w  w  w .  j  ava 2  s . co  m*/
    }
    endpoints.addAll(config.getEndpoints());

    Collections.sort(endpoints);
    if (log.isInfoEnabled()) {
        for (Endpoint endpoint : endpoints) {
            log.info("- LDClient Endpoint: {}", endpoint.getName());
        }
    }

    providers = new ArrayList<>();
    for (DataProvider provider : defaultProviders) {
        providers.add(provider);
    }
    providers.addAll(config.getProviders());
    if (log.isInfoEnabled()) {
        for (DataProvider provider : providers) {
            log.info("- LDClient Provider: {}", provider.getName());
        }
    }

    retrievalSemaphore = new Semaphore(config.getMaxParallelRequests());

    if (config.getHttpClient() != null) {
        log.debug("Using HttpClient provided in the configuration");
        this.client = config.getHttpClient();
    } else {
        log.debug("Creating default HttpClient based on the configuration");

        HttpParams httpParams = new BasicHttpParams();
        httpParams.setParameter(CoreProtocolPNames.USER_AGENT, "Apache Marmotta LDClient");

        httpParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, config.getSocketTimeout());
        httpParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, config.getConnectionTimeout());

        httpParams.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, true);
        httpParams.setIntParameter(ClientPNames.MAX_REDIRECTS, 3);

        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));

        try {
            SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(null, null, null);
            SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);

            schemeRegistry.register(new Scheme("https", 443, sf));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (KeyManagementException e) {
            e.printStackTrace();
        }

        PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);
        cm.setMaxTotal(20);
        cm.setDefaultMaxPerRoute(10);

        DefaultHttpClient client = new DefaultHttpClient(cm, httpParams);
        client.setRedirectStrategy(new LMFRedirectStrategy());
        client.setHttpRequestRetryHandler(new LMFHttpRequestRetryHandler());
        idleConnectionMonitorThread = new IdleConnectionMonitorThread(client.getConnectionManager());
        idleConnectionMonitorThread.start();

        this.client = client;
    }
}

From source file:org.dspace.submit.lookup.CrossRefService.java

public List<Record> search(Context context, String title, String authors, int year, int count, String apiKey)
        throws IOException, HttpException {
    HttpGet method = null;/*from  ww w .j  a  v a2 s.  c  om*/
    try {
        HttpClient client = new DefaultHttpClient();
        client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);

        URIBuilder uriBuilder = new URIBuilder("http://search.labs.crossref.org/dois");

        StringBuilder sb = new StringBuilder();
        if (StringUtils.isNotBlank(title)) {
            sb.append(title);
        }
        sb.append(" ");
        if (StringUtils.isNotBlank(authors)) {
            sb.append(authors);
        }
        String q = sb.toString().trim();
        uriBuilder.addParameter("q", q);

        uriBuilder.addParameter("year", year != -1 ? String.valueOf(year) : "");
        uriBuilder.addParameter("rows", count != -1 ? String.valueOf(count) : "");
        method = new HttpGet(uriBuilder.build());

        // Execute the method.
        HttpResponse response = client.execute(method);
        StatusLine statusLine = response.getStatusLine();
        int statusCode = statusLine.getStatusCode();

        if (statusCode != HttpStatus.SC_OK) {
            throw new RuntimeException("Http call failed:: " + statusLine);
        }

        Gson gson = new Gson();
        Type listType = new TypeToken<ArrayList<Map>>() {
        }.getType();
        List<Map> json = gson.fromJson(
                IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8), listType);
        Set<String> dois = new HashSet<String>();
        for (Map r : json) {
            dois.add(SubmissionLookupUtils.normalizeDOI((String) r.get("doi")));
        }
        method.releaseConnection();

        return search(context, dois, apiKey);
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    } finally {
        if (method != null) {
            method.releaseConnection();
        }
    }
}

From source file:com.pipi.studio.dev.net.AsyncHttpGet.java

@Override
public void run() {
    String ret = "";
    try {/*from   w ww.  ja  v a  2s. c om*/
        if (parameter != null && parameter.size() > 0) {
            StringBuilder bulider = new StringBuilder();
            for (RequestParameter p : parameter) {
                if (bulider.length() != 0) {
                    bulider.append("&");
                }

                bulider.append(Utils.encode(p.getName()));
                bulider.append("=");
                bulider.append(Utils.encode(p.getValue()));
            }
            url += "?" + bulider.toString();
        }
        LogUtil.d(AsyncHttpGet.class.getName(), "AsyncHttpGet  request to url :" + url);
        request = new HttpGet(url);
        /*if(Constants.isGzip){
        request.addHeader("Accept-Encoding", "gzip");
          }else{
        request.addHeader("Accept-Encoding", "default");
          }*/
        //  
        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectTimeout);
        // ? 
        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, readTimeout);
        HttpResponse response = httpClient.execute(request);
        int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode == HttpStatus.SC_OK) {
            InputStream is = response.getEntity().getContent();
            BufferedInputStream bis = new BufferedInputStream(is);
            bis.mark(2);
            // ??
            byte[] header = new byte[2];
            int result = bis.read(header);
            // reset??
            bis.reset();
            // ?GZIP?
            int headerData = getShort(header);
            // Gzip ? ? 0x1f8b
            if (result != -1 && headerData == 0x1f8b) {
                LogUtil.d("HttpTask", " use GZIPInputStream  ");
                is = new GZIPInputStream(bis);
            } else {
                LogUtil.d("HttpTask", " not use GZIPInputStream");
                is = bis;
            }
            InputStreamReader reader = new InputStreamReader(is, "utf-8");
            char[] data = new char[100];
            int readSize;
            StringBuffer sb = new StringBuffer();
            while ((readSize = reader.read(data)) > 0) {
                sb.append(data, 0, readSize);
            }
            ret = sb.toString();
            bis.close();
            reader.close();

            //            ByteArrayOutputStream content = new ByteArrayOutputStream();
            //            response.getEntity().writeTo(content);
            //            ret = new String(content.toByteArray()).trim();
            //            content.close();
        } else {
            RequestException exception = new RequestException(RequestException.IO_EXCEPTION,
                    "??,??" + statusCode);
            ret = ErrorUtil.errorJson("ERROR.HTTP.001", exception.getMessage());
        }

        LogUtil.d(AsyncHttpGet.class.getName(), "AsyncHttpGet  request to url :" + url + "  finished !");

    } catch (java.lang.IllegalArgumentException e) {

        RequestException exception = new RequestException(RequestException.IO_EXCEPTION,
                Constants.ERROR_MESSAGE);
        ret = ErrorUtil.errorJson("ERROR.HTTP.002", exception.getMessage());
        LogUtil.d(AsyncHttpGet.class.getName(),
                "AsyncHttpGet  request to url :" + url + "  onFail  " + e.getMessage());
    } catch (org.apache.http.conn.ConnectTimeoutException e) {
        RequestException exception = new RequestException(RequestException.SOCKET_TIMEOUT_EXCEPTION,
                Constants.ERROR_MESSAGE);
        ret = ErrorUtil.errorJson("ERROR.HTTP.003", exception.getMessage());
        LogUtil.d(AsyncHttpGet.class.getName(),
                "AsyncHttpGet  request to url :" + url + "  onFail  " + e.getMessage());
    } catch (java.net.SocketTimeoutException e) {
        RequestException exception = new RequestException(RequestException.SOCKET_TIMEOUT_EXCEPTION,
                Constants.ERROR_MESSAGE);
        ret = ErrorUtil.errorJson("ERROR.HTTP.004", exception.getMessage());
        LogUtil.d(AsyncHttpGet.class.getName(),
                "AsyncHttpGet  request to url :" + url + "  onFail  " + e.getMessage());
    } catch (UnsupportedEncodingException e) {
        RequestException exception = new RequestException(RequestException.UNSUPPORTED_ENCODEING_EXCEPTION,
                "?");
        ret = ErrorUtil.errorJson("ERROR.HTTP.005", exception.getMessage());
        LogUtil.d(AsyncHttpGet.class.getName(),
                "AsyncHttpGet  request to url :" + url + "  UnsupportedEncodingException  " + e.getMessage());
    } catch (org.apache.http.conn.HttpHostConnectException e) {
        RequestException exception = new RequestException(RequestException.CONNECT_EXCEPTION,
                Constants.ERROR_MESSAGE);
        ret = ErrorUtil.errorJson("ERROR.HTTP.006", exception.getMessage());
        LogUtil.d(AsyncHttpGet.class.getName(),
                "AsyncHttpGet  request to url :" + url + "  HttpHostConnectException  " + e.getMessage());
    } catch (ClientProtocolException e) {
        RequestException exception = new RequestException(RequestException.CLIENT_PROTOL_EXCEPTION,
                "??");
        ret = ErrorUtil.errorJson("ERROR.HTTP.007", exception.getMessage());
        e.printStackTrace();
        LogUtil.d(AsyncHttpGet.class.getName(),
                "AsyncHttpGet  request to url :" + url + "  ClientProtocolException " + e.getMessage());
    } catch (IOException e) {
        RequestException exception = new RequestException(RequestException.IO_EXCEPTION, "??");
        ret = ErrorUtil.errorJson("ERROR.HTTP.008", exception.getMessage());
        e.printStackTrace();
        LogUtil.d(AsyncHttpGet.class.getName(),
                "AsyncHttpGet  request to url :" + url + "  IOException  " + e.getMessage());
    } finally {
        if (!Constants.IS_STOP_REQUEST) {
            Message msg = new Message();
            msg.obj = ret;
            LogUtil.d("result", ret);
            msg.getData().putSerializable("callback", callBack);
            resultHandler.sendMessage(msg);
        }
        //request.//
        if (customLoadingDialog != null && customLoadingDialog.isShowing()) {
            customLoadingDialog.dismiss();
            customLoadingDialog = null;
        }
    }
    super.run();
}

From source file:cn.tc.ulife.platform.msg.http.util.HttpUtil.java

/**
 * Http POST /*from   ww w.  j a  v  a2  s . c om*/
 * @param host
 * @param path
 * @param connectTimeout
 * @param headers
 * @param querys
 * @param body
 * @param signHeaderPrefixList
 * @param appKey
 * @param appSecret
 * @return
 * @throws Exception
 */
public static Response httpPost(String host, String path, int connectTimeout, Map<String, String> headers,
        Map<String, String> querys, String body, List<String> signHeaderPrefixList, String appKey,
        String appSecret) throws Exception {
    headers = initialBasicHeader(HttpMethod.POST, path, headers, querys, null, signHeaderPrefixList, appKey,
            appSecret);

    HttpClient httpClient = wrapClient(host);
    httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, getTimeout(connectTimeout));

    HttpPost post = new HttpPost(initUrl(host, path, querys));
    for (Map.Entry<String, String> e : headers.entrySet()) {
        post.addHeader(e.getKey(), MessageDigestUtil.utf8ToIso88591(e.getValue()));
    }

    if (StringUtils.isNotBlank(body)) {
        post.setEntity(new StringEntity(body, Constants.ENCODING));

    }

    return convert(httpClient.execute(post));
}

From source file:edu.harvard.liblab.ecru.SolrClient.java

/**
 * Creates a new HttpClient. If keyStorePath and/or trustStorePath are set, a secure client will
 * be created by reading in the keyStore and/or trustStore. In addition, system keys will also be 
 * included (i.e. those specified in the JRE).
 * //from ww w .  java 2  s  . co  m
 * Most of the code below is "borrowed" from edu.harvard.hul.ois.drs2.callservice.ServiceClient
 * 
 * @return  an HttpClient ready to roll!
 */
protected HttpClient createHttpClient() throws SolrClientException {
    // turn on SSL logging, according to Log4j settings

    DefaultHttpClient httpClient = new DefaultHttpClient();

    // set parameters
    httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectionTimeout);
    httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, socketTimeout);
    httpClient.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
    httpClient.getParams().setParameter(ClientPNames.HANDLE_AUTHENTICATION, true);

    return httpClient;
}

From source file:com.tiaoin.crawl.plugin.util.PageFetcherImpl.java

/**
 * client?Header?Cookie//from www.ja  v  a2 s .  c  o m
 * @param aconfig
 * @param cookies
 */
public void init(Site site) {
    //System.out.println(site.toString());
    if (null != site.getHeaders() && site.getHeaders().getHeader() != null) {
        for (com.tiaoin.crawl.core.xml.Header header : site.getHeaders().getHeader()) {
            this.addHeader(header.getName(), header.getValue());
        }
    }
    if (null != site.getCookies() && site.getCookies().getCookie() != null) {
        for (com.tiaoin.crawl.core.xml.Cookie cookie : site.getCookies().getCookie()) {
            this.addCookie(cookie.getName(), cookie.getValue(), cookie.getHost(), cookie.getPath());
        }
    }

    //HTTP?
    HttpParams params = new BasicHttpParams();
    params.setParameter(CoreProtocolPNames.USER_AGENT, config.getUserAgentString());
    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, config.getSocketTimeout());
    params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, config.getConnectionTimeout());

    HttpProtocolParamBean paramsBean = new HttpProtocolParamBean(params);
    paramsBean.setVersion(HttpVersion.HTTP_1_1);
    paramsBean.setContentCharset("UTF-8");
    paramsBean.setUseExpectContinue(false);

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));

    if (config.isIncludeHttpsPages())
        schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

    connectionManager = new ThreadSafeClientConnManager(schemeRegistry);
    connectionManager.setMaxTotal(config.getMaxTotalConnections());
    connectionManager.setDefaultMaxPerRoute(config.getMaxConnectionsPerHost());

    httpClient = new DefaultHttpClient(connectionManager, params);
    httpClient.getParams().setIntParameter("http.socket.timeout", 15000);
    httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);

    //?
    httpClient.addResponseInterceptor(new HttpResponseInterceptor() {
        public void process(final HttpResponse response, final HttpContext context)
                throws HttpException, IOException {
            HttpEntity entity = response.getEntity();
            Header contentEncoding = entity.getContentEncoding();
            if (contentEncoding != null) {
                HeaderElement[] codecs = contentEncoding.getElements();
                for (HeaderElement codec : codecs) {
                    //?GZIP
                    if (codec.getName().equalsIgnoreCase("gzip")) {
                        response.setEntity(new GzipDecompressingEntity(response.getEntity()));
                        return;
                    }
                }
            }
        }
    });
}

From source file:com.iloomo.net.AsyncHttpGet.java

@Override
public void run() {
    String ret = "";
    try {//from  w  w  w  . j  a  v  a2  s  .  c  o  m
        if (parameter != null && parameter.size() > 0) {
            StringBuilder bulider = new StringBuilder();
            Set<String> keys = parameter.keySet();
            for (String key : keys) {
                if (bulider.length() != 0) {
                    bulider.append("&");
                }

                bulider.append(EncodeUtils.encode(key));
                bulider.append("=");
                bulider.append(EncodeUtils.encode(String.valueOf(parameter.get(key))));
            }
            url += "?" + bulider.toString();
            Log.i("request", url);
        }
        for (int i = 0; i < HttpConstant.CONNECTION_COUNT; i++) {
            try {
                request = new HttpGet(url);
                if (HttpConstant.isGzip) {
                    request.addHeader("Accept-Encoding", "gzip");
                } else {
                    request.addHeader("Accept-Encoding", "default");
                }
                // 
                httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectTimeout);
                // ?
                httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, readTimeout);
                HttpResponse response = httpClient.execute(request);
                int statusCode = response.getStatusLine().getStatusCode();
                if (statusCode == HttpStatus.SC_OK) {
                    InputStream is = response.getEntity().getContent();
                    BufferedInputStream bis = new BufferedInputStream(is);
                    bis.mark(2);
                    // ??
                    byte[] header = new byte[2];
                    int result = bis.read(header);
                    // reset??
                    bis.reset();
                    // ?GZIP?
                    int headerData = getShort(header);
                    // Gzip ? ? 0x1f8b
                    if (result != -1 && headerData == 0x1f8b) {
                        is = new GZIPInputStream(bis);
                    } else {
                        is = bis;
                    }
                    InputStreamReader reader = new InputStreamReader(is, "utf-8");
                    char[] data = new char[100];
                    int readSize;
                    StringBuffer sb = new StringBuffer();
                    while ((readSize = reader.read(data)) > 0) {
                        sb.append(data, 0, readSize);
                    }
                    ret = sb.toString();
                    bis.close();
                    reader.close();

                    // ByteArrayOutputStream content = new
                    // ByteArrayOutputStream();
                    // response.getEntity().writeTo(content);
                    // ret = new String(content.toByteArray()).trim();
                    // content.close();
                } else {
                    ret = ErrorUtil.errorJson("" + statusCode, "??,??" + statusCode);
                    continue;
                }

                break;
            } catch (Exception e) {
                if (i == HttpConstant.CONNECTION_COUNT - 1) {
                    ret = ErrorUtil.errorJson("999", "");
                } else {
                    Log.d("connection url", "" + i);
                    continue;
                }
            }
        }

    } catch (IllegalArgumentException e) {

        RequestException exception = new RequestException(RequestException.IO_EXCEPTION,
                HttpConstant.ERROR_MESSAGE);
        ret = ErrorUtil.errorJson("999", exception.getMessage());
    } finally {
        if (!HttpConstant.IS_STOP_REQUEST) {
            Message msg = new Message();
            msg.obj = ret;
            msg.getData().putSerializable("callback", callBack);
            resultHandler.sendMessage(msg);
        }
    }
    super.run();
}