Package org.apache.commons.httpclient.methods

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


    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

    /* 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

      {
         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

            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

         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

         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

      {
         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

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

      // Submit the login form
      PostMethod formPost = new PostMethod(baseURLNoAuth+"web-role-map/j_security_check");
      formPost.addRequestHeader("Referer", baseURLNoAuth+"web-role-map/login.html");
      formPost.addParameter("j_username", "user");
      formPost.addParameter("j_password", "pass");
      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

      {
         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

TOP

Related Classes of org.apache.commons.httpclient.methods.PostMethod

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.