org.apache.http.impl.client
Class BasicResponseHandler

java.lang.Object
  extended by org.apache.http.impl.client.BasicResponseHandler
All Implemented Interfaces:
org.apache.http.client.ResponseHandler<java.lang.String>

@Immutable
public class BasicResponseHandler
extends java.lang.Object
implements org.apache.http.client.ResponseHandler<java.lang.String>

A ResponseHandler that returns the response body as a String for successful (2xx) responses. If the response code was >= 300, the response body is consumed and an HttpResponseException is thrown. If this is used with HttpClient.execute( org.apache.http.client.methods.HttpUriRequest, ResponseHandler), HttpClient may handle redirects (3xx responses) internally.

Since:
4.0

Constructor Summary
BasicResponseHandler()
           
 
Method Summary
 java.lang.String handleResponse(org.apache.http.HttpResponse response)
          Returns the response body as a String if the response was successful (a 2xx status code).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicResponseHandler

public BasicResponseHandler()
Method Detail

handleResponse

public java.lang.String handleResponse(org.apache.http.HttpResponse response)
                                throws org.apache.http.client.HttpResponseException,
                                       java.io.IOException
Returns the response body as a String if the response was successful (a 2xx status code). If no response body exists, this returns null. If the response was unsuccessful (>= 300 status code), throws an HttpResponseException.

Specified by:
handleResponse in interface org.apache.http.client.ResponseHandler<java.lang.String>
Parameters:
response - The response to process
Returns:
A value determined by the response
Throws:
org.apache.http.client.ClientProtocolException - in case of an http protocol error
java.io.IOException - in case of a problem or the connection was aborted
org.apache.http.client.HttpResponseException