Package org.apache.http.message

Examples of org.apache.http.message.BasicNameValuePair


         final HttpClient client = new DefaultHttpClient();

         // Make an HTTP Request
         final String echoValue = "EmbeddedBiatch";
         final List<NameValuePair> params = new ArrayList<NameValuePair>();
         params.add(new BasicNameValuePair("jsp", PATH_JSP));
         params.add(new BasicNameValuePair("echo", echoValue));
         final URI uri = URIUtils.createURI("http", "localhost", 8080,
               appName + SEPARATOR + servletClass.getSimpleName(), URLEncodedUtils.format(params, "UTF-8"), null);
         final HttpGet request = new HttpGet(uri);

         // Execute the request
View Full Code Here


         for (Map.Entry<String, List<String>> formParam : request.getFormParameters().entrySet())
         {
            List<String> values = formParam.getValue();
            for (String value : values)
            {
               formparams.add(new BasicNameValuePair(formParam.getKey(), value));
            }
         }

         UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
         post.setEntity(entity);
View Full Code Here

    @Override
    public void run() {
      try {
        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();
View Full Code Here

    }
    logger.info("getUrlContent({},{})", url, params);
    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

    public void testFormat () throws Exception {
        final List <NameValuePair> params = new ArrayList <NameValuePair>();
        assertEquals(0, URLEncodedUtils.format(params, null).length());

        params.clear();
        params.add(new BasicNameValuePair("Name1", "Value1"));
        assertEquals("Name1=Value1", URLEncodedUtils.format(params, null));

        params.clear();
        params.add(new BasicNameValuePair("Name2", null));
        assertEquals("Name2=", URLEncodedUtils.format(params, null));

        params.clear();
        params.add(new BasicNameValuePair("Name4", "Value 4!"));
        assertEquals("Name4=Value+4%21", URLEncodedUtils.format(params, null));

        params.clear();
        params.add(new BasicNameValuePair("Name4", "Value+4!"));
        assertEquals("Name4=Value%2B4%21", URLEncodedUtils.format(params, null));

        params.clear();
        params.add(new BasicNameValuePair("Name4", "Value 4! !4"));
        assertEquals("Name4=Value+4%21+%214", URLEncodedUtils.format(params, null));

        params.clear();
        params.add(new BasicNameValuePair("Name5", "aaa"));
        params.add(new BasicNameValuePair("Name6", "bbb"));
        assertEquals("Name5=aaa&Name6=bbb", URLEncodedUtils.format(params, null));

        params.clear();
        params.add(new BasicNameValuePair("Name7", "aaa"));
        params.add(new BasicNameValuePair("Name7", "b,b"));
        params.add(new BasicNameValuePair("Name7", "ccc"));
        assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", URLEncodedUtils.format(params, null));

        params.clear();
        params.add(new BasicNameValuePair("Name8", "xx,  yy  ,zz"));
        assertEquals("Name8=xx%2C++yy++%2Czz", URLEncodedUtils.format(params, null));
    }
View Full Code Here

                            // as the user had entered.
                            parameterName = URLDecoder.decode(parameterName, urlContentEncoding);
                            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();
View Full Code Here

            final String name = decode(nameValue[0], encoding);
            String value = null;
            if (nameValue.length == 2)
                value = decode(nameValue[1], encoding);
            parameters.add(new BasicNameValuePair(name, value));
        }
    }
View Full Code Here

        String algorithm = getParameter("algorithm");

        String uname = credentials.getUserPrincipal().getName();
       
        List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(20);
        params.add(new BasicNameValuePair("username", uname));
        params.add(new BasicNameValuePair("realm", realm));
        params.add(new BasicNameValuePair("nonce", nonce));
        params.add(new BasicNameValuePair("uri", uri));
        params.add(new BasicNameValuePair("response", response));
       
        if (qopVariant != QOP_MISSING) {
            params.add(new BasicNameValuePair("qop", getQopVariantString()));
            params.add(new BasicNameValuePair("nc", NC));
            params.add(new BasicNameValuePair("cnonce", getCnonce()));
        }
        if (algorithm != null) {
            params.add(new BasicNameValuePair("algorithm", algorithm));
        }   
        if (opaque != null) {
            params.add(new BasicNameValuePair("opaque", opaque));
        }

        for (int i = 0; i < params.size(); i++) {
            BasicNameValuePair param = params.get(i);
            if (i > 0) {
                buffer.append(", ");
            }
            boolean noQuotes = "nc".equals(param.getName()) ||
                               "qop".equals(param.getName());
            BasicHeaderValueFormatter.DEFAULT
                .formatNameValuePair(buffer, param, !noQuotes);
        }
        return new BufferedHeader(buffer);
    }
View Full Code Here

                    + "), must be even"
                    );
        } else {
            final List<NameValuePair> p = new ArrayList<NameValuePair>();
            for(int i=0 ; i < queryParameters.length; i+=2) {
                p.add(new BasicNameValuePair(queryParameters[i], queryParameters[i+1]));
            }
            sb.append(baseUrl);
            sb.append(path);
            sb.append("?");
            sb.append(URLEncodedUtils.format(p, "UTF-8"));
View Full Code Here

    protected String testUpdate(String username, String password,
                              String path, int expectedStatus,
                              String... expectedContent) throws Exception {
        String addedValue = "addedValue" + UUID.randomUUID().toString();
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("addedProperty", addedValue));

        if ( username == null )
        {
            // call without credentials
            getRequestExecutor().execute(
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.