Search in sources :

Example 1 with HttpResponseHeaderContributor

use of org.eclipse.scout.rt.server.commons.servlet.cache.HttpResponseHeaderContributor in project scout.rt by eclipse.

the class HtmlFileLoader method loadResource.

@Override
public HttpCacheObject loadResource(HttpCacheKey cacheKey) throws IOException {
    String pathInfo = cacheKey.getResourcePath();
    BinaryResource content = loadResource(pathInfo);
    if (content == null) {
        return null;
    }
    // no cache-control, only E-Tag checks to make sure that a session with timeout is correctly
    // forwarded to the login using a GET request BEFORE the first json POST request
    HttpCacheObject httpCacheObject = new HttpCacheObject(cacheKey, content);
    // Suppress automatic "compatibility mode" in IE in intranet zone
    httpCacheObject.addHttpResponseInterceptor(new HttpResponseHeaderContributor("X-UA-Compatible", "IE=edge") {

        private static final long serialVersionUID = 1L;

        @Override
        public void intercept(HttpServletRequest req, HttpServletResponse resp) {
            HttpClientInfo httpClientInfo = HttpClientInfo.get(req);
            if (httpClientInfo.isMshtml()) {
                // Send headers only for IE
                super.intercept(req, resp);
            }
        }
    });
    return httpCacheObject;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) BinaryResource(org.eclipse.scout.rt.platform.resource.BinaryResource) HttpResponseHeaderContributor(org.eclipse.scout.rt.server.commons.servlet.cache.HttpResponseHeaderContributor) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpCacheObject(org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheObject) HttpClientInfo(org.eclipse.scout.rt.server.commons.servlet.HttpClientInfo)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 BinaryResource (org.eclipse.scout.rt.platform.resource.BinaryResource)1 HttpClientInfo (org.eclipse.scout.rt.server.commons.servlet.HttpClientInfo)1 HttpCacheObject (org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheObject)1 HttpResponseHeaderContributor (org.eclipse.scout.rt.server.commons.servlet.cache.HttpResponseHeaderContributor)1