Search in sources :

Example 61 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class CssUrlReplacerTest method newApplication.

@Override
protected WebApplication newApplication() {
    return new MockApplication() {

        @Override
        protected void init() {
            super.init();
            getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy("=VER=", new MessageDigestResourceVersion()) {

                @Override
                public void decorateUrl(ResourceUrl url, IStaticCacheableResource resource) {
                    url.setFileName(url.getFileName() + DECORATION_SUFFIX);
                }
            });
        }

        @Override
        public Session newSession(Request request, Response response) {
            Session newSession = super.newSession(request, response);
            newSession.setLocale(Locale.ROOT);
            return newSession;
        }
    };
}
Also used : FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy) IStaticCacheableResource(org.apache.wicket.request.resource.caching.IStaticCacheableResource) Response(org.apache.wicket.request.Response) MockApplication(org.apache.wicket.mock.MockApplication) Request(org.apache.wicket.request.Request) MessageDigestResourceVersion(org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Session(org.apache.wicket.Session)

Example 62 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class Jetty9PushBuilder method push.

@Override
public void push(HttpServletRequest httpServletRequest, PushItem... pushItems) {
    Request request = RequestCycle.get().getRequest();
    HttpServletRequest httpRequest = (HttpServletRequest) request.getContainerRequest();
    final org.eclipse.jetty.server.PushBuilder pushBuilder = org.eclipse.jetty.server.Request.getBaseRequest(httpRequest).getPushBuilder();
    if (pushBuilder != null) {
        for (PushItem pushItem : pushItems) {
            pushBuilder.path(pushItem.getUrl());
            pushItem.getHeaders().entrySet().stream().forEach(pushHeader -> {
                String key = pushHeader.getKey();
                PushItemHeaderValue value = pushHeader.getValue();
                if (value.getOperation() == HeaderOperation.ADD) {
                    pushBuilder.addHeader(key, value.getValue());
                } else {
                    pushBuilder.setHeader(key, value.getValue());
                }
            });
            pushBuilder.push();
        }
    } else {
        LOG.warn("Attempted to use HTTP2 Push but it is not supported for the current request: {}!", httpRequest);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.wicket.request.Request)

Example 63 with Request

use of org.apache.wicket.request.Request in project midpoint by Evolveum.

the class SecurityUtils method getCsrfToken.

public static CsrfToken getCsrfToken() {
    Request req = RequestCycle.get().getRequest();
    HttpServletRequest httpReq = (HttpServletRequest) req.getContainerRequest();
    return (CsrfToken) httpReq.getAttribute("_csrf");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.wicket.request.Request) CsrfToken(org.springframework.security.web.csrf.CsrfToken)

Aggregations

Request (org.apache.wicket.request.Request)63 Test (org.junit.Test)28 IRequestHandler (org.apache.wicket.request.IRequestHandler)26 Url (org.apache.wicket.request.Url)23 WebRequest (org.apache.wicket.request.http.WebRequest)9 Response (org.apache.wicket.request.Response)8 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)6 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)6 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)6 IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)5 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)5 MockApplication (org.apache.wicket.mock.MockApplication)4 MockHttpServletRequest (org.apache.wicket.protocol.http.mock.MockHttpServletRequest)4 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)3 Attributes (org.apache.wicket.request.resource.IResource.Attributes)3 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)3 UrlAttributes (org.apache.wicket.request.resource.ResourceReference.UrlAttributes)3 ByteArrayResponse (org.apache.wicket.response.ByteArrayResponse)3