Sunday, July 29, 2007

HTTP Client Review

HTTP Client from Apache (http://commons.apache.org/httpclient/) is well known api and is in use mostly for testing the web application. However over the time HTTP Client has become mature and can be integrated with any application built using Java. While I have used HTTP Client for one of the Resource Adaptor's for Mobicents http://groups.google.com/group/mobicents-public/web/mobicents-http-client-ra I didn't like the concept of Request and Response being represented by same API. For example


HttpClient client = new HttpClient();

// Create a method instance.
GetMethod method = new GetMethod("http://amitbhayani.blogspot.com/");

// Execute the method.
int statusCode = client.executeMethod(method);

//Get the Response
byte[] responseBody = method.getResponseBody();



As you can see the instance of GetMethod is used to send the request as well as receive response. This is a bit ambiguous and different api for Request and Response makes a lot of sense.

To overcome this limitation Apache is coming up with HttpCore. You can call HttpCore as advanced version of HTTPClien which has all the features of old api but in a cleaner way and also some more additions.

I am waiting for HttpCore to bit stabilize and become mature and will then integrate with Mobicents HTTP Client Resource Adaptor

No comments: