1) AS ciasteczka, zobaczyć, że exapmle:
httpcomponents-client-4.1.3 \ przykłady \ org \ apache \ http \ examples \ klient ClientCustomContext.java
główny kod \:
HttpClient httpclient = new DefaultHttpClient();
try {
// Create a local instance of cookie store
CookieStore cookieStore = new BasicCookieStore();
// Create local HTTP context
HttpContext localContext = new BasicHttpContext();
// Bind custom cookie store to the local context
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
HttpGet httpget = new HttpGet("http://www.google.com/");
System.out.println("executing request " + httpget.getURI());
// Pass local context as a parameter
HttpResponse response = httpclient.execute(httpget, localContext);
} finally {
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}
2) można dostać wszystko, czego potrzebujesz od odpowiedzi i:
HttpEntity entity = response.getEntity();
entity.getContent()
Wystarczy przeczytać przykłady w: httpcomponents-client-4.1.3 \ examples \ org \ apache \ http \ examples \ client z httpcomponents-client-4.1.3-bin.zip, który jest pobrany z jego website.