Package org.apache.http.impl.client

Examples of org.apache.http.impl.client.BasicResponseHandler


                    String location = locations[0].getValue();
                    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


            get.setHeader("Authorization", "Basic " + encodedPassword);

            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

        }
        return content;
    }

    public static String fetch(String url) throws IOException, UnexpectedHttpResponseCodeException {
        return fetch(url, new BasicResponseHandler());
    }
View Full Code Here

            post.setEntity(new UrlEncodedFormEntity(nameValuePairs, "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

            if (body!=null)
                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

            HttpGet get = new HttpGet(String.format("https://jawbone.com/nudge/api/v.1.0/users/@me/moves?start_time=%s&updated_after=%s", beginningOfTime, "1391432752"));
            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

                    new UsernamePasswordCredentials(proxyUser, proxyPass));
        }
        HttpGet httpGet = new HttpGet(uri);

        // Create a response handler
        ResponseHandler<String> responseHandler = new BasicResponseHandler();

        try {
            responseBody = httpClient.execute(httpGet, responseHandler);
        } catch (IOException ioe) {
            LOG.error("Could not get data from URL '" + URI + "'", ioe);
View Full Code Here

        HttpClient client = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(url.toString());

        if (consumer != null) consumer.sign(httpget);

        return client.execute(httpget, new BasicResponseHandler());
    }
View Full Code Here

        }

        if (consumer != null) consumer.sign(httppost);

        HttpClient client = new DefaultHttpClient();
        return client.execute(httppost, new BasicResponseHandler());
    }
View Full Code Here

TOP

Related Classes of org.apache.http.impl.client.BasicResponseHandler

Copyright © 2018 www.massapicom. 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.