diff --git a/src/reference/docbook/remoting.xml b/src/reference/docbook/remoting.xml index b65cd7b59a..1af73d50ec 100644 --- a/src/reference/docbook/remoting.xml +++ b/src/reference/docbook/remoting.xml @@ -1125,7 +1125,7 @@ String result = HttpClient directly rewritten to use the RestTemplate is shown below - uri = "http://example.com/hotels/{id}/bookings"; + uri = "http://example.com/hotels/{id}/bookings"; RestTemplate template = new RestTemplate(); @@ -1134,6 +1134,20 @@ Booking booking = // create booking object URI location = template.postForLocation(uri, booking, "1"); + To use Apache HttpComponents instead of the native java.net + functionality, construct the RestTemplate as follows: + + RestTemplate template = new RestTemplate(new HttpComponentsClientHttpRequestFactory()); + + Apache HttpClient supports gzip encoding via the + DecompressingHttpClient. To use it, construct a + HttpComponentsClientHttpRequestFactory like so: + + HttpClient httpClient = new DecompressingHttpClient(new DefaultHttpClient()); +ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); +RestTemplate template = new RestTemplate(requestFactory); + + The general callback interface is RequestCallback and is called when the execute method is invoked.