Package org.apache.http.message

Examples of org.apache.http.message.BasicNameValuePair


            FormDataElement e = (FormDataElement)iter.next();
            String param = e.getElementName();
            String value = e.getElementValue();
            if (Logging.connectors.isDebugEnabled())
              Logging.connectors.debug("WEB: Post parameter name '"+param+"' value '"+value+"' for '"+urlPath+"'");
            nvps.add(new BasicNameValuePair(param,value));
          }
        }
        try
        {
          postMethod.setEntity(new UrlEncodedFormEntity(nvps,HTTP.UTF_8));
View Full Code Here


    @Test
    public void testPostBody() throws Exception {
        HttpUriRequest method = new HttpPost("http://localhost:" + portNum + "/users");

        List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
        urlParameters.add(new BasicNameValuePair("foo", "bar"));

        ((HttpEntityEnclosingRequestBase)method).setEntity(new UrlEncodedFormEntity(urlParameters));

        HttpResponse response = doExecute(method);
       
View Full Code Here

    private void execute2(String code) throws Exception
    {
        RequestBuilder rb = new RequestBuilder(ServerConfiguration.getServerUrl());

        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("lang","groovy"));
        params.add(new BasicNameValuePair("code",code));

        final HttpEntity entity = new UrlEncodedFormEntity(params);
        // Add Sling POST options
        executor.execute(
                rb.buildPostRequest("/system/console/sc")
View Full Code Here

    @Test
    public void testPostBody() throws Exception {
        HttpUriRequest method = new HttpPost("http://localhost:" + portNum + "/users");

        List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
        urlParameters.add(new BasicNameValuePair("foo", "bar"));

        ((HttpEntityEnclosingRequestBase)method).setEntity(new UrlEncodedFormEntity(urlParameters));

        HttpResponse response = doExecute(method);
       
View Full Code Here

     
      // This works for connections
      // add parameters to the post method 
      method = new HttpPost(getAccessTokenURL());
      List <NameValuePair> parameters = new ArrayList <NameValuePair>();  
      parameters.add(new BasicNameValuePair(Configuration.OAUTH2_CALLBACK_URI, URLEncoder.encode(client_uri, "UTF-8")));  
      parameters.add(new BasicNameValuePair(Configuration.OAUTH2_CLIENT_ID, URLEncoder.encode(consumerKey, "UTF-8")));  
      parameters.add(new BasicNameValuePair(Configuration.OAUTH2_CLIENT_SECRET, URLEncoder.encode(consumerSecret, "UTF-8")));  
      parameters.add(new BasicNameValuePair(Configuration.OAUTH2_GRANT_TYPE, Configuration.OAUTH2_AUTHORIZATION_CODE));  
      parameters.add(new BasicNameValuePair(Configuration.OAUTH2_CODE, URLEncoder.encode(authorization_code, "UTF-8")));  
      UrlEncodedFormEntity sendentity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8)
      method.setEntity(sendentity);  
      HttpResponse httpResponse =client.execute(method);
      responseCode = httpResponse.getStatusLine().getStatusCode();
     
View Full Code Here

  @Test
  public void getLogEntries() {
    HttpInvoker mockInvoker = mock(HttpInvoker.class);
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("start", Long.toString(0)));
    params.add(new BasicNameValuePair("end", Long.toString(0)));

    when(mockInvoker.makeGetRequest(eq("http://ctlog/get-entries"), eq(params)))
      .thenReturn(LOG_ENTRY);

    HttpLogClient client = new HttpLogClient("http://ctlog/", mockInvoker);
View Full Code Here

  @Test
  public void getLogEntriesCorruptedEntry() {
    HttpInvoker mockInvoker = mock(HttpInvoker.class);
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("start", Long.toString(0)));
    params.add(new BasicNameValuePair("end", Long.toString(0)));

    when(mockInvoker.makeGetRequest(eq("http://ctlog/get-entries"), eq(params)))
      .thenReturn(LOG_ENTRY_CORRUPTED_ENTRY);

    HttpLogClient client = new HttpLogClient("http://ctlog/", mockInvoker);
View Full Code Here

  @Test
  public void getLogEntriesEmptyEntry() {
    HttpInvoker mockInvoker = mock(HttpInvoker.class);
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("start", Long.toString(0)));
    params.add(new BasicNameValuePair("end", Long.toString(0)));

    when(mockInvoker.makeGetRequest(eq("http://ctlog/get-entries"), eq(params)))
      .thenReturn(LOG_ENTRY_EMPTY);

    HttpLogClient client = new HttpLogClient("http://ctlog/", mockInvoker);
View Full Code Here

  @Test
  public void getSTHConsistency() {
    HttpInvoker mockInvoker = mock(HttpInvoker.class);
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("first", Long.toString(1)));
    params.add(new BasicNameValuePair("second", Long.toString(3)));

    when(mockInvoker.makeGetRequest(eq("http://ctlog/get-sth-consistency"), eq(params)))
      .thenReturn(CONSISTENCY_PROOF);

    HttpLogClient client = new HttpLogClient("http://ctlog/", mockInvoker);
View Full Code Here

  @Test
  public void getSTHConsistencyEmpty() {
    HttpInvoker mockInvoker = mock(HttpInvoker.class);
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("first", Long.toString(1)));
    params.add(new BasicNameValuePair("second", Long.toString(3)));

    when(mockInvoker.makeGetRequest(eq("http://ctlog/get-sth-consistency"), eq(params)))
      .thenReturn(CONSISTENCY_PROOF_EMPTY);

    HttpLogClient client = new HttpLogClient("http://ctlog/", mockInvoker);
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.