|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
AuthenticationHandler | /** A handler for determining if an HTTP response represents an authentication challenge that was sent back to the client as a result of authentication failure. |
CookieStore | This interface represents an abstract store for Cookie
objects. |
CredentialsProvider | Abstract credentials provider that maintains a collection of user credentials. |
HttpClient | This interface represents only the most basic contract for HTTP request execution. |
HttpRequestRetryHandler | A handler for determining if an HttpRequest should be retried after a recoverable exception during execution. |
RedirectHandler | A handler for determining if an HTTP request should be redirected to a new location in response to an HTTP response received from the target server. |
RequestDirector | A client-side request director. |
ResponseHandler<T> | Handler that encapsulates the process of generating a response object
from a HttpResponse . |
UserTokenHandler | A handler for determining if the given execution context is user specific or not. |
Exception Summary | |
---|---|
CircularRedirectException | Signals a circular redirect |
ClientProtocolException | Signals an error in the HTTP protocol. |
HttpResponseException | Signals a non 2xx HTTP response. |
NonRepeatableRequestException | Signals failure to retry the request due to non-repeatable request entity. |
RedirectException | Signals violation of HTTP specification caused by an invalid redirect |
The API for client-side HTTP communication.
The usual execution flow can be demonstrated by the code snippet below:HttpClient httpclient = new DefaultHttpClient(); // Prepare a request object HttpGet httpget = new HttpGet("http://www.apache.org/"); // Execute the request HttpResponse response = httpclient.execute(httpget); // Examine the response status System.out.println(response.getStatusLine()); // Get hold of the response entity HttpEntity entity = response.getEntity(); // If the response does not enclose an entity, there is no need // to worry about connection release if (entity != null) { InputStream instream = entity.getContent(); try { BufferedReader reader = new BufferedReader( new InputStreamReader(instream)); // do something useful with the response System.out.println(reader.readLine()); } catch (IOException ex) { // In case of an IOException the connection will be released // back to the connection manager automatically throw ex; } catch (RuntimeException ex) { // In case of an unexpected exception you may want to abort // the HTTP request in order to shut down the underlying // connection and release it back to the connection manager. httpget.abort(); throw ex; } finally { // Closing the input stream will trigger connection release instream.close(); } }
|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |