Package org.exoplatform.common.http.client

Examples of org.exoplatform.common.http.client.HTTPConnection


      {
         Thread.sleep(waitTime);

         // execute the GET
         URL url = new URL(sURL);
         connection = new HTTPConnection(url);
         connection.removeModule(CookieModule.class);

         connection.addBasicAuthorization(BaseTestCaseChecker.TEST_REALM, login, password);

         HTTPResponse resp = connection.Get(url.getFile());
View Full Code Here


   public static HTTPConnection getAuthConnection(WebDavConfig config)
   {

      CookieModule.setCookiePolicyHandler(null);

      HTTPConnection connection = new HTTPConnection(config.getHost(), config.getPort());
      connection.addBasicAuthorization(WebDav.REALM, config.getUserId(), config.getUserPass());

      return connection;
   }
View Full Code Here

            testConfig.setRepository(repository);
            testConfig.setWorkSpace(workSpace);
            testConfig.setUserId(userId);
            testConfig.setUserPass(userPass);

            HTTPConnection connection = WebDavUtils.getAuthConnection(testConfig);

            String filePath = WebDavUtils.getFullPath(testConfig);
            HTTPResponse response = connection.Head(filePath);

            LOG.info("Testing connection....");

            int status = response.getStatusCode();
View Full Code Here

      ProtocolNotSuppException, IOException, ModuleException, ParseException
   {
      URL url_obj = null;
      url_obj = new URL(url);

      conn = new HTTPConnection(url_obj);
      conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
      prepareRequestHeaders(httpRequest);
      prepareFormParams(url_obj);
      conn.setAllowUserInteraction(false);
      resp = conn.Get(url_obj.getProtocol() + "://" + url_obj.getAuthority() + url_obj.getPath(), form_data, headers);
View Full Code Here

      ProtocolNotSuppException, IOException, ModuleException, ParseException
   {
      URL url_obj = null;
      url_obj = new URL(url);

      conn = new HTTPConnection(url_obj);
      conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
      conn.setAllowUserInteraction(false);
      prepareRequestHeaders(httpRequest);

      byte[] body = new byte[httpRequest.getContentLength()];
View Full Code Here

      ProtocolNotSuppException, IOException, ModuleException, ParseException
   {
      URL url_obj = null;
      url_obj = new URL(url);

      conn = new HTTPConnection(url_obj);
      conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
      conn.setAllowUserInteraction(false);
      prepareRequestHeaders(httpRequest);

      byte[] body = new byte[httpRequest.getContentLength()];
View Full Code Here

      ProtocolNotSuppException, IOException, ModuleException, ParseException
   {
      URL url_obj = null;
      url_obj = new URL(url);

      conn = new HTTPConnection(url_obj);
      conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
      conn.setAllowUserInteraction(false);
      prepareRequestHeaders(httpRequest);
      resp = conn.Delete(url_obj.getProtocol() + "://" + url_obj.getAuthority() + url_obj.getPath(), headers);
      if (resp.getStatusCode() >= 300)
View Full Code Here

         throw new WebApplicationException(e, createErrorResponse(e, 404));
      }
      try
      {
         URL url = new URL(urlParam);
         HTTPConnection conn = new HTTPConnection(url);
         conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
         NVPair[] headerPairs = toNVPair(headers.getRequestHeaders(), //
            Collections.singleton(new CaseInsensitiveStringWrapper(HttpHeaders.HOST)));
         conn.setAllowUserInteraction(false);
         NVPair credentials = getCredentials(url);
         if (credentials != null)
         {
            conn.addBasicAuthorization(null, credentials.getName(), credentials.getValue());
         }
         HTTPResponse resp = conn.Delete(url.getFile(), headerPairs);
         if (resp.getStatusCode() >= 300)
         {
            if (LOG.isDebugEnabled())
            {
               // Do not read data if debug is off.
View Full Code Here

         throw new WebApplicationException(e, createErrorResponse(e, 404));
      }
      try
      {
         URL url = new URL(urlParam);
         HTTPConnection conn = new HTTPConnection(url);
         conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
         NVPair[] headerPairs = toNVPair(headers.getRequestHeaders(), //
            Collections.singleton(new CaseInsensitiveStringWrapper(HttpHeaders.HOST)));
         conn.setAllowUserInteraction(false);
         NVPair credentials = getCredentials(url);
         if (credentials != null)
         {
            conn.addBasicAuthorization(null, credentials.getName(), credentials.getValue());
         }
         HTTPResponse resp = conn.Get(url.getFile(), (NVPair[])null, headerPairs);
         if (resp.getStatusCode() >= 300)
         {
            if (LOG.isDebugEnabled())
            {
               // Do not read data if debug is off.
View Full Code Here

      }

      try
      {
         URL url = new URL(urlParam);
         HTTPConnection conn = new HTTPConnection(url);
         conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
         NVPair[] headerPairs = toNVPair(headers.getRequestHeaders(), //
            Collections.singleton(new CaseInsensitiveStringWrapper(HttpHeaders.HOST)));
         conn.setAllowUserInteraction(false);
         NVPair credentials = getCredentials(url);
         if (credentials != null)
         {
            conn.addBasicAuthorization(null, credentials.getName(), credentials.getValue());
         }
         HTTPResponse resp = null;
         if (entity != null)
         {
            HttpOutputStream stream = new HttpOutputStream();
            resp = conn.Post(url.getFile(), stream, headerPairs);
            byte[] buf = new byte[1024];
            int r = -1;
            while ((r = entity.read(buf)) != -1)
            {
               stream.write(buf, 0, r);
            }
            stream.close();
         }
         else
         {
            resp = conn.Post(url.getFile(), (NVPair[])null, headerPairs);
         }

         if (resp.getStatusCode() >= 300)
         {
            if (LOG.isDebugEnabled())
View Full Code Here

TOP

Related Classes of org.exoplatform.common.http.client.HTTPConnection

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.