Example usage for org.apache.http.params BasicHttpParams BasicHttpParams

List of usage examples for org.apache.http.params BasicHttpParams BasicHttpParams

Introduction

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

Prototype

public BasicHttpParams() 

Source Link

Usage

From source file:com.devbliss.doctest.httpfactory.GetWithoutRedirectImpl.java

public HttpGet createGetRequest(URI uri) throws IOException {
    HttpGet httpGet = new HttpGet(uri);
    HttpParams params = new BasicHttpParams();
    params.setParameter(HANDLE_REDIRECTS, false);
    httpGet.setParams(params);/*from  w ww. j ava2 s .  c o  m*/
    return httpGet;
}

From source file:co.edu.uniajc.vtf.utils.RestAsyncTask.java

public RestAsyncTask(Context pContext) {
    HttpParams httpParameters = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParameters, 30000);
    HttpConnectionParams.setSoTimeout(httpParameters, 30000);
    this.coClient = new ToguisHttpClient(httpParameters, pContext);
    this.cbohasError = false;
    this.coAsyncTaskListener = new ArrayList<RestAsyncTaskListener>();
}

From source file:dk.i2m.drupal.DrupalHttpClient.java

public DrupalHttpClient() {
    BasicHttpParams params = new BasicHttpParams();
    params.setParameter(AllClientPNames.CONNECTION_TIMEOUT, 30000)
            .setParameter(AllClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH)
            .setParameter(AllClientPNames.HTTP_CONTENT_CHARSET, HTTP.UTF_8)
            .setParameter(AllClientPNames.SO_TIMEOUT, 30000);

    this.setParams(params);
}

From source file:fr.cph.stock.android.web.MyHttpClient.java

public MyHttpClient() {

    HttpParams httpParameters = new BasicHttpParams();
    int timeoutConnection = 6000;

    HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
    int timeoutSocket = 6000;

    HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
    this.setParams(httpParameters);

}

From source file:cc.nickmo.easyhttp.EasyHttp.java

public EasyHttp(SchemeRegistry schemeRegistry) {
    if (httpConf == null)
        httpConf = new EasyHttpOptions();
    BasicHttpParams httpParams = new BasicHttpParams();

    ConnManagerParams.setTimeout(httpParams, httpConf.getTimeout());
    ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(httpConf.getMaxConnection()));
    ConnManagerParams.setMaxTotalConnections(httpParams, 10);
}

From source file:it.restrung.rest.misc.HttpClientFactory.java

/**
 * Private helper to initialize an http client
 *
 * @return the initialize http client//from   w ww  . j  a v  a 2s. c o m
 */
private static synchronized DefaultHttpClient initializeClient() {
    //prepare for the https connection
    //call this in the constructor of the class that does the connection if
    //it's used multiple times
    SchemeRegistry schemeRegistry = new SchemeRegistry();

    // http scheme
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    // https scheme
    schemeRegistry.register(new Scheme("https", new FakeSocketFactory(), 443));

    HttpParams params;
    params = new BasicHttpParams();
    params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 1);
    params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(1));
    params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
    HttpClientParams.setRedirecting(params, true);
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, "utf8");

    // ignore that the ssl cert is self signed
    ThreadSafeClientConnManager clientConnectionManager = new ThreadSafeClientConnManager(params,
            schemeRegistry);

    instance = new DefaultHttpClient(clientConnectionManager, params);
    instance.setRedirectHandler(new DefaultRedirectHandler()); //If the link has a redirect
    return instance;
}

From source file:lv.vizzual.numuri.service.http.HttpProvider.java

private void init() {
    HttpParams httpParameters = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParameters, CONNECTION_TIMEOUT);

    client = new DefaultHttpClient(httpParameters);
}

From source file:mock.MockHttpClient.java

public HttpParams getParams() {
    return new BasicHttpParams();
}

From source file:hpcc.hut.edu.vn.ocr.ocrserviceconnector.HpccOcrServiceConnector.java

public static String postToOcrService(byte[] data, int size, int imgw, int imgh, String lang, int psm,
        boolean isPrePostProcess) {
    System.out.println("Sent data: w = " + imgw + ", h = " + imgh + ", psm = " + psm + ", process: "
            + isPrePostProcess + ", with lang: " + lang);
    String result = "";

    try {/*from   w  w  w . j a  va 2  s . co  m*/
        HttpParams httpParamenters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParamenters, 30000);
        DefaultHttpClient httpClient = new DefaultHttpClient(httpParamenters);
        HttpPost postRequest = new HttpPost(HOST);

        ByteArrayBody bab = new ByteArrayBody(data, "input.jpg");
        MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        reqEntity.addPart("image", bab);
        reqEntity.addPart("size", new StringBody("" + size)); // size to
        // check if
        // decompress
        // fail
        reqEntity.addPart("width", new StringBody("" + imgw));
        reqEntity.addPart("height", new StringBody("" + imgh));
        reqEntity.addPart("lang", new StringBody(lang));
        reqEntity.addPart("psm", new StringBody("" + psm));
        reqEntity.addPart("process", new StringBody("" + isPrePostProcess));

        postRequest.setEntity(reqEntity);

        HttpResponse response = httpClient.execute(postRequest);
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
        String sResponse;
        StringBuilder s = new StringBuilder();
        while ((sResponse = reader.readLine()) != null) {
            s = s.append(sResponse);
        }
        result = s.toString();
        System.out.println("result in Json: " + result);
    } catch (Exception e) {
        // handle exception here
        Log.e(e.getClass().getName(), e.getMessage());
        return null;
    }
    return result;

}

From source file:org.elegosproject.romupdater.JSONParser.java

public static InputStream getJSONData(String url) throws Exception {
    HttpParams httpParameters = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParameters, 3000);
    DefaultHttpClient httpClient = new DefaultHttpClient();
    URI uri;//from   ww w  .  j av  a2  s.com
    InputStream data = null;
    try {
        uri = new URI(url);
        HttpGet method = new HttpGet(uri);
        HttpResponse response = httpClient.execute(method);
        data = response.getEntity().getContent();
    } catch (Exception e) {
        Log.e(TAG, "Unable to download file: " + e);
        throw e;
    }
    return data;
}