com.google.api.client.http.HttpResponse.disconnect()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中com.google.api.client.http.HttpResponse.disconnect()方法的一些代码示例,展示了HttpResponse.disconnect()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.disconnect()方法的具体详情如下:
包路径:com.google.api.client.http.HttpResponse
类名称:HttpResponse
方法名:disconnect

HttpResponse.disconnect介绍

暂无

代码示例

代码示例来源:origin: GoogleContainerTools/jib

@Override
public void close() throws IOException {
 if (httpResponse == null) {
  return;
 }
 httpResponse.disconnect();
}

代码示例来源:origin: googleapis/google-cloud-java

} finally {
 if (response != null) {
  response.disconnect();

代码示例来源:origin: google/google-api-java-client-samples

fileContents.disconnect();

代码示例来源:origin: firebase/firebase-admin-java

private static void disconnectQuietly(HttpResponse response) {
 if (response != null) {
  try {
   response.disconnect();
  } catch (IOException ignored) {
   // ignored
  }
 }
}

代码示例来源:origin: gradle.plugin.com.google.cloud.tools/jib-gradle-plugin

@Override
public void close() throws IOException {
 if (httpResponse == null) {
  return;
 }
 httpResponse.disconnect();
}

代码示例来源:origin: com.google.cloud.tools/jib-maven-plugin

@Override
public void close() throws IOException {
 if (httpResponse == null) {
  return;
 }
 httpResponse.disconnect();
}

代码示例来源:origin: firebase/firebase-admin-java

private static void disconnectQuietly(HttpResponse response) {
 if (response != null) {
  try {
   response.disconnect();
  } catch (IOException ignored) {
   // ignored
  }
 }
}

代码示例来源:origin: firebase/firebase-admin-java

private static void disconnectQuietly(HttpResponse response) {
 if (response != null) {
  try {
   response.disconnect();
  } catch (IOException ignored) {
   // Ignored.
  }
 }
}

代码示例来源:origin: com.testdroid/testdroid-api

protected void disconnectQuitely(HttpResponse httpResponse) {
    if (httpResponse != null) {
      try {
        httpResponse.disconnect();
      } catch (IOException exc) {
        //ignore
      }
    }
  }
}

代码示例来源:origin: deric/gitlab-ci-mesos

public void content(HttpResponse response) throws IOException {
  //Result result = response.parseAs(Result.class);
  System.out.println(response.getStatusCode());
  System.out.println(response.getStatusMessage());
  System.out.println(response.getContentType());
  InputStream is = response.getContent();
  int ch;
  while ((ch = is.read()) != -1) {
    System.out.print((char) ch);
  }
  response.disconnect();
}

代码示例来源:origin: siom79/jdrivesync

private HttpResponse executeHttpRequest(HttpRequest httpRequest) throws IOException {
    HttpResponse httpResponse = null;
    try {
      httpRequest.setThrowExceptionOnExecuteError(false);
      return httpResponse = httpRequest.execute();
    } finally {
      if (httpResponse != null) {
        try {
          httpResponse.disconnect();
        } catch (IOException e) {
          throw new JDriveSyncException(JDriveSyncException.Reason.IOException, "Failed to disconnect HTTP request: " + e.getMessage(), e);
        }
      }
    }
  }
}

代码示例来源:origin: com.google.cloud.bigdataoss/gcsio

@Override
 public Boolean load(String bucketName) throws Exception {
  try {
   gcs.buckets()
     .testIamPermissions(bucketName, iamPermissions)
     .executeUnparsed()
     .disconnect();
  } catch (IOException e) {
   return errorExtractor.userProjectMissing(e);
  }
  return false;
 }
});

代码示例来源:origin: firebase/firebase-admin-java

