Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 1.06 KB

File metadata and controls

48 lines (39 loc) · 1.06 KB

#AsyncHttpClient Example GET

###Example GET

	AsyncHttpClient client = new AsyncHttpClient("http://example.com");
	client.get("api/v1/", new JsonResponseHandler()
	{
		@Override public void onSuccess()
		{
			JsonElement result = getContent();
		}
	});

###Example GET with parameters and headers

	AsyncHttpClient client = new AsyncHttpClient("http://example.com");
	List<NameValuePair> params = new ArrayList<NameValuePair>();
	params.add(new BasicNameValuePair("key", "value"));
	
	List<Header> headers = new ArrayList<Header>();
	headers.add(new BasicHeader("1", "2"));
	
	client.get("api/v1/", params, headers, new JsonResponseHandler()
	{
		@Override public void onSuccess()
		{
			JsonElement result = getContent();
		}
	});

###Example GET - Downloading a large file directly to cache

	AsyncHttpClient client = new AsyncHttpClient("http://example.com");
	
	client.get("api/v1/", new CacheResponseHandler("file.bin")
	{
		@Override public void onSuccess()
		{
			File result = getContent();
			boolean exists = result.exists();
		}
	});