Package org.apache.http.client.entity

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


            {
               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


      httpget.setHeader("Accept", requestHeader);
      httpurirequest = httpget;
    } else {
      final HttpPost httppost = new HttpPost(url);
      httppost.setHeader("Accept", requestHeader);
      httppost.setEntity(new UrlEncodedFormEntity(content, org.apache.commons.lang.CharEncoding.UTF_8));
      httpurirequest = httppost;
    }
    final HttpResponse response = httpclient.execute(httpurirequest);
    final HttpEntity entity = response.getEntity();
    InputStream in = entity.getContent();
View Full Code Here

    private static HttpEntity convertFormParams(Params params) {
        try {
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            for (Pair p : params.pairs())
                nvps.add(new BasicNameValuePair(p.getName(), p.getValue()));
            HttpEntity e = new UrlEncodedFormEntity(nvps, "UTF-8");
            return e;
        } catch (UnsupportedEncodingException e) {
            throw new InternalErrorException("Platform does not support required UTF-8");
        }
    }
View Full Code Here

    public HttpEntity getLoginEntity() throws UnsupportedEncodingException {
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair(this.loginUserField, this.username));
        nvps.add(new BasicNameValuePair(this.loginPasswordField, new String(this.password)));

        return new UrlEncodedFormEntity(nvps, "UTF-8");
    }
View Full Code Here

                            parameterValue = URLDecoder.decode(parameterValue, urlContentEncoding);
                        }
                        // Add the parameter, httpclient will urlencode it
                        nvps.add(new BasicNameValuePair(parameterName, parameterValue));
                    }
                    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nvps, urlContentEncoding);
                    post.setEntity(entity);
                    if (entity.isRepeatable()){
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        post.getEntity().writeTo(bos);
                        bos.flush();
                        // We get the posted bytes using the encoding used to create it
                        if (contentEncoding != null) {
View Full Code Here

            final Set<String> keys = _methodParams.keySet();
            for (final String name : keys) {
                final String value = _methodParams.get(name).toString();
                nameValuePairs.add(new BasicNameValuePair(name, value));
            }
            return new UrlEncodedFormEntity(nameValuePairs, UTF8);
        }
        return null;
    }
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

    List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
    nvps.add(new BasicNameValuePair("auth", "test"));
    nvps.add(new BasicNameValuePair("com.rasdesign.dras.home.thermostat.setpoint.set", new Double(
        Math.round((Math.random() * 30) + 60)).toString()));

    httpPost.setEntity(new UrlEncodedFormEntity(nvps));
    HttpResponse response2 = httpclient.execute(httpPost);

    try {
      System.out.println("set response=" + response2.getStatusLine());
      HttpEntity entity2 = response2.getEntity();
View Full Code Here

    HttpPost httpPost = new HttpPost(url);
    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    nvps.add(new BasicNameValuePair("auth", "test"));
    nvps.add(new BasicNameValuePair("com.rasdesign.dras.home.thermostat.setpoint.get", ""));

    httpPost.setEntity(new UrlEncodedFormEntity(nvps));
    HttpResponse response2 = httpclient.execute(httpPost);

    try {
      System.out.println("get response=" + response2.getStatusLine());
      HttpEntity entity2 = response2.getEntity();
View Full Code Here

    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    nvps.add(new BasicNameValuePair("auth", "test"));
    nvps.add(new BasicNameValuePair("listenkey",
        "com.rasdesign.dras.home.thermostat.temperature.setpoint"));

    httpPost.setEntity(new UrlEncodedFormEntity(nvps));
    org.apache.http.HttpResponse response2 = httpclient.execute(httpPost);

    try {
      System.out.println(response2.getStatusLine());
      // HttpEntity entity2 = response2.getEntity();
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.