use of org.apache.wicket.request.Request in project wicket by apache.
the class UndertowPushBuilder method push.
@Override
public void push(HttpServletRequest httpServletRequest, PushItem... pushItems) {
Request request = RequestCycle.get().getRequest();
HttpServletRequest httpRequest = (HttpServletRequest) request.getContainerRequest();
io.undertow.servlet.spec.HttpServletRequestImpl undertowRequest = (io.undertow.servlet.spec.HttpServletRequestImpl) httpRequest;
// Added explicit cast here to ensure this is the implementation of undertow
io.undertow.servlet.spec.PushBuilderImpl pushBuilder = (io.undertow.servlet.spec.PushBuilderImpl) undertowRequest.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);
}
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class Tomcat85PushBuilder method push.
@Override
public void push(HttpServletRequest httpServletRequest, PushItem... pushItems) {
Request request = RequestCycle.get().getRequest();
HttpServletRequest httpRequest = (HttpServletRequest) request.getContainerRequest();
org.apache.catalina.connector.RequestFacade tomcatRequest = (org.apache.catalina.connector.RequestFacade) httpRequest;
ApplicationPushBuilder pushBuilder = (ApplicationPushBuilder) tomcatRequest.newPushBuilder();
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);
}
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class Servlet4PushBuilder method push.
@Override
public void push(HttpServletRequest httpServletRequest, PushItem... pushItems) {
Request request = RequestCycle.get().getRequest();
HttpServletRequest httpRequest = (HttpServletRequest) request.getContainerRequest();
javax.servlet.http.PushBuilder pushBuilder = httpRequest.newPushBuilder();
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);
}
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class WebPageRenderer method isAjax.
protected boolean isAjax(RequestCycle requestCycle) {
boolean isAjax = false;
Request request = requestCycle.getRequest();
if (request instanceof WebRequest) {
WebRequest webRequest = (WebRequest) request;
isAjax = webRequest.isAjax();
}
return isAjax;
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class CustomHomeMapper method mapRequest.
/**
* Removes the leading segment if it a valid Locale
*
* @see org.apache.wicket.core.request.mapper.HomePageMapper#mapRequest(org.apache.wicket.request.Request)
*/
@Override
public IRequestHandler mapRequest(Request request) {
IRequestHandler requestHandler = null;
Url url = request.getUrl();
List<String> segments = url.getSegments();
if (segments.size() == 1) {
String localeAsString = segments.get(0);
Locale locale = LocaleHelper.parseLocale(localeAsString);
if (locale != null) {
Session.get().setLocale(locale);
segments.remove(0);
Request requestWithoutLocale = request.cloneWithUrl(url);
requestHandler = super.mapRequest(requestWithoutLocale);
}
}
return requestHandler;
}
Aggregations