Code example for ClientProtocolException

0
        private class StringResponseHandler implements ResponseHandler<String> {
            @Override 
            public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
                final int status_code = response.getStatusLine().getStatusCode();
                if (status_code != HttpStatus.SC_OK && status_code != HttpStatus.SC_CREATED) {
                    throw new ClientProtocolException("HTTP response returned failure. : return Http status code="
                            + Integer.toString(status_code));
                } 
 
                HttpEntity entity = response.getEntity();
                String response_str = EntityUtils.toString(entity);
                entity.consumeContent();
                return response_str;
            } 
        } 
    } 
 
    /** 
     * A class that represents GET API Request. 
     */ 
    private final class GETRequest extends APIRequest {