Java 类org.springframework.web.client.RestClientResponseException 实例源码

项目:java-buildpack-metric-writer    文件:RestOperationsMetricPublisher.java   
private Long getRetryAfter(Exception candidate) {
    if (candidate instanceof RestClientResponseException) {
        String retryAfter = ((RestClientResponseException) candidate).getResponseHeaders().getFirst(RETRY_AFTER);

        if (retryAfter != null) {
            return System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(Long.parseLong(retryAfter));
        }
    }

    return null;
}
项目:java-restify    文件:ErrorHttpResponseMessage.java   
public static ErrorHttpResponseMessage from(RequestEntity<Object> request, RestClientResponseException e) {
    StatusCode statusCode = StatusCode.of(e.getRawStatusCode(), e.getStatusText());

    Headers headers = new Headers();
    e.getResponseHeaders().forEach((k, v) -> headers.put(k, v));

    InputStream body = new ByteArrayInputStream(e.getResponseBodyAsByteArray());

    return new ErrorHttpResponseMessage(statusCode, headers, body, new ErrorHttpRequestMessage(request));
}