提交 3d645cf8 编写于 作者: A Arjen Poutsma

Added documentation on DecompressingHttpClient

Added documentation on the support for gzip encoding using the
DecompressingHttpClient in Apache HttpComponents.

Issue: SPR-7874
上级 38c8c6d0
...@@ -1125,7 +1125,7 @@ String result = ...@@ -1125,7 +1125,7 @@ String result =
<classname>HttpClient</classname> directly rewritten to use the <classname>HttpClient</classname> directly rewritten to use the
<classname>RestTemplate</classname> is shown below</para> <classname>RestTemplate</classname> is shown below</para>
<programlisting>uri = "http://example.com/hotels/{id}/bookings"; <programlisting language="java">uri = "http://example.com/hotels/{id}/bookings";
RestTemplate template = new RestTemplate(); RestTemplate template = new RestTemplate();
...@@ -1134,6 +1134,20 @@ Booking booking = // create booking object ...@@ -1134,6 +1134,20 @@ Booking booking = // create booking object
URI location = template.postForLocation(uri, booking, "1"); URI location = template.postForLocation(uri, booking, "1");
</programlisting> </programlisting>
<para>To use Apache HttpComponents instead of the native <literal>java.net</literal>
functionality, construct the <classname>RestTemplate</classname> as follows:</para>
<programlisting language="java">RestTemplate template = new RestTemplate(new HttpComponentsClientHttpRequestFactory());</programlisting>
<tip><para>Apache HttpClient supports gzip encoding via the
<classname>DecompressingHttpClient</classname>. To use it, construct a
<classname>HttpComponentsClientHttpRequestFactory</classname> like so:</para>
<programlisting language="java">HttpClient httpClient = new DecompressingHttpClient(new DefaultHttpClient());
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
RestTemplate template = new RestTemplate(requestFactory);</programlisting>
</tip>
<para>The general callback interface is <para>The general callback interface is
<interfacename>RequestCallback</interfacename> and is called when the <interfacename>RequestCallback</interfacename> and is called when the
execute method is invoked.</para> execute method is invoked.</para>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册