Code example for HttpRequestBase

Methods: getURI

0
            mClientVersion = DEFAULT_CLIENT_VERSION; 
        }*/ 
    } 
 
    public <T> T doHttpRequest(HttpRequestBase httpRequest, Type type) throws ClinicException, IOException {
        if (DEBUG) LOG.log(Level.FINE, "doHttpRequest: " + httpRequest.getURI());
 
        HttpResponse response = executeHttpRequest(httpRequest);
        if (DEBUG) LOG.log(Level.FINE, "executed HttpRequest for: " + httpRequest.getURI().toString());
 
        int statusCode = response.getStatusLine().getStatusCode();
        switch (statusCode) {
            case 200: 
                String content = EntityUtils.toString(response.getEntity());
                return GsonUtils.consume(content, type);
 
            case 400: 
                if (DEBUG) LOG.log(Level.FINE, "HTTP Code: 400");
                throw new ClinicException(response.getStatusLine().toString(), EntityUtils.toString(response.getEntity()));