|
The basic object when working with HttpClient is, of course, HttpClient, as shown in Figure 3-3. This object represents a complete HTTP client, keeping track of state (e.g., cookies and authentication management), and it includes support for things like connection pooling and persistent connections. Figure 3-3. HttpClient class.To actually make a connection, create a "method" object, corresponding to the type of request desired (for example, GET, POST, PUT, OPTIONS, HEAD, etc.). The most common methods are GET (a simple URI retrieval, e.g., "http://www.cascadetg.com/") and POST (sending form data back to a URI). For more information on the other methods, you may want to consult the RFC for HTTP 1.1 at http://www.ietf.org/rfc/rfc2616.txt. The hierarchy of methods can be found in Figure 3-4. Figure 3-4. HTTP methods relationship diagram.The main methods of interest for HttpMethod and HttpUrlMethod are shown in Figure 3-5. Figure 3-5. HttpMethod interface.
You may want to inquire about the current status of the client, for example to determine the current state of the cookies that have been set. To do this, you use the HttpClient.getState() method. This returns an HttpState object, as shown in Figure 3-6. Figure 3-6. HttpState.So, to recap, you'll use an HttpClient object as a single representation of a client, you'll create an HttpMethod to make a connection, and you'll inspect the HttpState object to get data about the current client state.
|
|