Class THttpClient

All Implemented Interfaces:
Closeable, AutoCloseable

public class THttpClient extends TEndpointTransport
HTTP implementation of the TTransport interface. Used for working with a Thrift web services implementation (using for example TServlet).

This class offers two implementations of the HTTP transport. One uses HttpURLConnection instances, the other HttpClient from Apache Http Components. The chosen implementation depends on the constructor used to create the THttpClient instance. Using the THttpClient(String url) constructor or passing null as the HttpClient to THttpClient(String url, HttpClient client) will create an instance which will use HttpURLConnection.

When using HttpClient, the following configuration leads to 5-15% better performance than the HttpURLConnection implementation:

http.protocol.version=HttpVersion.HTTP_1_1 http.protocol.content-charset=UTF-8 http.protocol.expect-continue=false http.connection.stalecheck=false

Also note that under high load, the HttpURLConnection implementation may exhaust the open file descriptor limit.

See Also: