Example usage for com.google.common.net HttpHeaders AGE

List of usage examples for com.google.common.net HttpHeaders AGE

Introduction

In this page you can find the example usage for com.google.common.net HttpHeaders AGE.

Prototype

String AGE

To view the source code for com.google.common.net HttpHeaders AGE.

Click Source Link

Document

The HTTP Age header field name.

Usage

From source file:org.wso2.carbon.mediator.cache.util.HttpCachingFilter.java

/**
 * This method sets the Age header./* w  w w . j  a va2s  .  c  o  m*/
 *
 * @param cachedResponse The cached response to be returned.
 * @param msgCtx         The messageContext.
 */
@SuppressWarnings("unchecked")
public static void setAgeHeader(CachableResponse cachedResponse,
        org.apache.axis2.context.MessageContext msgCtx) {
    Map excessHeaders = new MultiValueMap();
    long responseCachedTime = cachedResponse.getResponseFetchedTime();
    long age = Math.abs((responseCachedTime - System.currentTimeMillis()) / 1000);
    excessHeaders.put(HttpHeaders.AGE, String.valueOf(age));

    msgCtx.setProperty(NhttpConstants.EXCESS_TRANSPORT_HEADERS, excessHeaders);
}