Package org.apache.http.client

Examples of org.apache.http.client.HttpClient


      url[4] = SERVER_URL+"/auth/ajax/worklist?action=get";


  for(int i = 0; i < 3; i++) {
  try {       
    HttpClient client = new DefaultHttpClient()
    HttpGet get = new HttpGet(url[i]);
    get.setHeader("Cookie", "user=kevin.lam92@gmail.com;auth=e3eeba822df43aaa86abe30bb320b082");
    get.addHeader("Accept", "application/xml");
    get.addHeader("Content-Type", "application/xml");
    HttpResponse responsePost;
    responsePost = client.execute(get);
    HttpEntity resEntity = responsePost.getEntity();
        if (resEntity != null)  {
          results[i] = resEntity.getContentLength();
          System.out.println(results[i]);
        }
View Full Code Here


   * Check connection for sanity.
   */
  @Override
  public String check()
    throws ManifoldCFException {
    HttpClient client = getClient();
    try {
      CheckThread checkThread = new CheckThread(client, genericEntryPoint + "?" + ACTION_PARAM_NAME + "=" + ACTION_CHECK);
      checkThread.start();
      checkThread.join();
      if (checkThread.getException() != null) {
View Full Code Here

   */
  @Override
  public AuthorizationResponse getAuthorizationResponse(String userName)
    throws ManifoldCFException {

    HttpClient client = getClient();
    // Construct a cache description object
    ICacheDescription objectDescription = new GenericAuthorizationResponseDescription(userName,
      createCacheConnectionString(), this.responseLifetime, this.LRUsize);

    // Enter the cache
View Full Code Here

        schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));

        ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);
        cm.setMaxTotal(clients);

        final HttpClient httpClient = new DefaultHttpClient(cm);

        ExecutorService executor = Executors.newFixedThreadPool(clients);

        CountDownLatch startGate = new CountDownLatch(1);
        CountDownLatch endGate = new CountDownLatch(clients);
View Full Code Here

      if (ingestProtocol != null)
      {
        String contextMsg = "for document access";
        String ingestHttpAddress = ingestCgiPath;

        HttpClient client = getInitializedClient(contextMsg);
        HttpGet method = new HttpGet(getHost().toURI() + ingestHttpAddress);
        method.setHeader(new BasicHeader("Accept","*/*"));
        try
        {
          int statusCode = executeMethodViaThread(client,method);
View Full Code Here

              String ingestHttpAddress = convertToIngestURI(documentIdentifier);
              if (ingestHttpAddress != null)
              {

                // Set up connection
                HttpClient client = getInitializedClient(contextMsg);

                long currentTime;

                if (Logging.connectors.isInfoEnabled())
                  Logging.connectors.info("Livelink: " + ingestHttpAddress);
View Full Code Here

        cacheConfig.setMaxObjectSizeBytes(262144); //256kb

        ResourceFactory resourceFactory = new FileResourceFactory(cacheDir);
        HttpCacheStorage httpCacheStorage = new ManagedHttpCacheStorage(cacheConfig);

        HttpClient client = EasyMock.createMock(HttpClient.class);
        HttpGet get = new HttpGet("http://somehost/");
        HttpContext context = new BasicHttpContext();
        HttpHost target = new HttpHost("somehost");

        Date now = new Date();
        Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
       
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.setEntity(HttpTestUtils.makeBody(128));
        response.setHeader("Content-Length", "128");
        response.setHeader("ETag", "\"etag\"");
        response.setHeader("Cache-Control", "public, max-age=3600");
        response.setHeader("Last-Modified", DateUtils.formatDate(tenSecondsAgo));
       
        EasyMock.expect(client.execute(
                EasyMock.eq(target),
                EasyMock.isA(HttpRequest.class),
                EasyMock.same(context))).andReturn(response);
        EasyMock.replay(client);
       
        CachingHttpClient t = new CachingHttpClient(client, resourceFactory, httpCacheStorage, cacheConfig);

        HttpResponse response1 = t.execute(get, context);
        Assert.assertEquals(200, response1.getStatusLine().getStatusCode());
        EntityUtils.consume(response1.getEntity());
       
        EasyMock.verify(client);
       
        removeCache();

        EasyMock.reset(client);
        EasyMock.expect(client.execute(
                EasyMock.eq(target),
                EasyMock.isA(HttpRequest.class),
                EasyMock.same(context))).andReturn(response);
        EasyMock.replay(client);
       
View Full Code Here

    return cl;
  }

  @Override
  public String check() throws ManifoldCFException {
    HttpClient client = getClient();
    try {
      CheckThread checkThread = new CheckThread(client, genericEntryPoint + "?" + ACTION_PARAM_NAME + "=" + ACTION_CHECK);
      checkThread.start();
      checkThread.join();
      if (checkThread.getException() != null) {
View Full Code Here

  @Override
  public void addSeedDocuments(ISeedingActivity activities, DocumentSpecification spec,
    long startTime, long endTime)
    throws ManifoldCFException, ServiceInterruption {

    HttpClient client = getClient();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

    StringBuilder url = new StringBuilder(genericEntryPoint);
    url.append("?").append(ACTION_PARAM_NAME).append("=").append(ACTION_SEED);
    if (startTime > 0) {
View Full Code Here

        genericAuthMode = sn.getValue();
        break;
      }
    }

    HttpClient client = getClient();
    StringBuilder url = new StringBuilder(genericEntryPoint);
    try {
      url.append("?").append(ACTION_PARAM_NAME).append("=").append(ACTION_ITEMS);
      for (int i = 0; i < documentIdentifiers.length; i++) {
        url.append("&id[]=").append(URLEncoder.encode(documentIdentifiers[i], "UTF-8"));
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.