From 3d645cf80854ebad53cd0ae85995f36a5a4d46ea Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Wed, 28 Aug 2013 14:09:07 +0200 Subject: [PATCH] Added documentation on DecompressingHttpClient Added documentation on the support for gzip encoding using the DecompressingHttpClient in Apache HttpComponents. Issue: SPR-7874 --- src/reference/docbook/remoting.xml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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. -- GitLab