Package com.dotcms.repackage.org.apache.commons.httpclient

Examples of com.dotcms.repackage.org.apache.commons.httpclient.HttpClient


          }
      }).when(req).setAttribute(Mockito.eq("requestCode"),Mockito.any(String.class));

      LicenseUtil.processForm(req);
     
      HttpClient client=new HttpClient();
      PostMethod post=new PostMethod("https://my.dotcms.com/app/licenseRequest3");
      post.setRequestBody(new NameValuePair[] { new NameValuePair("code", reqcode.toString()) });
      client.executeMethod(post);
     
      if(post.getStatusCode()==200){
        license = post.getResponseBodyAsString();
        HttpServletRequest req2=Mockito.mock(HttpServletRequest.class);
        Mockito.when(req2.getParameter("iwantTo")).thenReturn("paste_license");
View Full Code Here


        pars.put( "level", Long.toString(LicenseUtil.getLevel()));
        if ( LicenseUtil.getSerial() != null ) {
            pars.put( "license", LicenseUtil.getSerial() );
        }

        HttpClient client = new HttpClient();

        PostMethod method = new PostMethod( fileUrl );
        Object[] keys = (Object[]) pars.keySet().toArray();
        NameValuePair[] data = new NameValuePair[keys.length];
        for ( int i = 0; i < keys.length; i++ ) {
            String key = (String) keys[i];
            NameValuePair pair = new NameValuePair( key, pars.get( key ) );
            data[i] = pair;
        }

        method.setRequestBody( data );
        String ret = null;

        try {
            client.executeMethod( method );
            int retCode = method.getStatusCode();
            if ( retCode == 204 ) {
                Logger.info( UpdateUtil.class, "No new updates found" );
            } else {
                if ( retCode == 200 ) {
View Full Code Here

    byte[] byteArray = null;

    HttpMethod method = null;

    try {
      HttpClient client =
        new HttpClient(new SimpleHttpConnectionManager());

      if (location == null) {
        return byteArray;
      }
      else if (!location.startsWith(HTTP_WITH_SLASH) &&
           !location.startsWith(HTTPS_WITH_SLASH)) {

        location = HTTP_WITH_SLASH + location;
      }

      HostConfiguration hostConfig = new HostConfiguration();

      hostConfig.setHost(new URI(location));

      if (Validator.isNotNull(PROXY_HOST) && PROXY_PORT > 0) {
        hostConfig.setProxy(PROXY_HOST, PROXY_PORT);
      }

      client.setHostConfiguration(hostConfig);
      client.setConnectionTimeout(5000);
      client.setTimeout(5000);

      if (cookies != null && cookies.length > 0) {
        HttpState state = new HttpState();

        state.addCookies(cookies);
        state.setCookiePolicy(CookiePolicy.COMPATIBILITY);

        client.setState(state);
      }

      if (post) {
        method = new PostMethod(location);
      }
      else {
        method = new GetMethod(location);
      }

      method.setFollowRedirects(true);

      client.executeMethod(method);

      Header locationHeader = method.getResponseHeader("location");
      if (locationHeader != null) {
        return URLtoByteArray(locationHeader.getValue(), cookies, post);
      }
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.apache.commons.httpclient.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.