Examples of GetMethod


Examples of org.apache.commons.httpclient.methods.GetMethod

    private String retrieveAttributeHelp() {
        if (_connectionErrors < MAX_CONNECTION_ERRORS) {
                StringBuffer information = new StringBuffer();
                try {
                    // build online help url
                    GetMethod getMethod = null;
                    if (_attribute != null) {
                        getMethod = new GetMethod(retrieveAttributeInfoURL(_tagname, _attribute, _value, _versionCompliance));                     
                    }
                   
                    if (getMethod != null) {
                        int returnCode = _httpClient.executeMethod(getMethod);
                        if (returnCode == HttpsURLConnection.HTTP_OK) {
                            information.append(getMethod.getResponseBodyAsString());
                        }
                    }
                } catch (Exception e) {
                    Plugin.getDefault().logError("Unable to retrieve online help data.", e);
                    _connectionErrors++;
View Full Code Here

Examples of org.apache.commons.httpclient.methods.GetMethod

  }
 
   public TemporaryFile downloadWGA(IProgressMonitor monitor, String url) throws IllegalStateException, IOException, URISyntaxException {
        monitor.setTaskName("Downloading OpenWGA from '" + url + "'");                    
        HttpClient client = new DefaultHttpClient((IProxyService)_proxyServiceTracker.getService(), new URI(url));
        GetMethod get = new GetMethod(url);
    int result = client.executeMethod(get);
    if (result == HttpURLConnection.HTTP_OK) {
      long size = get.getResponseContentLength();               
            TemporaryFile temp = new TemporaryFile("wga.war", new ProgressMonitorInputStream(monitor, "Downloading OpenWGA ", size, get.getResponseBodyAsStream()), getStateLocation().toFile());
      return temp;
    } else {
            throw new IOException("Download of OpenWGA failed. Server returned '" + result + "'.");
    }
   
View Full Code Here

Examples of org.apache.commons.httpclient.methods.GetMethod

    Object args = parameters != null ? parameters
        .get(ModelMap.RPC_ARGS_KEY) : null;

    if (methodType.equalsIgnoreCase("get")) {
      method = new GetMethod(url);
    } else if (methodType.equalsIgnoreCase("post")) {
      PostMethod postMethod = new PostMethod(url);
      if (args != null) {
        byte[] output = constructArgs(method, args);
        postMethod.setRequestEntity(new ByteArrayRequestEntity(output));
View Full Code Here

Examples of org.apache.commons.httpclient.methods.GetMethod

  public synchronized  void login(HttpClient httpClient,
      String securityHost, String loginUrl,String userName,String password) throws Exception {
    Exception exception = null;

    GetMethod authget = null;
    PostMethod authpost = null;
    GetMethod redirect = null;
    try {
      httpClient.getParams().setCookiePolicy(
          CookiePolicy.BROWSER_COMPATIBILITY);

      authget = new GetMethod(securityHost + loginUrl);

      httpClient.executeMethod(authget);
      int statuscode = authget.getStatusCode();

      authpost = new PostMethod(securityHost + "/j_security_check");
      NameValuePair j_username = new NameValuePair("j_username", userName);
      NameValuePair j_password = new NameValuePair("j_password", password);
      authpost.setRequestBody(new NameValuePair[] { j_username, j_password });

      httpClient.executeMethod(authpost);
      statuscode = authpost.getStatusCode();
      if ((statuscode == HttpStatus.SC_MOVED_TEMPORARILY)
          || (statuscode == HttpStatus.SC_MOVED_PERMANENTLY)
          || (statuscode == HttpStatus.SC_SEE_OTHER)
          || (statuscode == HttpStatus.SC_TEMPORARY_REDIRECT)) {
        Header header = authpost.getResponseHeader("location");
        if (header != null) {
          String newuri = header.getValue();
          if ((newuri == null) || (newuri.equals(""))) {
            newuri = "/";
          }
          redirect = new GetMethod(newuri);

          httpClient.executeMethod(redirect);
          redirect.releaseConnection();
        }
      } else {
        exception = new LoginErrorException("用户名或者密码错误");
      }
    } catch (Exception e) {
      exception = e;
    } finally {
      if (authget != null)
        authget.releaseConnection();
      if (authpost != null)
        authpost.releaseConnection();
      if (redirect != null)
        redirect.releaseConnection();
    }

    if (exception != null)
      throw exception;
  }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.GetMethod

            org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
            httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));
           
            for (int j = 0; j< 1000; j++) {
             
              GetMethod getMeth = new GetMethod("http://localhost:" + server.getLocalPort() + "/");
              httpClient.executeMethod(getMeth);
             
              Assert.assertEquals(200, getMeth.getStatusCode());
              Assert.assertEquals("OK", getMeth.getResponseBodyAsString());
             
              getMeth.releaseConnection();
            }

           
          } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of org.apache.commons.httpclient.methods.GetMethod

          try {
            org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
            httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));
            for (int j = 0; j< 1000; j++) {
             
              GetMethod getMeth = new GetMethod("http://localhost:" + server.getLocalPort() + "/");
              httpClient.executeMethod(getMeth);
             
              Assert.assertEquals(200, getMeth.getStatusCode());
              Assert.assertEquals("OK", getMeth.getResponseBodyAsString());
             
              getMeth.releaseConnection();
            }

           
          } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of org.apache.commons.httpclient.methods.GetMethod

     * <p>The returned stream does not have to be buffered.
     */
    protected InputStream doGetInputStream()
        throws Exception
    {
        final GetMethod getMethod = new GetMethod();
        setupMethod(getMethod);
        final int status = fileSystem.getClient().executeMethod(getMethod);
        if (status != HttpURLConnection.HTTP_OK)
        {
            throw new FileSystemException("vfs.provider.http/get.error", getName());
View Full Code Here

Examples of org.apache.commons.httpclient.methods.GetMethod

  private String getProxyTicket(String casServer, String pgt, String targetServiceURL) {
    try {
      NameValuePair pgtParam = new NameValuePair("pgt", pgt);
      NameValuePair serviceParam = new NameValuePair("targetService", targetServiceURL);

      GetMethod proxyMethod = new GetMethod(casServer + "proxy");
      proxyMethod.setQueryString(new NameValuePair[] { pgtParam, serviceParam });

      int status = pool.httpClient.executeMethod(proxyMethod);

      if (status == HttpStatus.SC_OK) {
        // Do not use raw stream since that will ignore the response's
        // character encoding
        String casResponseStr = proxyMethod.getResponseBodyAsString();
        ServiceResponse casResponse = ServiceResponseParser.parse(casResponseStr);
        if (casResponse instanceof ProxySuccess) {
          return ((ProxySuccess)casResponse).getProxyTicket();
        }
        else if (casResponse instanceof ProxyFailure) {
View Full Code Here

Examples of org.apache.commons.httpclient.methods.GetMethod

  }

  private String startRemoteSession(String sessionURL, String proxyTicket, Session localSession) {
    try {
      NameValuePair ticketParam = new NameValuePair("ticket", proxyTicket);
      GetMethod sessionMethod = new GetMethod(sessionURL);
      sessionMethod.setQueryString(new NameValuePair[] { ticketParam });

      int status = pool.httpClient.executeMethod(sessionMethod);

      if (status == HttpStatus.SC_OK) {
        for (Header header : sessionMethod.getResponseHeaders("Set-Cookie")) {
          for (HeaderElement headerEl : header.getElements()) {
            if (Protocol.SESSION_COOKIE.equals(headerEl.getName())) {
              return headerEl.getValue();
            }
          }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.GetMethod

  private void callAndCompare(int jettyPort, int xSocketPort, String path) throws IOException {

    HttpClient httpClient = new HttpClient();

    GetMethod jettyMethod = new GetMethod("http://localhost:" + jettyPort + path);
    int jettyStatusCode = httpClient.executeMethod(jettyMethod);
    String jettyResponse = jettyMethod.getResponseBodyAsString().trim();
    jettyMethod.releaseConnection();


    GetMethod xSocketMethod = new GetMethod("http://localhost:" + xSocketPort + path);
    int xSocketStatusCode = httpClient.executeMethod(xSocketMethod);
    String xSocketResponse = xSocketMethod.getResponseBodyAsString().trim();
    xSocketMethod.releaseConnection();

    Assert.assertEquals(jettyStatusCode, xSocketStatusCode);
    Assert.assertEquals(jettyResponse, xSocketResponse);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.