Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.NameValuePair


     *
     * @throws ContactsException
     */
    public void doLogin() throws ContactsException {
        try {
            NameValuePair params[] = {new NameValuePair("username", email),
                new NameValuePair("user", getUsername(email)),
                new NameValuePair("password", password),
                new NameValuePair("url2", "http%3A%2F%2Femail.163.com%2Ferrorpage%2Ferr_yeah.htm"),
                new NameValuePair("style", "3")};

            String responseStr = doPost(loginUrl, params,
                    "http://email.163.com/");

            String redirectUrl1 = getJSRedirectLocation(responseStr);
View Full Code Here


     *
     * @throws ContactsException
     */
    public void doLogin() throws ContactsException {
        try {
            NameValuePair params[] = {new NameValuePair("verifycookie", "1"),
                new NameValuePair("product", "mail163"),
                new NameValuePair("username", getUsername(email)),
                new NameValuePair("password", password),
                new NameValuePair("selType", "jy")};
            Calendar calendar = Calendar.getInstance();
            calendar.set(2099, 11, 31);
            client.getState().addCookies(
                    new Cookie[]{
                        new Cookie(".163.com", "ntes_mail_firstpage",
View Full Code Here

   *
   * @throws ContactsException
   */
  public void doLogin() throws ContactsException {
    try {
      NameValuePair params[] = { new NameValuePair("logintype", "uid"),
          new NameValuePair("u", getUsername(email)),
          new NameValuePair("psw", password) };
      client.getState().addCookies(
          new Cookie[] {
              new Cookie("mail.sina.com.cn",
                  "sina_free_mail_recid", "false", "/", null,
                  false),
View Full Code Here

   * @return 所有的联系人信息
   * @throws ContactsException
   */
  public List<Contact> parseContacts() throws ContactsException {
    try {
      NameValuePair params[] = { new NameValuePair("act", "list"),
          new NameValuePair("sort_item", "letter"),
          new NameValuePair("sort_type", "desc") };
      String contactsUrl = lastUrl.substring(0, lastUrl.lastIndexOf("/"))
          + "/addr_member.php";
      String json = doPost(contactsUrl, params);
      JSONTokener jsonTokener = new JSONTokener(json);
      Object o = jsonTokener.nextValue();
View Full Code Here

    try {
      String content = doGet(beforeLoginUrl);
      String challenge = getInputValue(".challenge", content);

      NameValuePair[] params = new NameValuePair[] {
          new NameValuePair(".intl", getInputValue(".intl", content)),
          new NameValuePair(".done", getInputValue(".done", content)),
          new NameValuePair(".src", getInputValue(".src", content)),
          new NameValuePair(".cnrid",
              getInputValue(".cnrid", content)),
          new NameValuePair(".challenge", challenge),
          new NameValuePair("login", email),
          new NameValuePair("passwd", password) };
      content = doPost(loginUrl, params, beforeLoginUrl);

      client.getState().addCookie(
          new Cookie("mail.cn.yahoo.com", "cn_challenge", challenge, "/", null, false));
      String redirectUrl = getJSRedirectLocation(content);
View Full Code Here

       
        /**
         * Adds a security crumb to the quest
         */
        public WebRequestSettings addCrumb(WebRequestSettings req) {
            NameValuePair crumb[] = { new NameValuePair() };
           
            crumb[0].setName(hudson.getCrumbIssuer().getDescriptor().getCrumbRequestField());
            crumb[0].setValue(hudson.getCrumbIssuer().getCrumb( null ));
           
            req.setRequestParameters(Arrays.asList( crumb ));
View Full Code Here

        props.put("text", "Hello ATcsp");
        testClient.createNode(HTTP_BASE_URL + testPath + "/a/1", props);
        testClient.createNode(HTTP_BASE_URL + testPath + "/a/12", props);
   
        final List<NameValuePair> opt = new ArrayList<NameValuePair>();
        opt.add(new NameValuePair(testPath + "/a/12/13@CopyFrom", testPath + "/a/1"));
       
        final int expectedStatus = HttpServletResponse.SC_OK;
        assertPostStatus(HTTP_BASE_URL + testPath, expectedStatus, opt, "Expecting status " + expectedStatus);
       
        // assert content at old and new locations
View Full Code Here

   
    public void testCopyAncestor() throws IOException {
        final String testPath = TEST_BASE_PATH + "/AT_tcanc/" + System.currentTimeMillis();
       
        final List<NameValuePair> opt = new ArrayList<NameValuePair>();
        opt.add(new NameValuePair(testPath + "./@CopyFrom", "../"));
       
        final int expectedStatus = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
        assertPostStatus(HTTP_BASE_URL + testPath, expectedStatus, opt, "Expecting status " + expectedStatus);
    }
View Full Code Here

        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must initially exist");
        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must initially exist");
       
        // delete one and check
        final List <NameValuePair> params = new LinkedList<NameValuePair> ();
        params.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_DELETE));
        assertPostStatus(urlA,HttpServletResponse.SC_OK,params,"Delete must return expected status (3)");
        assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (1)");
        assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_OK, "B must still exist");
        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must still exist");
        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must still exist");
View Full Code Here

        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must initially exist");
        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must initially exist");

        // delete one and check
        final List <NameValuePair> params = new LinkedList<NameValuePair> ();
        params.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_DELETE));
        params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlA.substring(HTTP_BASE_URL.length())));
        params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlB.substring(HTTP_BASE_URL.length())));
        assertPostStatus(urlC,HttpServletResponse.SC_OK,params,"Delete must return expected status (3)");
        assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (1)");
        assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "B must be deleted (1)");
        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must still exist");
        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must still exist");

        // delete the others with successive requests
        params.clear();
        params.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_DELETE));
        params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlA.substring(HTTP_BASE_URL.length())));
        params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlB.substring(HTTP_BASE_URL.length())));
        params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlC.substring(HTTP_BASE_URL.length())));
        params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlD.substring(HTTP_BASE_URL.length())));
        assertPostStatus(urlC,HttpServletResponse.SC_OK,params,"Delete must return expected status (3)");
        assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (2)");
        assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "B must be deleted (2)");
        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "C must be deleted (2)");
        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "D must be deleted (2)");
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.NameValuePair

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.