Ejemplo n.º 1
0
  public static String httpGetSSL(final String exist, String database, String android_id)
      throws IOException, HttpHostConnectException, ConnectException {
    String getUrl = "https://" + exist + ":50001/exist/rest/db/calendar/" + android_id + ".xml";
    LogHelper.logV(c, "httpGetSSL: " + getUrl);

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    //        schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(),
    // 80));
    schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpParams params = httpClient.getParams();
    ClientConnectionManager ccm = new SingleClientConnManager(params, schemeRegistry);

    httpClient =
        new DefaultHttpClient(new ThreadSafeClientConnManager(params, schemeRegistry), params);
    httpClient.setRedirectHandler(new DefaultRedirectHandler());

    HttpGet get = new HttpGet(getUrl);

    get.setHeader("Location", database + ":50082");
    get.setHeader("Connection", "close");

    HttpResponse response = httpClient.execute(get);

    HttpEntity httpEntity = response.getEntity();

    return EntityUtils.toString(httpEntity);
  }
Ejemplo n.º 2
0
  /** httpPost */
  public static String httpPost(final String url) throws IOException {

    LogHelper.logV(c, "httpPost: " + url);

    DefaultHttpClient httpClient = new DefaultHttpClient();
    ClientConnectionManager ccm = httpClient.getConnectionManager();
    HttpParams params = httpClient.getParams();

    httpClient =
        new DefaultHttpClient(
            new ThreadSafeClientConnManager(params, ccm.getSchemeRegistry()), params);
    httpClient.setRedirectHandler(new DefaultRedirectHandler());

    HttpPost post = new HttpPost(url);

    post.setHeader("Location", "localhost:50082");
    post.setHeader("Connection", "close");
    post.setHeader("Content-Type", "text/xml");

    HttpResponse response = httpClient.execute(post);

    HttpEntity httpEntity = response.getEntity();
    return EntityUtils.toString(httpEntity);
  }