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);
      }
      else if (request.getBody() != null)
      {
         if (httpMethod instanceof HttpGet) throw new RuntimeException("A GET request cannot have a body.");
View Full Code Here


        final List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        final HttpPost req = new HttpPost("http://datacleaner.eobjects.org/ws/user_action");
        nameValuePairs.add(new BasicNameValuePair("username", _username));
        nameValuePairs.add(new BasicNameValuePair("action", _action));
        nameValuePairs.add(new BasicNameValuePair("version", Main.VERSION));
        req.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse resp = HttpXmlUtils.getHttpClient().execute(req);
        InputStream content = resp.getEntity().getContent();
        String line = new BufferedReader(new InputStreamReader(content)).readLine();
        assert "success".equals(line);
View Full Code Here

    HttpPost method = new HttpPost(url);
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    for (Entry<String, String> entry : params.entrySet()) {
      nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }
    method.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    String response = getHttpClient().execute(method, responseHandler);
    return response;
  }
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

        if ( username == null )
        {
            // call without credentials
            getRequestExecutor().execute(
                    getRequestBuilder().buildPostRequest(path)
                            .withEntity(new UrlEncodedFormEntity(params))
            ).assertStatus(expectedStatus).assertContentContains(expectedContent);
        }
        else
        {
            // call with credentials
            getRequestExecutor().execute(
                    getRequestBuilder().buildPostRequest(path)
                            .withEntity(new UrlEncodedFormEntity(params))
            ).assertStatus(expectedStatus).assertContentContains(expectedContent);
          
        }

        return addedValue;
View Full Code Here

    public SResponse post(Url url, Map data, Map<String, String> headers) {
        HttpPost post = null;

        try {
            post = new HttpPost(url.toURI());
            UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(mapToNameValuesPairs(data), charset);
            post.setHeader(content_type.v1(), content_type.v2());

            if (headers != null) {
                for (Map.Entry<String, String> entry : headers.entrySet()) {
                    post.setHeader(entry.getKey(), entry.getValue());
View Full Code Here

    public SResponse put(Url url, Map data, Map<String, String> headers) {
        HttpPut put = null;
        try {
            put = new HttpPut(url.toURI());
            UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(mapToNameValuesPairs(data), charset);
            put.setHeader(content_type.v1(), content_type.v2());
            if (headers != null) {
                for (Map.Entry<String, String> entry : headers.entrySet()) {
                    put.setHeader(entry.getKey(), entry.getValue());
                }
View Full Code Here

        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

            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);
        }

        return slingInstance.getRequestExecutor().execute(
                request.withCredentials(slingInstance.getServerUsername(), slingInstance.getServerPassword())
View Full Code Here

                subpath, junitServletUrl);
        final Request r = builder
        .buildPostRequest(subpath.toString())
        .withCredentials(username, password)
        .withCustomizer(requestCustomizer)
        .withEntity(new UrlEncodedFormEntity(opt));
        executor.execute(r).assertStatus(200);

        return executor;
    }
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.