Package org.apache.http.impl.client

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


    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    for (Entry<String, String> entry : params.entrySet()) {
      nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }
    method.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    String response = getHttpClient().execute(method, responseHandler);
    return response;
  }
View Full Code Here


  protected String executeWSRequest(WebserviceInvocation invocation,
      String path, List<NameValuePair> params) throws ApplicationException {
    String response = null;
    HttpGet httpGet = new HttpGet(getURI(path, params));
    httpGet.setHeader(USER_AGENT, CLIENT_INFO);
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
        try {
          long elapsedMs = -currentTimeMillis();
      response = httpClient.execute(httpGet, responseHandler);
      elapsedMs += currentTimeMillis();
      sleep(Math.max(INTERVAL_MS - elapsedMs, 0));
View Full Code Here

    }
    WSResponse wsResponse;
    HttpClient httpClient = getHttpClient();
    try {
      HttpGet httpGet = new HttpGet(getURI(params));
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String responseBody = httpClient.execute(httpGet, responseHandler);
            wsResponse = new WSResponse(responseBody);
    } catch (HttpResponseException e) {
      wsResponse = new WSResponse(isHttpRecoverable(e.getStatusCode()),
          e.getStatusCode(), e.getMessage());
View Full Code Here

    try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
      HttpPost post = new HttpPost(url);
      post.setEntity(new StringEntity(jsonPayload, "utf-8"));
      post.addHeader("Content-Type", "application/json; charset=utf-8");

      return httpClient.execute(post, new BasicResponseHandler());
    } catch (IOException e) {
      throw new LogCommunicationException("Error making POST request to " + url, e);
    }
  }
View Full Code Here

        paramsStr = "?" + URLEncodedUtils.format(params, "UTF-8");
      }
      HttpGet get = new HttpGet(url + paramsStr);
      get.addHeader("Content-Type", "application/json; charset=utf-8");

      return httpClient.execute(get, new BasicResponseHandler());
    } catch (IOException e) {
      throw new LogCommunicationException("Error making GET request to " + url, e);
    }
  }
View Full Code Here

       
        System.out.println("URL: " + final_url);
        try {
            HttpGet httpget = new HttpGet(final_url);

            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            response_body = http_client.execute(httpget, responseHandler);
        } finally {
            http_client.getConnectionManager().shutdown();
        }
       
View Full Code Here

       
        System.out.println("URL: " + final_url);
        try {
            HttpGet httpget = new HttpGet(final_url);

            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            response_body = http_client.execute(httpget, responseHandler);
        } finally {
            http_client.getConnectionManager().shutdown();
        }
       
View Full Code Here

            UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
            BasicScheme scheme = new BasicScheme();
            Header authorizationHeader = scheme.authenticate(credentials, httpGet);
            httpGet.setHeader(authorizationHeader);
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
           
            //System.out.println("Executing request: " + httpGet.getRequestLine());
            //System.out.println(response);
            response = httpclient.execute(httpGet,responseHandler);
           
View Full Code Here

        HttpGet httpget = new HttpGet("http://www.google.com/");

        System.out.println("executing request " + httpget.getURI());

        // Create a response handler
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String responseBody = httpclient.execute(httpget, responseHandler);
        System.out.println(responseBody);
       
        System.out.println("----------------------------------------");
    }
View Full Code Here

    private String getResponseBody()
        throws IOException
    {
        HttpGet httpGet = new HttpGet( getWebappUrl() );
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        return httpClient.execute( httpGet, responseHandler );
    }
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.