

Adding DependenciesĪt a minimum you will need to add the core HTTP client library:įor the purposes of this example we will add a couple more libraries: google-http-client-jackson2 and :gson. You should see success if your project was created correctly 2.1. Let’s start by creating a new Maven project (you have the m2e plugin installed, right?). We’ll be using Eclipse as our IDE of choice and Maven for dependency management. One of the beauties of Google’s HTTP library is that as your code moves from one Java platform to another, all you might have to change is your choice of HttpTransport: the rest of your code remains unchanged! 2. Apache’s HttpClient is a well-known and popular choice and if you are writing code for running on App Engine, then Url Fetch is your only choice. might be the weapon of choice if you don’t want to add any dependencies. Your choice might be dictated by the limitations/issues of your Java platform (if any).

When you start to use Google’s HTTP client library, the first choice you have to make is which client implementation to use (remember, this client library is just an abstraction). A gentle introduction to the use of the library it is not, and that is the gap that this article fills.

The only downside is that the official documentation on it is minimal & only covers the major points. It offers a well-designed abstraction layer over a number of lower level HTTP client implementations (we’ll talk more about this later). Google’s HTTP Client Library for Java is a one-stop shop for all your HTTP client needs, irrespective of the Java platform (application server, Android, App Engine etc.).
