Example usage for javax.servlet.http HttpServletResponse getHeader

List of usage examples for javax.servlet.http HttpServletResponse getHeader

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse getHeader.

Prototype

public String getHeader(String name);

Source Link

Document

Gets the value of the response header with the given name.

Usage

From source file:org.openrepose.commons.utils.logging.apache.format.stock.ResponseBytesClfHandler.java

@Override
public String handle(HttpServletRequest request, HttpServletResponse response) {
    String contentLength = "-1";
    String contentLengthHeader = response.getHeader(CommonHttpHeader.CONTENT_LENGTH.toString());

    if (StringUtils.isNotBlank(contentLengthHeader)) {
        try {//from w  ww.  j  a va 2s. com
            int parsedContentLength = Integer.parseInt(contentLengthHeader);
            contentLength = parsedContentLength == 0 ? NO_DATA : String.valueOf(parsedContentLength);
        } catch (NumberFormatException nfe) {
            LOG.warn("Unparsable integer value in Content-Length header. Value: " + contentLengthHeader, nfe);
        }
    } else {
        LOG.debug("No Content-Length header could be found");
    }

    return contentLength;
}

From source file:org.openrepose.commons.utils.logging.apache.format.stock.ResponseBytesHandler.java

@Override
public String handle(HttpServletRequest request, HttpServletResponse response) {
    String contentLength = "-1";
    String contentLengthHeader = response.getHeader(CommonHttpHeader.CONTENT_LENGTH.toString());

    if (StringUtils.isNotBlank(contentLengthHeader)) {
        try {/*from w  ww  .j a  v  a  2  s . c  o m*/
            contentLength = String.valueOf(Integer.parseInt(contentLengthHeader));
        } catch (NumberFormatException nfe) {
            LOG.warn("Unparsable integer value in Content-Length header. Value: " + contentLengthHeader, nfe);
        }
    } else {
        LOG.debug("No Content-Length header could be found");
    }

    return contentLength;
}

From source file:org.springframework.boot.actuate.trace.WebRequestTraceFilter.java

private Map<String, String> getResponseHeaders(HttpServletResponse response) {
    Map<String, String> headers = new LinkedHashMap<String, String>();
    for (String header : response.getHeaderNames()) {
        String value = response.getHeader(header);
        headers.put(header, value);/*from www. j  a va  2s. c o m*/
    }
    headers.put("status", "" + response.getStatus());
    return headers;
}

From source file:org.xlcloud.xsa.meter.ApiCallMeteringFilter.java

private static Map<String, String> getHeadersMap(HttpServletResponse response) {
    Map<String, String> map = new HashMap<String, String>();
    for (String header : response.getHeaderNames()) {
        map.put(header, response.getHeader(header));
    }//from www  . j a  va2s  . co  m
    return map;
}