io.sphere.sdk.http.HttpClient.close()方法的使用及代码示例

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

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

HttpClient.close介绍

暂无

代码示例

代码示例来源:origin: io.sphere.jvmsdk/java-client

@Override
public void close() {
  requestExecutor.close();
}

代码示例来源:origin: com.commercetools.sunrise/common

@Override
public void close() {
  underlying.close();
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Override
public void close() {
  client.close();
  closed = true;
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Override
public void close() {
  httpClient.close();
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Override
public void close() {
  delegate.close();
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

final HttpRequest httpRequest = HttpRequest.of(HttpMethod.POST, "http://localhost:" + port, HttpHeaders.of("foo", "bar"), requestBody);
final HttpResponse response = client.execute(httpRequest).toCompletableFuture().get(15, TimeUnit.SECONDS);
client.close();
final String receivedHttpHeadersAndBody = future.join();
LoggerFactory.getLogger(HttpClientAdapterTest.class).info(receivedHttpHeadersAndBody);

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public final void testConnection() {
  final HttpClient client = createClient();
  final HttpResponse response = client.execute(HttpRequest.of(HttpMethod.GET, "http://dev.commercetools.com")).toCompletableFuture().join();
  client.close();
  final String body = new String(response.getResponseBody());
  final Integer statusCode = response.getStatusCode();
  assertThat(statusCode).isLessThan(400);
  assertThat(body).containsIgnoringCase("commercetools");
}

代码示例来源:origin: com.commercetools.payment/common

@Override
  @Nonnull
  public CompletionStage<HttpRequestResult> sendHttpGetRequest(String url) {
    HttpRequest request = HttpRequest.of(HttpMethod.GET, url);

    HttpClient client = SphereClientFactory.of().createHttpClient();

    return client.execute(request)
           .thenApplyAsync(response -> HttpRequestResult.of(request, response, null))
           .exceptionally(throwable -> HttpRequestResult.of(request, null, throwable))
           .whenCompleteAsync((response, throwable) -> client.close());
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
  public void customClient() {
    final HttpClient httpClient = createCustomHttpClient();
    final CompletionStage<HttpResponse> completionStage =
        httpClient.execute(HttpRequest.of(GET, "http://commercetools.com"));
    final HttpResponse httpResponse = completionStage.toCompletableFuture().join();
    assertThat(httpResponse.getStatusCode()).isLessThanOrEqualTo(302);
    httpClient.close();
  }
}

相关文章