Package org.apache.http.client

Examples of org.apache.http.client.HttpClient


        if(lowercase.indexOf("insert")>=0&&lowercase.indexOf("into")>0 && lowercase.indexOf("values")>0)
        {
          InsertParser parser=new InsertParser();
          try {
            parser.parse(sql);
          HttpClient httpclient = new DefaultHttpClient();
          httpclient.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 60000*30);
           httpclient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF8");
          HttpPost httppost = new HttpPost("http://" + this.strurl+ "/higo/insert.jsp");
          List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
          nameValuePairs.add(new BasicNameValuePair("project",parser.tablename));
          nameValuePairs.add(new BasicNameValuePair("json", parser.jsons));

          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8"));

          HttpResponse response = httpclient.execute(httppost);

          InputStream is = response.getEntity().getContent();
          BufferedInputStream bis = new BufferedInputStream(is);
          ByteArrayBuffer baf = new ByteArrayBuffer(1024);

View Full Code Here


//        text=DownLoad.result(parser.tablename, "", parser.start, parser.rows, parser.queryStr, "",  parser.fl, parser.groupby, parser.sort, parser.order).trim();
//      } catch (Exception e) {
//        throw new IOException(e);
//      }
    } else {
      HttpClient httpclient = new DefaultHttpClient();
      httpclient.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 60000*30);
       httpclient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF8");
      HttpPost httppost = new HttpPost("http://" + this.strurl
          + "/higo/result.jsp");
      List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
      nameValuePairs.add(new BasicNameValuePair("project",parser.tablename));
      nameValuePairs.add(new BasicNameValuePair("start", parser.start));
      nameValuePairs.add(new BasicNameValuePair("rows", parser.rows));
      nameValuePairs.add(new BasicNameValuePair("fl", parser.fl));
      if (parser.queryStr != null) {
        nameValuePairs
            .add(new BasicNameValuePair("q", parser.queryStr));
      }
      if (parser.groupby != null) {
        nameValuePairs.add(new BasicNameValuePair("groupby",
            parser.groupby));
      }
      if (parser.sort != null) {
        nameValuePairs.add(new BasicNameValuePair("sort", parser.sort));
      }
      if (parser.order != null) {
        nameValuePairs
            .add(new BasicNameValuePair("order", parser.order));
      }

      httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8"));

      HttpResponse response = httpclient.execute(httppost);

      InputStream is = response.getEntity().getContent();
      BufferedInputStream bis = new BufferedInputStream(is);
      ByteArrayBuffer baf = new ByteArrayBuffer(1024);

View Full Code Here

    private String getData(String url, int timeoutSeconds, int retries) throws TranslatableException {
        // Try to get the data.
        String data;
        while (true) {
            HttpClient client = Common.getHttpClient(timeoutSeconds * 1000);
            HttpGet request = null;
            TranslatableMessage message;

            try {
                request = new HttpGet(url);
                HttpResponse response = client.execute(request);
                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                    data = HttpUtils4.readResponseBody(response);
                    break;
                }
                message = new TranslatableMessage("event.http.response", url, response.getStatusLine().getStatusCode());
View Full Code Here

public class TestGooglePlayCrawler {

  private static GooglePlayAPI service;

  private static HttpClient getProxiedHttpClient(String host, Integer port) throws Exception {
    HttpClient client = new DefaultHttpClient(GooglePlayAPI.getConnectionManager());
    client.getConnectionManager().getSchemeRegistry().register(Utils.getMockedScheme());
    HttpHost proxy = new HttpHost(host, port);
    client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    return client;
  }
View Full Code Here

    }

    private void createLoginableService(String androidid, String email, String password, String localization) throws Exception {
  service = new GooglePlayAPI(email, password, androidid);
  service.setLocalization(localization);
  HttpClient proxiedHttpClient = getProxiedHttpClient();
  if (proxiedHttpClient != null) {
      service.setClient(proxiedHttpClient);
  }
    }
View Full Code Here

    }

    private void createCheckinableService(String email, String password, String localization) throws Exception {
  service = new GooglePlayAPI(email, password);
  service.setLocalization(localization);
  HttpClient proxiedHttpClient = getProxiedHttpClient();
  if (proxiedHttpClient != null) {
      service.setClient(proxiedHttpClient);
  }
    }
View Full Code Here

  return null;
    }

    private static HttpClient getProxiedHttpClient(String host, Integer port) throws Exception {
  HttpClient client = new DefaultHttpClient(GooglePlayAPI.getConnectionManager());
  client.getConnectionManager().getSchemeRegistry().register(Utils.getMockedScheme());
  HttpHost proxy = new HttpHost(host, port);
  client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
  return client;
    }
View Full Code Here

        String url = "/datastreams/" + getGUID() + "?auth_key=" + getAuthKey();
        return callURI(url);
    }
   
    private String callURI(String p_url) throws ClientProtocolException, IOException {
        HttpClient http_client = new DefaultHttpClient();
        String response_body = "";
        String final_url = this.base_uri + p_url;
       
        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();
        }
       
        return response_body;
    }
View Full Code Here

        String url = "/datastreams/" + getGUID() + "?auth_key=" + getAuthKey();
        return callURI(url);
    }
   
    private String callURI(String p_url) throws ClientProtocolException, IOException {
        HttpClient http_client = new DefaultHttpClient();
        String response_body = "";
        String final_url = this.base_uri + p_url;
       
        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();
        }
       
        return response_body;
    }
View Full Code Here

        HttpActionDefinition definition = (HttpActionDefinition) actionDefinition;

        LOGGER.debug("HTTP query will be executed on node [{}]", nodeAddress);

        HttpClient httpClient = composeHttpClient(definition);

        try {
            return processHttpClient(definition, httpClient, scheduleExecutionId, nodeAddress);
        } catch (Exception e) {
            LOGGER.debug("Fail to process HTTP request", e);
            return produceExceptionalResult(e);
        } finally {
            httpClient.getConnectionManager().shutdown();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.http.client.HttpClient

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.