@Override
public byte[] sign(byte[] payload) throws IOException {
 String encodedUrl = String.format(IAM_SIGN_BLOB_URL, serviceAccount);
 HttpResponse response = null;
 String encodedPayload = BaseEncoding.base64().encode(payload);
 Map<String, String> content = ImmutableMap.of("bytesToSign", encodedPayload);
 try {
  HttpRequest request = requestFactory.buildPostRequest(new GenericUrl(encodedUrl),
    new JsonHttpContent(jsonFactory, content));
  request.setParser(new JsonObjectParser(jsonFactory));
  request.setResponseInterceptor(interceptor);
  response = request.execute();
  SignBlobResponse parsed = response.parseAs(SignBlobResponse.class);
  return BaseEncoding.base64().decode(parsed.signature);
 } finally {
  if (response != null) {
   try {
    response.disconnect();
   } catch (IOException ignored) {
    // Ignored
   }
  }
 }
}

代码示例来源:origin: com.google.api-client/google-api-client

IOUtils.copy(response.getContent(), outputStream);
} finally {
 response.disconnect();

代码示例来源:origin: googleapis/google-auth-library-java

return OAuth2Utils.headersContainValue(headers, "Metadata-Flavor", "Google");
} finally {
 response.disconnect();

代码示例来源:origin: com.google.auth/google-auth-library-oauth2-http

return OAuth2Utils.headersContainValue(headers, "Metadata-Flavor", "Google");
} finally {
 response.disconnect();

代码示例来源:origin: com.google.api-client/google-api-client

static boolean runningOnComputeEngine(HttpTransport transport,
  SystemEnvironmentProvider environment) {
 // If the environment has requested that we do no GCE checks, return immediately.
 if (Boolean.parseBoolean(environment.getEnv("NO_GCE_CHECK"))) {
  return false;
 }
 GenericUrl tokenUrl = new GenericUrl(getMetadataServerUrl(environment));
 for (int i = 1; i <= MAX_COMPUTE_PING_TRIES; ++i) {
  try {
   HttpRequest request = transport.createRequestFactory().buildGetRequest(tokenUrl);
   request.setConnectTimeout(COMPUTE_PING_CONNECTION_TIMEOUT_MS);
   HttpResponse response = request.execute();
   try {
    HttpHeaders headers = response.getHeaders();
    return headersContainValue(headers, "Metadata-Flavor", "Google");
   } finally {
    response.disconnect();
   }
  } catch (SocketTimeoutException expected) {
   // Ignore logging timeouts which is the expected failure mode in non GCE environments.
  } catch (IOException e) {
   LOGGER.log(
     Level.WARNING,
     "Failed to detect whether we are running on Google Compute Engine.",
     e);
  }
 }
 return false;
}

代码示例来源:origin: firebase/firebase-admin-java

if (response != null) {
 try {
  response.disconnect();
 } catch (IOException ignored) {

代码示例来源:origin: com.google.api-client/google-api-client

} finally {
 if (!responseProcessed) {
  response.disconnect();

代码示例来源:origin: com.google.api-client/google-api-client

/**
 * This method sends a POST request with empty content to get the unique upload URL.
 *
 * @param initiationRequestUrl The request URL where the initiation request will be sent
 */
private HttpResponse executeUploadInitiation(GenericUrl initiationRequestUrl) throws IOException {
 updateStateAndNotifyListener(UploadState.INITIATION_STARTED);
 initiationRequestUrl.put("uploadType", "resumable");
 HttpContent content = metadata == null ? new EmptyContent() : metadata;
 HttpRequest request =
   requestFactory.buildRequest(initiationRequestMethod, initiationRequestUrl, content);
 initiationHeaders.set(CONTENT_TYPE_HEADER, mediaContent.getType());
 if (isMediaLengthKnown()) {
  initiationHeaders.set(CONTENT_LENGTH_HEADER, getMediaContentLength());
 }
 request.getHeaders().putAll(initiationHeaders);
 HttpResponse response = executeCurrentRequest(request);
 boolean notificationCompleted = false;
 try {
  updateStateAndNotifyListener(UploadState.INITIATION_COMPLETE);
  notificationCompleted = true;
 } finally {
  if (!notificationCompleted) {
   response.disconnect();
  }
 }
 return response;
}

相关文章