本文整理了Java中io.sphere.sdk.http.HttpResponse.getHeaders()
方法的一些代码示例,展示了HttpResponse.getHeaders()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.getHeaders()
方法的具体详情如下:
包路径:io.sphere.sdk.http.HttpResponse
类名称:HttpResponse
方法名:getHeaders
暂无
代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-java-client-core
private List<String> getDeprecationNoticeHeaderValues(final HttpResponse response) {
return response.getHeaders().getHeader(SphereHttpHeaders.X_DEPRECATION_NOTICE);
}
代码示例来源:origin: io.sphere.sdk.jvm/sphere-java-client-core
private List<String> getDeprecationNoticeHeaderValues(final HttpResponse response) {
return response.getHeaders().getHeader(SphereHttpHeaders.X_DEPRECATION_NOTICE);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
private List<String> getDeprecationNoticeHeaderValues(final HttpResponse response) {
return response.getHeaders().getHeader(SphereHttpHeaders.X_DEPRECATION_NOTICE);
}
代码示例来源:origin: io.sphere.sdk.jvm/java-client-core
private List<String> getDeprecationNoticeHeaderValues(final HttpResponse response) {
return response.getHeaders().getHeader(SphereHttpHeaders.X_DEPRECATION_NOTICE);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Nullable
@Override
public T deserialize(final HttpResponse httpResponse) {
final long startTimestamp = System.currentTimeMillis();
final T result = super.deserialize(httpResponse);
final long stopTimestamp = System.currentTimeMillis();
final long duration = stopTimestamp - startTimestamp;
correlationId = httpResponse.getHeaders().findFlatHeader("X-Correlation-ID").orElse(null);
observable.notifyObservers(ObservedDeserializationDuration.of(duration, id, delegate, correlationId, httpResponse, result));
return result;
}
代码示例来源:origin: io.sphere.sdk.jvm/common
default HttpResponse withoutRequest() {
return HttpResponse.of(getStatusCode(), getResponseBody(), Optional.<HttpRequest>empty(), Optional.of(getHeaders()));
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
.map(r -> r.getHeaders())
.flatMap(headers -> headers.findFlatHeader(correlationIdHeaderName))
.map(id -> " with " + correlationIdHeaderName + " `" + id + "`")
代码示例来源:origin: commercetools/commercetools-jvm-sdk
default HttpResponse withoutRequest() {
return HttpResponse.of(getStatusCode(), getResponseBody(), null, getHeaders());
}
}
代码示例来源:origin: io.sphere.sdk.jvm/sphere-java-client-core
private static <T> T processHttpResponse(final SphereRequest<T> sphereRequest, final ObjectMapper objectMapper, final SphereApiConfig config, final HttpResponse httpResponse) {
final SphereInternalLogger logger = getLogger(httpResponse);
logger.debug(() -> httpResponse);
logger.trace(() -> httpResponse.getStatusCode() + "\n" + Optional.ofNullable(httpResponse.getResponseBody()).map(body -> SphereJsonUtils.prettyPrint(bytesToString(body))).orElse("No body present.") + "\n");
final List<String> notices = httpResponse.getHeaders().getHeadersAsMap().get(SphereHttpHeaders.X_DEPRECATION_NOTICE);
if (notices != null) {
notices.stream().forEach(message -> logger.warn(() -> "Deprecation notice : " + message));
}
return parse(sphereRequest, objectMapper, config, httpResponse);
}
代码示例来源:origin: io.sphere.sdk.jvm/sdk-http
default HttpResponse withoutRequest() {
return HttpResponse.of(getStatusCode(), getResponseBody(), null, getHeaders());
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
private static <T> T processHttpResponse(final SphereRequest<T> sphereRequest, final ObjectMapper objectMapper, final SphereApiConfig config, final HttpResponse httpResponse, final HttpRequest httpRequest) {
final SphereInternalLogger logger = getLogger(httpResponse);
logger.debug(() -> httpResponse);
logger.trace(() -> httpResponse.getStatusCode() + "\n" + Optional.ofNullable(httpResponse.getResponseBody()).map(body -> SphereJsonUtils.prettyPrint(bytesToString(body))).orElse("No body present."));
final List<String> notices = httpResponse.getHeaders().getHeadersAsMap().get(SphereHttpHeaders.X_DEPRECATION_NOTICE);
if (notices != null) {
notices.forEach(message -> logger.warn(() -> "Deprecation notice : " + message));
}
return parse(sphereRequest, objectMapper, config, httpResponse, httpRequest);
}
代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-java-client-core
private static <T> T processHttpResponse(final SphereRequest<T> sphereRequest, final ObjectMapper objectMapper, final SphereApiConfig config, final HttpResponse httpResponse, final HttpRequest httpRequest) {
final SphereInternalLogger logger = getLogger(httpResponse);
logger.debug(() -> httpResponse);
logger.trace(() -> httpResponse.getStatusCode() + "\n" + Optional.ofNullable(httpResponse.getResponseBody()).map(body -> SphereJsonUtils.prettyPrint(bytesToString(body))).orElse("No body present."));
final List<String> notices = httpResponse.getHeaders().getHeadersAsMap().get(SphereHttpHeaders.X_DEPRECATION_NOTICE);
if (notices != null) {
notices.forEach(message -> logger.warn(() -> "Deprecation notice : " + message));
}
return parse(sphereRequest, objectMapper, config, httpResponse, httpRequest);
}
代码示例来源:origin: io.sphere.sdk.jvm/java-client-core
static <T> Function<HttpResponse, T> preProcess(final SphereRequest<T> sphereRequest, final ObjectMapper objectMapper, final SphereApiConfig config) {
return httpResponse -> {
final SphereInternalLogger logger = getLogger(httpResponse);
logger.debug(() -> httpResponse);
logger.trace(() -> httpResponse.getStatusCode() + "\n" + httpResponse.getResponseBody().map(body -> JsonUtils.prettyPrintJsonStringSecure(bytesToString(body))).orElse("No body present.") + "\n");
final List<String> notices = httpResponse.getHeaders().getHeadersAsMap().get(SphereHttpHeaders.X_DEPRECATION_NOTICE);
if (notices != null) {
notices.stream().forEach(message -> logger.warn(() -> "Deprecation notice : " + message));
}
return parse(httpResponse, sphereRequest, objectMapper, config);
};
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Override
public Project deserialize(HttpResponse httpResponse) {
correlationId = httpResponse.getHeaders().findFlatHeader(HttpHeaders.X_CORRELATION_ID);
return super.deserialize(httpResponse);
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void execute() {
withCategory(client(), category -> {
final CategoryByIdGet originalRequest = CategoryByIdGet.of(category);
final JavaAndHttpResponseSphereRequest<Category> request =
JavaAndHttpResponseSphereRequest.of(originalRequest);
final Pair<Category, HttpResponse> result = client().executeBlocking(request);
final Category categoryJavaObject = result.getLeft();
final HttpResponse httpResponse = result.getRight();
assertThat(categoryJavaObject).isEqualTo(category);
assertThat(httpResponse.getHeaders().findFlatHeader(HttpHeaders.CONTENT_TYPE).get())
.contains("application/json");
});
}
}
内容来源于网络,如有侵权,请联系作者删除!