Package org.apache.http.client.entity

Examples of org.apache.http.client.entity.UrlEncodedFormEntity


            HttpEntityEnclosingRequestBase enclodingRequest = (HttpEntityEnclosingRequestBase) method;

            if (!nvps.isEmpty()) {
                try {
                    if (!multiPart) {
                        enclodingRequest.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
                    } else {
                        for (NameValuePair nvp : nvps) {
                            multipartEntity.addPart(nvp.getName(), new StringBody(nvp.getValue()));
                        }
                        enclodingRequest.setEntity(multipartEntity);
View Full Code Here


        formPost.addHeader("Referer", warURL + "login.html");

        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("j_username", "user1"));
        formparams.add(new BasicNameValuePair("j_password", "password1"));
        formPost.setEntity(new UrlEncodedFormEntity(formparams, "UTF-8"));

        HttpResponse postResponse = httpConn.execute(formPost);

        int statusCode = postResponse.getStatusLine().getStatusCode();
        Header[] errorHeaders = postResponse.getHeaders("X-NoJException");
View Full Code Here

            HttpPost post = new HttpPost(requestURL);
            boolean isRedirects = httpClient.getParams().getBooleanParameter("http.protocol.handle-redirects", false);
            post.getParams().setBooleanParameter("http.protocol.handle-redirects", isRedirects);
            ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("indexStoreName", indexStoreName));
            post.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
           
            // 发送请求
            HttpResponse httpResponse = httpClient.execute(post);
            int statusCode = httpResponse.getStatusLine().getStatusCode();
            inputStream = httpResponse.getEntity().getContent();
View Full Code Here

            // 封装请求参数
            ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
            for (Serializable bean : indexBeans) {
                params.add(new BasicNameValuePair("ids", bean.toString()));
            }
            post.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
           
            // 发送请求
            httpClient.execute(post);
            logger.info("Update index bean status success!");
        } catch (ClientProtocolException e) {
View Full Code Here

            // 封装请求参数
            ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
            for (Map<String, Object> indexMap : indexDataList) {
                params.add(new BasicNameValuePair("ids", String.valueOf(indexMap.get("id"))));
            }
            post.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
           
            // 发送请求
            httpClient.execute(post);
            logger.info("Update index data status success!");
        } catch (ClientProtocolException e) {
View Full Code Here

   
    for (String key : params.keySet()) {
      pairs.add(new BasicNameValuePair(key, params.get(key)));
    }
   
    method.setEntity(new UrlEncodedFormEntity(pairs, HTTP.UTF_8));
   
    return method;
  }
View Full Code Here

   
    for (String key : params.keySet()) {
      pairs.add(new BasicNameValuePair(key, params.get(key)));
    }
   
    method.setEntity(new UrlEncodedFormEntity(pairs, HTTP.UTF_8));
   
    return method;
  }
View Full Code Here

        URI uri = this.uri != null ? this.uri : URI.create("/");
        HttpEntity entity = this.entity;
        if (parameters != null && !parameters.isEmpty()) {
            if (entity == null && (HttpPost.METHOD_NAME.equalsIgnoreCase(method)
                    || HttpPut.METHOD_NAME.equalsIgnoreCase(method))) {
                entity = new UrlEncodedFormEntity(parameters, HTTP.DEF_CONTENT_CHARSET);
            } else {
                try {
                    uri = new URIBuilder(uri).addParameters(parameters).build();
                } catch (final URISyntaxException ex) {
                    // should never happen
View Full Code Here

      }

      defaultHttpClient.setCookieStore(cookieStore);
      HttpPost httpost = new HttpPost(requestUrl);
      List<NameValuePair> formParams = getLoginFormParameters(); // retrieve platform specific login parameters
      httpost.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8"));
     
      //getting to interface to avoid
      //java.lang.NoSuchMethodError: org/apache/http/impl/client/DefaultHttpClient.execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/client/methods/CloseableHttpResponse;
      //when run from different version of HttpClient (that's why it is deprecated)
      HttpClient httpClient = defaultHttpClient;
View Full Code Here

            {
               formparams.add(new BasicNameValuePair(formParam.getKey(), value));
            }
         }

         UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
         post.setEntity(entity);
      }
      if (request.getBody() != null)
      {
         if (httpMethod instanceof HttpGet) throw new RuntimeException("A GET request cannot have a body.");
View Full Code Here

TOP

Related Classes of org.apache.http.client.entity.UrlEncodedFormEntity

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.