Show TOC

HTTP ClientLocate this document in the navigation structure

Use

Architecture

This HTTP client implementation provides a simple and easy way to construct and execute HTTP requests to an HTTP server, retrieving data from external sites, and allows you to communicate via the HTTP protocol.

Architecture of the HTTP Client

The HTTP client implements parts of the HTTP 1.0 and HTTP 1.1 protocol versions, including:

  • HTTP request methods HEAD, GET, POST, CONNECT, DELETE, OPTIONS, TRACE, PUT.

  • WEBDAV extension methods COPY, LOCK, MKCOL, MOVE, PROPFIND, PROPPATCH, UNLOCK.

  • Automatic handling of authorization, redirection requests, cookies, connection pooling. This is done by the HTTP connection manager.

Using the HTTP Client

User

As a user of the HTTP client implementation, you have to:

  1. Reference the HTTP client implementation classes in one of the following ways:

    • through an exposed public facade (development component): tc/bl/httpclient/lib

    • ○ as a library of AS Java: library:httpclient

  2. Then, instantiate the HTTPClient class and configure it, if necessary.

  3. Instantiate an HTTP method (GET, POST, and so on).

  4. Using the HTTP client implementation, you can execute your HTTP method(s).

  5. Process the results from the request.

HTTP Client Implementation

The HTTP client implementation contains an HTTP methods processor, in which checks for authentication or redirections can be performed, and then a connection to the HTTP connection manager is started. The HTTP connection manager either opens a new connection or gets the connection from the HTTP connections pool, and connects to the HTTP server. After the HTTP method processor receives the response, it sets it to the method, from where the user can access it.

Features
  • Cookie management - allows the HTTP server to set cookies or to recall them when required. The method has a state and the cookies are held in that state. Using the HTTP client API, you can get this state.

  • Connection pooling - allows multiple users to share a set of connection objects. This is automatically performed by the connection manager in the HTTP connections pool.

  • Custom methods - you can create and send custom HTTP methods as a request to the HTTP server.

  • Stream request writing - uses the property output-stream-interceptor that enables the request body to be written directly into the stream. This is helpful if the request body is so big that your virtual machine may throw an exception that it cannot process the request, for example.

  • Pluggable connection managers - you can add custom connection management algorithms, and in this way you can change the connection manager implementation with one of your own.

  • Keep alive connection support - allows persistence connections. By default, the connection is always opened.

  • Connection timeout support - you can set a timeout for getting a connection from the connection manager (using the properties connection-timeout) for setting the timeout to wait for opening a socket, and the connection-manager-timeout for setting the time for getting an HTTP connection from the connection manager.

  • Request timeout support - you can use the socket-timeout property to set a request timeout that throws a timeout exception if there is no response.

  • Idle connections timeout support - using the HTTP client API you can set the timeout upon which all idle connections are automatically closed.

  • Logging integrated - using the Logging API you can automatically log diagnostic and security information or use the interfaces provided for applications to log their own conditions.

  • SSL support - Secure Socket Layer (SSL) protocol support, which allows Web browsers and servers to communicate over a secured connection. Note that the HTTP Client does not provide any utilities for transfer and management of SSL certificates and relies on the default JDK SSL keystore configurations.

  • Basic authentication - support for the Basic authentication scheme that requires an instance of the UserPassCredentials object to be available. After setting a user name and a password in the object, the object is sent to the client.

  • Digest authentication - support for the Digest authentication, which is more secure than the basic authentication. The support does not transfer the actual password across the network, but uses the password to encrypt a value sent from the HTTP server. The Digest authentication requires an instance of the UserPassCredentials object to be available. After setting a user name and a password in the object, the object is sent to the client.

  • NTLM authentication - support of a proprietary protocol that uses the domain name of the realm. Clients can prove their identities without sending a password to the HTTP server.

  • Proxy authentication - support for the Proxy authentication, which is similar to server authentication with the exception that the credentials for each proxy are stored independently.

  • WEBDAV - support of Web-based Distributed Authoring and Versioning. This is a set of extensions to the HTTP protocol that allows users to collaboratively edit and manage files on remote Web servers.

Activities