Package org.apache.http.impl.client

Examples of org.apache.http.impl.client.BasicResponseHandler.handleResponse()


                //System.out.println(response1.getStatusLine());
                // HttpEntity entity1 = response1.getEntity();
                // do something useful with the response body
                // and ensure it is fully consumed
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                String handleResponse = responseHandler.handleResponse(response1);
                StringReader sr = new StringReader(handleResponse);
                inputSource = new InputSource(sr);


            } finally {
View Full Code Here


                //System.out.println(response1.getStatusLine());
                // HttpEntity entity1 = response1.getEntity();
                // do something useful with the response body
                // and ensure it is fully consumed
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                String handleResponse = responseHandler.handleResponse(response1);
                StringReader sr = new StringReader(handleResponse);
                inputSource = new InputSource(sr);


            } finally {
View Full Code Here

                //System.out.println(response1.getStatusLine());
                // HttpEntity entity1 = response1.getEntity();
                // do something useful with the response body
                // and ensure it is fully consumed
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                String handleResponse = responseHandler.handleResponse(response1);
                StringReader sr = new StringReader(handleResponse);
                unmarshal = JAXB.unmarshal(sr, Application.class);
               

            } finally {
View Full Code Here

                    response = location.substring(location.lastIndexOf("/")+1);
                }
            }
            else {
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                response = responseHandler.handleResponse(httpResponse);
                throw new RestCallException(url, "Unexpected status code: " + statusCode + "\n" + response);
            }
        } catch (UnsupportedEncodingException e) {
            throw new RestCallException(e, url);
        } catch (ClientProtocolException e) {
View Full Code Here

            HttpResponse response = client.execute(get);

            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                content = responseHandler.handleResponse(response);
            }
        }
        finally {
            client.getConnectionManager().shutdown();
        }
View Full Code Here

            HttpResponse response = client.execute(post);

            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                content = responseHandler.handleResponse(response);
            }
            else {
                throw new UnexpectedHttpResponseCodeException(response.getStatusLine().getStatusCode(),
                                                              response.getStatusLine().getReasonPhrase());
            }
View Full Code Here

                post.setEntity(new StringEntity(body, "utf-8"));
            HttpResponse response = client.execute(post);

            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                content = responseHandler.handleResponse(response);
            }
            else {
                throw new UnexpectedHttpResponseCodeException(response.getStatusLine().getStatusCode(),
                                                              response.getStatusLine().getReasonPhrase());
            }
View Full Code Here

            get.setHeader("Authorization", "Bearer b6_3pfGGwEhBVmnMx7TBfdpj72FdmizX1SAGFutknc_gduJsmw0YrYmjV9_oVcGdLeXXdbUpUeld6BVfbotfEVECdgRlo_GULMgGZS0EumxrKbZFiOmnmAPChBPDZ5JP");
            HttpResponse response = client.execute(get);
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == HttpStatus.SC_OK) {
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                String content = responseHandler.handleResponse(response);
                JSONObject json = JSONObject.fromObject(content);
                JSONObject data = json.getJSONObject("data");
                JSONArray items = data.getJSONArray("items");
                for (int i=0; i<items.size(); i++) {
                    JSONObject item = items.getJSONObject(i);
View Full Code Here

    private void handleErrors(final int statusCode, final HttpResponse response, final String message) throws Exception {
        // try to extract more information from the response
        try {
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String content = responseHandler.handleResponse(response);
            JSONObject errorJson = JSONObject.fromObject(content);
            if (errorJson.has("meta")) {
                JSONObject meta = errorJson.getJSONObject("meta");
                if (meta.has("error_type")) {
                    String details = meta.has("error_detail") ? meta.getString("error_details") : "Unknown Error (no details provided)";
View Full Code Here


            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == HttpStatus.SC_OK) {
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                content = responseHandler.handleResponse(response);
            }
            else {
                // attempt to get a human-readable message
                String message = null;
                try {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.