Examples of PostMethod


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

    {
      Protocol.registerProtocol("https", new Protocol("https",
          new EasySSLProtocolSocketFactory(), 8443));
    }

    PostMethod method = new PostMethod(url);

    setRequestHeaders(function, method);

    return method;
  }
View Full Code Here

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

    }
    Node rootNode = nodes.item(0);

    String url = XMLHelper.getAttribute(rootNode, "url");

    PostMethod method = initialize(function, url);

    nodes = rootNode.getChildNodes();
    String name = null;
    String value = null;
    Vector params = new Vector();
    for (int i = 0; i < nodes.getLength(); i++)
    {
      name = nodes.item(i).getNodeName();
      value = XMLHelper.getNodeText(nodes.item(i));
      if (value == null)
      {
        value = "";
      }
      params.add(new NameValuePair(name, value));
    }

    /*
     * Copy WILDCARDS from XBUSSystem into parameters
     */
    Hashtable info = mDestination.getAddresses();
    String key = null;
    for (Enumeration en = info.keys(); en.hasMoreElements();)
    {
      key = (String) en.nextElement();
      if (XBUSSystem.FILENAME_WILDCARD.equals(key))
      {
        value = (String) info.get(key);
        params.add(new NameValuePair(key, value));
      }
    }

    NameValuePair[] paramArray = new NameValuePair[params.size()];
    params.copyInto(paramArray);
    method.setQueryString(paramArray);

    String response = sendMessage(method);
    return XMLHelper.parseXML(response, "Default", mDestination.getName());
  }
View Full Code Here

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

    }
  }

  public HTTPRequest head() {
    // FIXME: Allow HEAD request to send a message body?
    HttpMethodBase method = new PostMethod(url) {

      @Override
      public String getName() {
        return "HEAD";
      }
View Full Code Here

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

    return new HTTPRequest(this, method);
  }

  public HTTPRequest get() {
    // FIXME: Allow GET request to send a message body?
    HttpMethodBase method = new PostMethod(url) {

      @Override
      public String getName() {
        return "GET";
      }
View Full Code Here

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

    setDoAuthentication(method);
    return new HTTPRequest(this, method);
  }

  public HTTPRequest post() {
    PostMethod method = new PostMethod(url);
    setDoAuthentication(method);
    return new HTTPRequest(this, method);
  }
View Full Code Here

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

    /* Create the Method. Wrap any RuntimeException into an IOException */
    HttpMethodBase method = null;
    try {
      if (properties != null && properties.containsKey(IConnectionPropertyConstants.POST))
        method = new PostMethod(link.toString());
      else
        method = new GetMethod(link.toString());
    } catch (RuntimeException e) {
      throw new IOException(e.getMessage());
    }
View Full Code Here

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

      {
         case GET:
            request = new GetMethod(url.toString());
            break;
         case POST:
            request = new PostMethod(url.toString());
            break;
         case HEAD:
            request = new HeadMethod(url.toString());
            break;
         case OPTIONS:
View Full Code Here

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

            sessionID = k.getValue();
      }
      getLog().debug("Saw JSESSIONID="+sessionID);

      // Submit the login form
      PostMethod formPost = new PostMethod(baseURLNoAuth+"header-form-auth/j_security_check");
      formPost.addRequestHeader("Referer", baseURLNoAuth+"header-form-auth/restricted/login.html");
      formPost.addParameter("j_username", username);
      formPost.addParameter("j_password", password);
      responseCode = httpConn.executeMethod(formPost.getHostConfiguration(),
            formPost, state);
      String response = formPost.getStatusText();
      log.debug("responseCode="+responseCode+", response="+response);
      assertTrue("Saw HTTP_MOVED_TEMP", responseCode == HttpURLConnection.HTTP_MOVED_TEMP);

      //  Follow the redirect to the SecureServlet
      Header location = formPost.getResponseHeader("Location");
      String indexURI = location.getValue();
      GetMethod war1Index = new GetMethod(indexURI);
      responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(),
            war1Index, state);
      response = war1Index.getStatusText();
View Full Code Here

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

         getMethod.releaseConnection();
      }

      HttpState state = this.httpClient.getState();
      // fill in the login form and submit it
      PostMethod postMethod = new PostMethod(this.testAppBaseURL + "j_security_check");
      postMethod.addRequestHeader("Referer", this.testAppBaseURL + "restricted/login.html");
      postMethod.addParameter("j_username", "jduke");
      postMethod.addParameter("j_password", "theduke");
      Header location = null;
      try
      {
         int responseCode = this.httpClient.executeMethod(postMethod.getHostConfiguration(), postMethod, state);
         log.debug("responseCode=" + responseCode + ", response=" + postMethod.getStatusText());
         // check the response code received and the presence of a location header in the response
         assertTrue("Unexpected response code received: " + responseCode,
               responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
         location = postMethod.getResponseHeader("Location");
         assertNotNull("Location header not found in response", location);
      }
      finally
      {
         postMethod.releaseConnection();
      }

      // follow the redirect as defined by the location header
      String indexURI = location.getValue();
      getMethod = new GetMethod(indexURI);
View Full Code Here

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

         if (k.getName().equalsIgnoreCase("JSESSIONID"))
            sessionID = k.getValue();
      }
      getLog().debug("Saw JSESSIONID=" + sessionID);
      // Submit the login form
      PostMethod formPost = new PostMethod(baseURLNoAuth + "sdtolerate/j_security_check");
      formPost.addRequestHeader("Referer", baseURLNoAuth + "sdtolerate/login.jsp");
      formPost.addParameter("j_username", this.username);
      formPost.addParameter("j_password", new String(password));
      responseCode = httpConn.executeMethod(formPost);
      String loginResult = formPost.getResponseBodyAsString();
      if( loginResult.indexOf("Encountered a login error") > 0 )
         fail("Login Failed");

      String response = formPost.getStatusText();
      log.debug("responseCode="+responseCode+", response="+response);
      assertTrue("Saw HTTP_MOVED_TEMP", responseCode == HttpURLConnection.HTTP_MOVED_TEMP);

      //  Follow the redirect to the index.jsp
      Header location = formPost.getResponseHeader("Location");
      String indexURI = location.getValue();
      GetMethod war1Index = new GetMethod(indexURI);
      responseCode = httpConn.executeMethod(war1Index);
      response = war1Index.getStatusText();
      log.debug("responseCode="+responseCode+", response="+response);
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.