Example usage for org.springframework.web.client HttpStatusCodeException getResponseHeaders

List of usage examples for org.springframework.web.client HttpStatusCodeException getResponseHeaders

Introduction

In this page you can find the example usage for org.springframework.web.client HttpStatusCodeException getResponseHeaders.

Prototype

@Nullable
public HttpHeaders getResponseHeaders() 

Source Link

Document

Return the HTTP response headers.

Usage

From source file:am.ik.categolj2.app.authentication.AuthenticationHelper.java

void handleHttpStatusCodeException(HttpStatusCodeException e, RedirectAttributes attributes)
        throws IOException {
    if (logger.isInfoEnabled()) {
        logger.info("authentication failed (message={},X-Track={})", e.getMessage(),
                e.getResponseHeaders().get("X-Track"));
    }/*from ww w .j  ava 2 s  .c  o  m*/
    try {
        OAuth2Exception oAuth2Exception = objectMapper.readValue(e.getResponseBodyAsByteArray(),
                OAuth2Exception.class);
        attributes.addAttribute("error", oAuth2Exception.getMessage());
    } catch (JsonMappingException | JsonParseException ex) {
        attributes.addAttribute("error", e.getMessage());
    }
}