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

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

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

HttpClient.getUserAgent介绍

暂无

代码示例

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

@Nullable
@Override
public String getUserAgent() {
  return delegate.getUserAgent();
}

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

@Nullable
@Override
public String getUserAgent() {
  return httpClient.getUserAgent();
}

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

private static String userAgent(final HttpClient httpClient) {
  final String template = "${sdkLikeGitHubRepo}/${sdkVersion} (${underlyingHttpClient}) ${runtime}/${runtimeVersion} (${optionalOs}; ${optionalOsarch}) ${solutionInfos}";
  final Map<String, String> values = new HashMap<>();
  values.put("sdkLikeGitHubRepo", "commercetools-jvm-sdk");
  values.put("sdkVersion", BuildInfo.version());
  final String underlyingHttpClient = Optional.ofNullable(httpClient.getUserAgent()).orElse("unknown/" + BuildInfo.version());
  values.put("underlyingHttpClient", underlyingHttpClient);
  values.put("runtime", "Java");
  values.put("runtimeVersion", SystemUtils.JAVA_RUNTIME_VERSION);
  values.put("optionalOs", SystemUtils.OS_NAME);
  values.put("optionalOsarch", SystemUtils.OS_ARCH);
  values.put("solutionInfos", getSolutionInfoString());
  return new StrSubstitutor(values).replace(template).trim();
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-java-client-core

private static String userAgent(final HttpClient httpClient) {
  final String template = "${sdkLikeGitHubRepo}/${sdkVersion} (${underlyingHttpClient}) ${runtime}/${runtimeVersion} (${optionalOs}; ${optionalOsarch}) ${solutionInfos}";
  final Map<String, String> values = new HashMap<>();
  values.put("sdkLikeGitHubRepo", "commercetools-jvm-sdk");
  values.put("sdkVersion", BuildInfo.version());
  final String underlyingHttpClient = Optional.ofNullable(httpClient.getUserAgent()).orElse("unknown/" + BuildInfo.version());
  values.put("underlyingHttpClient", underlyingHttpClient);
  values.put("runtime", "Java");
  values.put("runtimeVersion", SystemUtils.JAVA_RUNTIME_VERSION);
  values.put("optionalOs", SystemUtils.OS_NAME);
  values.put("optionalOsarch", SystemUtils.OS_ARCH);
  values.put("solutionInfos", getSolutionInfoString());
  return new StrSubstitutor(values).replace(template).trim();
}

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

@Test
public final void userAgent() throws Exception {
  try (final HttpClient client = createClient()) {
    assertThat(client.getUserAgent()).matches("\\S+/\\S+");
  }
}

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

when(sphereApiConfig.getProjectKey()).thenReturn(projectKey);
when(sphereApiConfig.getApiUrl()).thenReturn("http://api.commercetools.de");
when(httpClient.getUserAgent()).thenReturn("user-agent");
when(sphereAccessTokenSupplier.get()).thenReturn(CompletableFutureUtils.successful("token"));

相关文章