io.undertow.servlet.handlers.ServletPathMatch Java Examples
The following examples show how to use
io.undertow.servlet.handlers.ServletPathMatch.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RewriteCorrectingHandlerWrappers.java From quarkus with Apache License 2.0 | 6 votes |
@Override public HttpHandler wrap(final HttpHandler handler) { return new HttpHandler() { @Override public void handleRequest(HttpServerExchange exchange) throws Exception { String old = exchange.getAttachment(OLD_RELATIVE_PATH); if (!old.equals(exchange.getRelativePath())) { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletPathMatch info = src.getDeployment().getServletPaths() .getServletHandlerByPath(exchange.getRelativePath()); src.setCurrentServlet(info.getServletChain()); src.setServletPathMatch(info); } handler.handleRequest(exchange); } }; }
Example #2
Source File: HttpServletRequestImpl.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public HttpServletMapping getHttpServletMapping() { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletPathMatch match = src.getOriginalServletPathMatch(); if (getDispatcherType() == DispatcherType.FORWARD) { match = src.getServletPathMatch(); } String matchValue; switch (match.getMappingMatch()) { case EXACT: matchValue = match.getMatched(); if (matchValue.startsWith("/")) { matchValue = matchValue.substring(1); } break; case DEFAULT: case CONTEXT_ROOT: matchValue = ""; break; case PATH: matchValue = match.getRemaining(); if (matchValue.startsWith("/")) { matchValue = matchValue.substring(1); } break; case EXTENSION: matchValue = match.getMatched().substring(0, match.getMatched().length() - match.getMatchString().length() + 1); if (matchValue.startsWith("/")) { matchValue = matchValue.substring(1); } break; default: matchValue = match.getRemaining(); } return new MappingImpl(matchValue, match.getMatchString(), match.getMappingMatch(), match.getServletChain().getManagedServlet().getServletInfo().getName()); }
Example #3
Source File: HttpServletRequestImpl.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public String getPathInfo() { ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch(); if (match != null) { return match.getRemaining(); } return null; }
Example #4
Source File: HttpServletRequestImpl.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public String getServletPath() { ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch(); if (match != null) { return match.getMatched(); } return ""; }
Example #5
Source File: HttpServletRequestImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public HttpServletMapping getHttpServletMapping() { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletPathMatch match = src.getOriginalServletPathMatch(); if(getDispatcherType() == DispatcherType.FORWARD) { match = src.getServletPathMatch(); } String matchValue; switch (match.getMappingMatch()) { case EXACT: matchValue = match.getMatched(); if(matchValue.startsWith("/")) { matchValue = matchValue.substring(1); } break; case DEFAULT: case CONTEXT_ROOT: matchValue = ""; break; case PATH: matchValue = match.getRemaining(); if(matchValue.startsWith("/")) { matchValue = matchValue.substring(1); } break; case EXTENSION: matchValue = match.getMatched().substring(0, match.getMatched().length() - match.getMatchString().length() + 1); if(matchValue.startsWith("/")) { matchValue = matchValue.substring(1); } break; default: matchValue = match.getRemaining(); } return new MappingImpl(matchValue, match.getMatchString(), match.getMappingMatch(), match.getServletChain().getManagedServlet().getServletInfo().getName()); }
Example #6
Source File: HttpServletRequestImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String getPathInfo() { ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch(); if (match != null) { return match.getRemaining(); } return null; }
Example #7
Source File: HttpServletRequestImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String getServletPath() { ServletPathMatch match = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getServletPathMatch(); if (match != null) { return match.getMatched(); } return ""; }
Example #8
Source File: AsyncContextImpl.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public void dispatch(final ServletContext context, final String path) { if (dispatched) { throw UndertowServletMessages.MESSAGES.asyncRequestAlreadyDispatched(); } HttpServletRequestImpl requestImpl = servletRequestContext.getOriginalRequest(); HttpServletResponseImpl responseImpl = servletRequestContext.getOriginalResponse(); final HttpServerExchange exchange = requestImpl.getExchange(); exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).setDispatcherType(DispatcherType.ASYNC); requestImpl.setAttribute(ASYNC_REQUEST_URI, requestImpl.getOriginalRequestURI()); requestImpl.setAttribute(ASYNC_CONTEXT_PATH, requestImpl.getOriginalContextPath()); requestImpl.setAttribute(ASYNC_SERVLET_PATH, requestImpl.getOriginalServletPath()); requestImpl.setAttribute(ASYNC_QUERY_STRING, requestImpl.getOriginalQueryString()); String newQueryString = ""; int qsPos = path.indexOf("?"); String newServletPath = path; if (qsPos != -1) { newQueryString = newServletPath.substring(qsPos + 1); newServletPath = newServletPath.substring(0, qsPos); } String newRequestUri = context.getContextPath() + newServletPath; //todo: a more efficient impl Map<String, Deque<String>> newQueryParameters = new HashMap<>(); for (String part : newQueryString.split("&")) { String name = part; String value = ""; int equals = part.indexOf('='); if (equals != -1) { name = part.substring(0, equals); value = part.substring(equals + 1); } Deque<String> queue = newQueryParameters.get(name); if (queue == null) { newQueryParameters.put(name, queue = new ArrayDeque<>(1)); } queue.add(value); } requestImpl.setQueryParameters(newQueryParameters); requestImpl.getExchange().setRelativePath(newServletPath); requestImpl.getExchange().setQueryString(newQueryString); requestImpl.getExchange().setRequestPath(newRequestUri); requestImpl.getExchange().setRequestURI(newRequestUri); requestImpl.setServletContext((ServletContextImpl) context); responseImpl.setServletContext((ServletContextImpl) context); Deployment deployment = requestImpl.getServletContext().getDeployment(); ServletPathMatch info = deployment.getServletPaths().getServletHandlerByPath(newServletPath); requestImpl.getExchange().getAttachment(ServletRequestContext.ATTACHMENT_KEY).setServletPathMatch(info); dispatchAsyncRequest(deployment.getServletDispatcher(), info, exchange); }
Example #9
Source File: AsyncContextImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void dispatch(final ServletContext context, final String path) { if (dispatched) { throw UndertowServletMessages.MESSAGES.asyncRequestAlreadyDispatched(); } HttpServletRequestImpl requestImpl = servletRequestContext.getOriginalRequest(); HttpServletResponseImpl responseImpl = servletRequestContext.getOriginalResponse(); final HttpServerExchange exchange = requestImpl.getExchange(); exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).setDispatcherType(DispatcherType.ASYNC); requestImpl.setAttribute(ASYNC_REQUEST_URI, requestImpl.getOriginalRequestURI()); requestImpl.setAttribute(ASYNC_CONTEXT_PATH, requestImpl.getOriginalContextPath()); requestImpl.setAttribute(ASYNC_SERVLET_PATH, requestImpl.getOriginalServletPath()); requestImpl.setAttribute(ASYNC_QUERY_STRING, requestImpl.getOriginalQueryString()); String newQueryString = ""; int qsPos = path.indexOf("?"); String newServletPath = path; if (qsPos != -1) { newQueryString = newServletPath.substring(qsPos + 1); newServletPath = newServletPath.substring(0, qsPos); } String newRequestUri = context.getContextPath() + newServletPath; //todo: a more efficient impl Map<String, Deque<String>> newQueryParameters = new HashMap<>(); for (String part : newQueryString.split("&")) { String name = part; String value = ""; int equals = part.indexOf('='); if (equals != -1) { name = part.substring(0, equals); value = part.substring(equals + 1); } Deque<String> queue = newQueryParameters.get(name); if (queue == null) { newQueryParameters.put(name, queue = new ArrayDeque<>(1)); } queue.add(value); } requestImpl.setQueryParameters(newQueryParameters); requestImpl.getExchange().setRelativePath(newServletPath); requestImpl.getExchange().setQueryString(newQueryString); requestImpl.getExchange().setRequestPath(newRequestUri); requestImpl.getExchange().setRequestURI(newRequestUri); requestImpl.setServletContext((ServletContextImpl) context); responseImpl.setServletContext((ServletContextImpl) context); Deployment deployment = requestImpl.getServletContext().getDeployment(); ServletPathMatch info = deployment.getServletPaths().getServletHandlerByPath(newServletPath); requestImpl.getExchange().getAttachment(ServletRequestContext.ATTACHMENT_KEY).setServletPathMatch(info); dispatchAsyncRequest(deployment.getServletDispatcher(), info, exchange); }
Example #10
Source File: ServletDispatcher.java From quarkus-http with Apache License 2.0 | 2 votes |
/** * Dispatches a servlet request to the specified servlet path, changing the current path * @see io.undertow.servlet.handlers.ServletRequestContext */ void dispatchToPath(final HttpServerExchange exchange, final ServletPathMatch pathMatch, final DispatcherType dispatcherType) throws Exception;
Example #11
Source File: ServletDispatcher.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Dispatches a servlet request to the specified servlet path, changing the current path * @see io.undertow.servlet.handlers.ServletRequestContext */ void dispatchToPath(final HttpServerExchange exchange, final ServletPathMatch pathMatch, final DispatcherType dispatcherType) throws Exception;