Search in sources :

Example 16 with RequestHandler

use of act.handler.RequestHandler in project actframework by actframework.

the class ActionContext method applyContentSecurityPolicy.

public ActionContext applyContentSecurityPolicy() {
    RequestHandler handler = handler();
    if (null != handler) {
        boolean disableCSP = handler.disableContentSecurityPolicy();
        if (disableCSP) {
            return this;
        }
        String csp = handler.contentSecurityPolicy();
        if (S.notBlank(csp)) {
            H.Response resp = resp();
            resp.addHeaderIfNotAdded(CONTENT_SECURITY_POLICY, csp);
        }
    }
    applyGlobalCspSetting();
    return this;
}
Also used : RequestHandler(act.handler.RequestHandler) H(org.osgl.http.H)

Aggregations

RequestHandler (act.handler.RequestHandler)16 Test (org.junit.Test)7 H (org.osgl.http.H)7 FileGetter (act.handler.builtin.FileGetter)5 File (java.io.File)4 FastRequestHandler (act.handler.builtin.controller.FastRequestHandler)2 PreHandle (act.handler.event.PreHandle)2 EventBus (act.event.EventBus)1 AlwaysNotFound (act.handler.builtin.AlwaysNotFound)1 Echo (act.handler.builtin.Echo)1 ResourceGetter (act.handler.builtin.ResourceGetter)1 PostHandle (act.handler.event.PostHandle)1 Timer (act.metric.Timer)1 CORS (act.security.CORS)1 ActErrorResult (act.view.ActErrorResult)1 UndertowRequest (act.xio.undertow.UndertowRequest)1 URL (java.net.URL)1 NotAppliedException (org.osgl.exception.NotAppliedException)1 ErrorResult (org.osgl.mvc.result.ErrorResult)1 NotFound (org.osgl.mvc.result.NotFound)1