Android AbstractHttpClient - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AbstractHttpClient class.

This code example shows how to use the following methods: execute
	{ 
		if (uri.indexOf("http://") == -1)
			uri = "http://" + uri;
		boolean reached = isAvailable();
		try { 
			DefaultHttpClient httpclient = new DefaultHttpClient();
			HttpGet httpget = new HttpGet(uri);
			httpclient.execute(httpget);			
		} catch (Exception e) { 
			reached = false;
		} 
		return reached;
	} 
	 
	 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getConnectionManager, setParams, setRoutePlanner, setRedirectStrategy
  public HttpClient getHttpClient() {
    return httpClient;
  } 
 
  public HttpClient getGridHttpClient(int connection_timeout, int socket_timeout) {
    DefaultHttpClient gridClient = new DefaultHttpClient(gridClientConnectionManager);
    gridClient.setRedirectStrategy(new MyRedirectHandler());
    gridClient.setParams(getGridHttpParams(connection_timeout, socket_timeout));
    gridClient.setRoutePlanner(
        getRoutePlanner(gridClient.getConnectionManager().getSchemeRegistry()));
    gridClient.getConnectionManager().closeIdleConnections(100, TimeUnit.MILLISECONDS);
 
    return gridClient;
  } 
 
  public HttpParams getHttpParams() {
    HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setSoReuseaddr(params, true);
    HttpConnectionParams.setConnectionTimeout(params, 120 * 1000);
    HttpConnectionParams.setSoTimeout(params, TIMEOUT_THREE_HOURS);
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: execute, getCredentialsProvider
 
    @Test 
    public void testSuccessfulAuthentication(@ArquillianResource URL webAppURL) throws Exception {
        DefaultHttpClient httpClient = createHttpClient(webAppURL, "User", "User");
 
        HttpResponse httpResponse = httpClient.execute(new HttpGet(webAppURL.toURI()));
 
        assertEquals(200, httpResponse.getStatusLine().getStatusCode());
 
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
        httpResponse.getEntity().writeTo(bos);
 
        assertTrue(new String(bos.toByteArray()).contains("Welcome"));
    } 
 
    @Test 
    public void testUnsuccessfulAuthentication(@ArquillianResource URL webAppURL) throws Exception {
        DefaultHttpClient httpClient = createHttpClient(webAppURL, "Invalid User", "User");
 

8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: execute
        Assert.assertEquals("OrderModel{id=5}", EntityUtils.toString(result.getEntity()));
    } 
 
    @Test 
    public void testInvalidRequest() throws Exception { 
        DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());
 
        HttpGet get = new HttpGet(url + "myjaxrs/order/11");
        HttpResponse result = client.execute(get);
        result = client.execute(get);
 
        Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode());
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android AbstractHttpClient Questions & Answers:

See Code Examples for Android AbstractHttpClient Methods: