Package org.apache.http.message

Examples of org.apache.http.message.BasicNameValuePair



    private List<NameValuePair> mapToNameValuesPairs(Map data) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        for (Object key : data.keySet()) {
            params.add(new BasicNameValuePair((String) key, (String) data.get(key)));
        }
        return params;
    }
View Full Code Here


    return "<html><head><title>" + title + "</title></head><body>" + bodyHtml + "</body></html>";
  }

  public List<NameValuePair> parameter(final String name, final String value) {
    List<NameValuePair> result = new ArrayList<NameValuePair>();
    result.add(new BasicNameValuePair(name, value));
    return result;
  }
View Full Code Here

  private HttpPost composePostRequest(final String uri, final Parameters parameters) {
    HttpPost request = new HttpPost(uri);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    for(Parameter param : parameters)
      if(param.isSingleValue())
        formparams.add(new BasicNameValuePair(param.getName(), param.getValue()));
      else
        for(String value : param.getValues())
          formparams.add(new BasicNameValuePair(param.getName(), value));
    try {
      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
      request.setEntity(entity);
    } catch (UnsupportedEncodingException e) {
      throw MechanizeExceptionFactory.newException(e);
View Full Code Here

        if (parameters != null) {
            assertEquals(0, parameters.length % 2);
            List<NameValuePair> valuePairList = new ArrayList<NameValuePair>();

            for (int i = 0; i < parameters.length; i += 2) {
                valuePairList.add(new BasicNameValuePair(parameters[i], parameters[i + 1]));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(valuePairList);
            request.withEntity(entity);
        }
View Full Code Here

        // Request options if any
        final List<NameValuePair> opt = new ArrayList<NameValuePair>();
        if(requestOptions != null) {
            for(Map.Entry<String, String> e : requestOptions.entrySet()) {
                opt.add(new BasicNameValuePair(e.getKey(), e.getValue()));
            }
        }
       
        log.info("Executing test remotely, path={} JUnit servlet URL={}",
                subpath, junitServletUrl);
View Full Code Here

  }

  private DoubanReviewFeedObj getReviewList (String url, Integer startIndex, Integer maxResult, ReviewOrderBy orderBy) throws DoubanException, IOException {
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    if (startIndex != null) {
      params.add(new BasicNameValuePair("start-index", startIndex.toString()));
    }
    if (maxResult != null) {
      params.add(new BasicNameValuePair("max-results", maxResult.toString()));
    }
    if (orderBy != null) {
      params.add(new BasicNameValuePair("orderby", orderBy.getValue()));
    }
    DoubanReviewFeedObj result = this.client.getResponse(url, params, DoubanReviewFeedObj.class, false);
    return result;
  }
View Full Code Here

  }

  public DoubanMailFeedObj getMailsFromInbox(Integer startIndex, Integer maxResult) throws DoubanException, IOException {
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    if (startIndex != null) {
      params.add(new BasicNameValuePair("start-index", "" + startIndex));
    }
    if (maxResult != null) {
      params.add(new BasicNameValuePair("max-results", "" + maxResult));
    }
    String url = RequestUrls.DOUBAN_MAIL_PREFIX + "/inbox";
    DoubanMailFeedObj result = this.client.getResponse(url, params, DoubanMailFeedObj.class, true);
    return result;
  }
View Full Code Here

  private static List<NameValuePair> setParams(HttpPost httppost, Map<String, Object> body)
  {
    List<NameValuePair> formParams = new ArrayList<NameValuePair>();
    Set<Entry<String, Object>> set = body.entrySet();
    for (Entry<String, Object> e: set)
      formParams.add(new BasicNameValuePair(e.getKey(), (e.getValue() != null) ? e.getValue().toString() : null));
    return formParams;
  }
View Full Code Here

    }

    private void sendMessageToApplication(String hostName, String contextRoot, Map<String, String> params) {
        List<NameValuePair> qParams = new ArrayList<NameValuePair>();
        for (Map.Entry<String, String> mapEntry : params.entrySet()) {
            qParams.add(new BasicNameValuePair(mapEntry.getKey(), mapEntry.getValue()));
        }
        URI uri;
        try {
            uri = URIUtils.createURI("http", "localhost", 8080, "/" + contextRoot + "/testservlet", URLEncodedUtils.format(qParams, "UTF-8"), null);
        } catch (URISyntaxException e) {
View Full Code Here

            HttpPost httpPost = new HttpPost(uri);
            if (!serverName.equals("localhost")) {
                httpPost.getParams().setParameter(ClientPNames.VIRTUAL_HOST, new HttpHost(serverName, 8080));
            }
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            formparams.add(new BasicNameValuePair(name, value));
            UrlEncodedFormEntity entity;
            try {
                entity = new UrlEncodedFormEntity(formparams, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
View Full Code Here

TOP

Related Classes of org.apache.http.message.BasicNameValuePair

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.