当前位置: 首页>>代码示例>>Java>>正文


Java HttpResponse.disconnect方法代码示例

本文整理汇总了Java中com.google.api.client.http.HttpResponse.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse.disconnect方法的具体用法?Java HttpResponse.disconnect怎么用?Java HttpResponse.disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.client.http.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.disconnect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: signInWithCustomToken

import com.google.api.client.http.HttpResponse; //导入方法依赖的package包/类
private String signInWithCustomToken(String customToken) throws IOException {
  GenericUrl url = new GenericUrl(ID_TOOLKIT_URL + "?key="
      + IntegrationTestUtils.getApiKey());
  Map<String, Object> content = ImmutableMap.<String, Object>of(
      "token", customToken, "returnSecureToken", true);
  HttpRequest request = transport.createRequestFactory().buildPostRequest(url,
      new JsonHttpContent(jsonFactory, content));
  request.setParser(new JsonObjectParser(jsonFactory));
  HttpResponse response = request.execute();
  try {
    GenericJson json = response.parseAs(GenericJson.class);
    return json.get("idToken").toString();
  } finally {
    response.disconnect();
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:17,代码来源:FirebaseAuthIT.java

示例2: getPublicKeysJson

import com.google.api.client.http.HttpResponse; //导入方法依赖的package包/类
/**
 *
 * @return
 * @throws IOException
 */
private JsonObject getPublicKeysJson() throws IOException {
    // get public keys
    URI uri = URI.create(pubKeyUrl);
    GenericUrl url = new GenericUrl(uri);
    HttpTransport http = new NetHttpTransport();
    HttpResponse response = http.createRequestFactory().buildGetRequest(url).execute();

    // store json from request
    String json = response.parseAsString();
    // disconnect
    response.disconnect();

    // parse json to object
    JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();

    return jsonObject;
}
 
开发者ID:rvep,项目名称:dev_backend,代码行数:23,代码来源:FirebaseAuthVerifier.java

示例3: get

import com.google.api.client.http.HttpResponse; //导入方法依赖的package包/类
public String get(String url) {
    try {
        HttpRequest request = new NetHttpTransport()
                .createRequestFactory()
                .buildGetRequest(new GenericUrl(url));
        HttpResponse response = request.execute();
        InputStream is = response.getContent();
        StringBuilder sb = new StringBuilder();
        int ch;
        while ((ch = is.read()) != -1) {
            sb.append((char) ch);
        }
        response.disconnect();
        return sb.toString();
    } catch (Exception e) {
        throw new RuntimeException();
    }
}
 
开发者ID:Fewlaps,项目名称:http-monitor,代码行数:19,代码来源:HttpClient.java

示例4: send

import com.google.api.client.http.HttpResponse; //导入方法依赖的package包/类
/** Uploads {@code reportBytes} to ICANN, returning whether or not it succeeded. */
public boolean send(byte[] reportBytes, String reportFilename) throws XmlException, IOException {
  validateReportFilename(reportFilename);
  GenericUrl uploadUrl = new GenericUrl(makeUrl(reportFilename));
  HttpRequest request =
      httpTransport
          .createRequestFactory()
          .buildPutRequest(uploadUrl, new ByteArrayContent(CSV_UTF_8.toString(), reportBytes));

  HttpHeaders headers = request.getHeaders();
  headers.setBasicAuthentication(getTld(reportFilename) + "_ry", password);
  headers.setContentType(CSV_UTF_8.toString());
  request.setHeaders(headers);
  request.setFollowRedirects(false);

  HttpResponse response = null;
  logger.infofmt(
      "Sending report to %s with content length %s",
      uploadUrl.toString(), request.getContent().getLength());
  boolean success = true;
  try {
    response = request.execute();
    byte[] content;
    try {
      content = ByteStreams.toByteArray(response.getContent());
    } finally {
      response.getContent().close();
    }
    logger.infofmt(
        "Received response code %s with content %s",
        response.getStatusCode(), new String(content, UTF_8));
    XjcIirdeaResult result = parseResult(content);
    if (result.getCode().getValue() != 1000) {
      success = false;
      logger.warningfmt(
          "PUT rejected, status code %s:\n%s\n%s",
          result.getCode(),
          result.getMsg(),
          result.getDescription());
    }
  } finally {
    if (response != null) {
      response.disconnect();
    } else {
      success = false;
      logger.warningfmt(
          "Received null response from ICANN server at %s", uploadUrl.toString());
    }
  }
  return success;
}
 
开发者ID:google,项目名称:nomulus,代码行数:52,代码来源:IcannHttpReporter.java


注:本文中的com.google.api.client.http.HttpResponse.disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。