Package com.google.api.client.http

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


   public void should_ReturnAllStubbedRequestsAsYAML_WhenSuccessfulGetMade_ToAdminPortalRoot() throws Exception {

      final String requestUrl = String.format("%s%s", ADMIN_URL, "/");
      final HttpRequest httpGetRequest = HttpUtils.constructHttpRequest(HttpMethods.GET, requestUrl);

      final HttpResponse httpResponse = httpGetRequest.execute();
      final String responseContentAsString = httpResponse.parseAsString().trim();

      assertThat(httpResponse.getStatusCode()).isEqualTo(HttpStatus.OK_200);
      assertThat(responseContentAsString).contains("request");
      assertThat(responseContentAsString).contains("url: ^/resources/asn/");
      assertThat(responseContentAsString).contains("content-disposition: attachment; filename=hello-world.pdf");
      assertThat(responseContentAsString).contains("file: ../json/response.json");
      assertThat(responseContentAsString).contains("url: /uri/with/single/sequenced/response");
View Full Code Here


   public void should_ReturnSingleStubbedRequestAsYAML_WhenSuccessfulGetMade_ToAdminPortalRootWithValidIndexURI() throws Exception {

      final String requestUrl = String.format("%s%s", ADMIN_URL, "/0");
      final HttpRequest httpGetRequest = HttpUtils.constructHttpRequest(HttpMethods.GET, requestUrl);

      final HttpResponse httpResponse = httpGetRequest.execute();
      final String responseContentAsString = httpResponse.parseAsString().trim();

      assertThat(httpResponse.getStatusCode()).isEqualTo(HttpStatus.OK_200);
      assertThat(responseContentAsString).containsOnlyOnce("request");
      assertThat(responseContentAsString).containsOnlyOnce("url: ^/resources/asn/");
      assertThat(responseContentAsString).containsOnlyOnce("response");
      assertThat(responseContentAsString).containsOnlyOnce("content-type: application/json");
   }
View Full Code Here

  public final OAuthCredentialsResponse execute() throws IOException {
    HttpRequestFactory requestFactory = transport.createRequestFactory();
    HttpRequest request =
        requestFactory.buildRequest(usePost ? HttpMethod.POST : HttpMethod.GET, this, null);
    createParameters().intercept(request);
    HttpResponse response = request.execute();
    response.setContentLoggingLimit(0);
    OAuthCredentialsResponse oauthResponse = new OAuthCredentialsResponse();
    UrlEncodedParser.parse(response.parseAsString(), oauthResponse);
    return oauthResponse;
  }
View Full Code Here

       *
       * @return the {@link com.google.api.services.oauth2.model.Userinfo} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.oauth2.model.Userinfo execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.oauth2.model.Userinfo result = response.parseAs(
            com.google.api.services.oauth2.model.Userinfo.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }
View Full Code Here

   * @throws IOException if the request fails
   * @since 1.8
   */
  protected InputStream executeAsInputStream(HttpMethod method, GenericUrl url, Object body)
      throws IOException {
    HttpResponse response = executeUnparsed(method, url, body);
    return response.getContent();
  }
View Full Code Here

   * @throws IOException if the request fails
   */
  public HttpResponse executeUnparsed() throws IOException {
    HttpRequest request = buildHttpRequest();
    request.setEnableGZipContent(enableGZipContent);
    HttpResponse response = client.executeUnparsed(request);
    lastResponseHeaders = response.getHeaders();
    return response;
  }
View Full Code Here

   * @return input stream of the response content
   * @throws IOException if the request fails
   * @since 1.8
   */
  public InputStream executeAsInputStream() throws IOException {
    HttpResponse response = executeUnparsed();
    return response.getContent();
  }
View Full Code Here

   * @param outputStream destination output stream
   * @throws IOException I/O exception
   * @since 1.9
   */
  public void download(OutputStream outputStream) throws IOException {
    HttpResponse response = executeUnparsed();
    response.download(outputStream);
  }
View Full Code Here

       *
       * @return the {@link com.google.api.services.fusiontables.model.Table} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.fusiontables.model.Table execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.fusiontables.model.Table result = response.parseAs(
            com.google.api.services.fusiontables.model.Table.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }
View Full Code Here

       *
       * @return the {@link com.google.api.services.fusiontables.model.Table} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.fusiontables.model.Table execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.fusiontables.model.Table result = response.parseAs(
            com.google.api.services.fusiontables.model.Table.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }
View Full Code Here

TOP

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

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.