Package com.google.api.client.http

Examples of com.google.api.client.http.UrlEncodedContent


    method.setParser(new JsonObjectParser(new JacksonFactory()));
    return httpRequest(method, needAccessToken).parseAs(responseType);
  }
 
  public String postEncodedEntry (String url, Map<String, String> params, boolean needAccessToken) throws DoubanException, IOException {
    UrlEncodedContent content = new UrlEncodedContent(params);
    HttpRequest method = requestFactory.buildPostRequest(new GenericUrl(url), content);
    return httpRequest(method, needAccessToken).parseAsString();
  }
View Full Code Here


    HttpRequest method = requestFactory.buildPostRequest(new GenericUrl(url), content);
    return httpRequest(method, needAccessToken).parseAsString();
  }
 
  public String postMultipartEntry (String url, Map<String, String> params, boolean needAccessToken) throws DoubanException, IOException {
    UrlEncodedContent uec = new UrlEncodedContent(params);
    MultipartRelatedContent content = new MultipartRelatedContent(uec);
    HttpRequest method = requestFactory.buildPostRequest(new GenericUrl(url), content);
    return httpRequest(method, needAccessToken).parseAsString();
  }
View Full Code Here

    HttpRequest request = null;
    if ("POST".equals(requestMethod))
      if (postData == null)
        request = f.buildPostRequest(url, null);
      else
        request = f.buildPostRequest(url, new UrlEncodedContent(postData));
    else
      request = f.buildGetRequest(url);

    if (readTimeout != -1)
      request.setReadTimeout(readTimeout);
View Full Code Here

    ClientParametersAuthentication auth =
        new ClientParametersAuthentication(CLIENT_ID, CLIENT_SECRET);
    assertEquals(CLIENT_ID, auth.getClientId());
    assertEquals(CLIENT_SECRET, auth.getClientSecret());
    auth.intercept(request);
    UrlEncodedContent content = (UrlEncodedContent) request.getContent();
    @SuppressWarnings("unchecked")
    Map<String, ?> data = (Map<String, ?>) content.getData();
    assertEquals(CLIENT_ID, data.get("client_id"));
    assertEquals(CLIENT_SECRET, data.get("client_secret"));
  }
View Full Code Here

    ClientParametersAuthentication auth =
        new ClientParametersAuthentication(CLIENT_ID, null);
    assertEquals(CLIENT_ID, auth.getClientId());
    assertNull(auth.getClientSecret());
    auth.intercept(request);
    UrlEncodedContent content = (UrlEncodedContent) request.getContent();
    @SuppressWarnings("unchecked")
    Map<String, ?> data = (Map<String, ?>) content.getData();
    assertEquals(CLIENT_ID, data.get("client_id"));
    assertNull(data.get("client_secret"));
  }
View Full Code Here

            });
          }
        });
    // make request
    HttpRequest request = requestFactory.buildPostRequest(
        tokenServerUrl, new UrlEncodedContent(this));
    request.setParser(new JsonObjectParser(jsonFactory));
    request.setThrowExceptionOnExecuteError(false);
    HttpResponse response = request.execute();
    if (response.isSuccessStatusCode()) {
      return response;
View Full Code Here

   */
  public Response authenticate() throws ClientLoginResponseException, IOException {
    GenericUrl url = serverUrl.clone();
    url.appendRawPath("/accounts/ClientLogin");
    HttpRequest request =
        transport.createRequestFactory().buildPostRequest(url, new UrlEncodedContent(this));
    request.setParser(AuthKeyValueParser.INSTANCE);
    request.setContentLoggingLimit(0);
    request.setThrowExceptionOnExecuteError(false);
    HttpResponse response = request.execute();
    // check for an HTTP success response (2xx)
View Full Code Here

    assertEquals(HttpTesting.SIMPLE_GENERIC_URL, request.getUrl());
    char[] arr2 = new char[arr.length + 2];
    Arrays.fill(arr2, 'x');
    arr2[0] = 'a';
    arr2[1] = '=';
    UrlEncodedContent content = (UrlEncodedContent) request.getContent();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    content.writeTo(out);
    assertEquals(new String(arr2), out.toString());
  }
View Full Code Here

      HttpRequest request = null;
      if ("POST".equals(requestMethod))
        if (postData == null)
            request = f.buildPostRequest(url, null);
        else
          request = f.buildPostRequest(url, new UrlEncodedContent(postData));
      else
        request = f.buildGetRequest(url);
      HttpHeaders headers = new HttpHeaders();
      headers.set("X-Factual-Lib", DRIVER_HEADER_TAG);
      headers.set("Host", host);
View Full Code Here

    HttpRequest request = null;
    if ("POST".equals(requestMethod))
      if (postData == null)
        request = f.buildPostRequest(url, null);
      else
        request = f.buildPostRequest(url, new UrlEncodedContent(postData));
    else
      request = f.buildGetRequest(url);

    if (readTimeout != -1)
      request.setReadTimeout(readTimeout);
View Full Code Here

TOP

Related Classes of com.google.api.client.http.UrlEncodedContent

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.