本文整理汇总了Java中ro.pippo.core.Request类的典型用法代码示例。如果您正苦于以下问题:Java Request类的具体用法?Java Request怎么用?Java Request使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Request类属于ro.pippo.core包,在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RestServlet
import ro.pippo.core.Request; //导入依赖的package包/类
@Inject
public RestServlet(Application application) {
this.application = application;
this.routeDispatcher = new RouteDispatcher(application) {
protected RouteContextFactory<?> getRouteContextFactory() {
return new RouteContextFactory<Context>() {
@Override
public Context createRouteContext(Application application, Request request, Response response, List<RouteMatch> list) {
return new Context(application, request, response, list);
}
@Override
public void init(Application application) {
}
@Override
public void destroy(Application application) {
}
};
}
};
}
示例2: handle
import ro.pippo.core.Request; //导入依赖的package包/类
@Override
public void handle(RouteContext routeContext) {
// get request path
Request request = routeContext.getRequest();
String path = request.getPath();
// add or remove trailing slash
if (path.length() > 1) {
if (addSlash) {
path = StringUtils.addEnd(path, "/");
} else {
path = StringUtils.removeEnd(path, "/");
}
}
if (!path.equals(request.getPath())) {
// redirect
routeContext.redirect(path);
} else {
// continue with the next handler
routeContext.next();
}
}
示例3: processWebSocketRequest
import ro.pippo.core.Request; //导入依赖的package包/类
private void processWebSocketRequest(Request request, Response response) {
HttpServletRequest servletRequest = request.getHttpServletRequest();
HttpServletResponse servletResponse = response.getHttpServletResponse();
WebSocketHttpExchange exchange = new ServletWebSocketHttpExchange(servletRequest, servletResponse, peerConnections);
// exchange.putAttachment(HandshakeUtil.PATH_PARAMS, Collections.<String, String>emptyMap());
Handshake handshake = getHandshake(exchange);
exchange.upgradeChannel((connection, serverExchange) -> {
WebSocketChannel channel = handshake.createChannel(exchange, connection, exchange.getBufferPool());
peerConnections.add(channel);
createWebSocketAdapter(request).onConnect(exchange, channel);
});
handshake.handshake(exchange);
}
示例4: makePippoWebContext
import ro.pippo.core.Request; //导入依赖的package包/类
private PippoWebContext makePippoWebContext() {
Request request = makeRequest();
response = makeResponse();
when(mockRouteContext.getRequest()).thenReturn(request);
when(mockRouteContext.getResponse()).thenReturn(response);
return new PippoWebContext(mockRouteContext, null);
}
示例5: doFilterInternal
import ro.pippo.core.Request; //导入依赖的package包/类
protected void doFilterInternal(ServletRequest servletRequest, ServletResponse servletResponse, final FilterChain chain)
throws ServletException, IOException {
try {
super.doFilterInternal(servletRequest, servletResponse, chain);
} catch (Exception exception) {
Exception root = (Exception) Throwables.getRootCause(exception);
Request request = new Request((HttpServletRequest) servletRequest, application);
Response response = new Response((HttpServletResponse) servletResponse, application);
Context routeContext = new Context(application, request, response, Collections.emptyList());
errorHandler.handle(root, routeContext);
}
}
示例6: getAcceptTypes
import ro.pippo.core.Request; //导入依赖的package包/类
private Set<String> getAcceptTypes(Request request) {
Set<String> types = new LinkedHashSet<>();
types.addAll(getContentTypes(request.getAcceptType()));
types.addAll(getContentTypes(request.getHttpServletRequest().getHeader(HttpConstants.Header.ACCEPT)));
return types;
}
示例7: getContentTypes
import ro.pippo.core.Request; //导入依赖的package包/类
private Set<String> getContentTypes(Request request) {
Set<String> types = new LinkedHashSet<>();
types.addAll(getContentTypes(request.getContentType()));
types.addAll(getContentTypes(request.getHttpServletRequest().getContentType()));
return types;
}
示例8: headerContainsToken
import ro.pippo.core.Request; //导入依赖的package包/类
private boolean headerContainsToken(Request request, String headerName, String target) {
Enumeration<String> headers = request.getHeaders(headerName);
while (headers.hasMoreElements()) {
String header = headers.nextElement();
String[] tokens = header.split(",");
for (String token : tokens) {
if (target.equalsIgnoreCase(token.trim())) {
return true;
}
}
}
return false;
}
示例9: getTokensFromHeader
import ro.pippo.core.Request; //导入依赖的package包/类
protected List<String> getTokensFromHeader(Request request, String headerName) {
List<String> result = new ArrayList<>();
Enumeration<String> headers = request.getHeaders(headerName);
while (headers.hasMoreElements()) {
String header = headers.nextElement();
String[] tokens = header.split(",");
for (String token : tokens) {
result.add(token.trim());
}
}
return result;
}
示例10: createRouteContext
import ro.pippo.core.Request; //导入依赖的package包/类
@Override
public DefaultRouteContext createRouteContext(Application application,
Request request,
Response response,
List<RouteMatch> routeMatches) {
return new DefaultRouteContext(application, request, response, routeMatches);
}
示例11: createRequestResponse
import ro.pippo.core.Request; //导入依赖的package包/类
@Override
public RequestResponse createRequestResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
SessionHttpServletRequest sessionHttpServletRequest = new SessionHttpServletRequest(httpServletRequest, sessionManager);
Request request = new Request(sessionHttpServletRequest, application);
Response response = new Response(httpServletResponse, application);
response.getFinalizeListeners().add(r -> sessionHttpServletRequest.commitSession(httpServletResponse));
return new RequestResponse(request, response);
}
示例12: processRequest
import ro.pippo.core.Request; //导入依赖的package包/类
@Override
protected void processRequest(Request request, Response response) throws IOException, ServletException {
if (!acceptWebSocket(request, response)) {
super.processRequest(request, response);
} else {
processWebSocketRequest(request, response);
}
}
示例13: makeRequest
import ro.pippo.core.Request; //导入依赖的package包/类
private Request makeRequest() {
return new Request(mockHttpRequest, mockApplication);
}
示例14: Context
import ro.pippo.core.Request; //导入依赖的package包/类
public Context(Application application, Request request, Response response, List<RouteMatch> routeMatches) {
super(application, request, response, routeMatches);
}
示例15: getRequest
import ro.pippo.core.Request; //导入依赖的package包/类
public final Request getRequest() {
return context.getRequest();
}