@Override public String readAttribute(final HttpServerExchange exchange) { return exchange.getResolvedPath(); }
uri.append("://"); uri.append(exchange.getHostAndPort()); uri.append(encodeUrlPart(exchange.getResolvedPath())); if (exchange.getResolvedPath().endsWith("/")) { if (newRelativePath.startsWith("/")) { uri.append(encodeUrlPart(newRelativePath.substring(1)));
@Override public void start(StartContext context) throws StartException { pathHandler.clearPaths(); SecureRandomSessionIdGenerator generator = new SecureRandomSessionIdGenerator(); pathHandler.addPrefixPath(AFFINITY_PATH, exchange -> { String resolved = exchange.getResolvedPath(); int index = resolved.lastIndexOf(AFFINITY_PATH); if(index > 0) { resolved = resolved.substring(0, index); } exchange.getResponseCookies().put("JSESSIONID", new CookieImpl("JSESSIONID", generator.createSessionId()).setPath(resolved)); }); }
if (pos == -1) { exchange.setRelativePath(newValue); String requestURI = exchange.getResolvedPath() + newValue; if(requestURI.contains("%")) { final String path = newValue.substring(0, pos); exchange.setRelativePath(path); String requestURI = exchange.getResolvedPath() + path; if(requestURI.contains("%")) { exchange.setRequestURI(requestURI.replaceAll("%", "%25"));
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { boolean handlingRequired = File.separatorChar != '/'; if (handlingRequired) { exchange.setRequestPath(canonicalize(exchange.getRequestPath().replace(File.separatorChar, '/'))); exchange.setRelativePath(canonicalize(exchange.getRelativePath().replace(File.separatorChar, '/'))); exchange.setResolvedPath(canonicalize(exchange.getResolvedPath().replace(File.separatorChar, '/'))); } next.handleRequest(exchange); }
exchange.setRequestPath(URLUtils.decode(exchange.getRequestPath(), charset, decodeSlash, false, sb)); exchange.setRelativePath(URLUtils.decode(exchange.getRelativePath(), charset, decodeSlash, false, sb)); exchange.setResolvedPath(URLUtils.decode(exchange.getResolvedPath(), charset, decodeSlash, false, sb)); if (!exchange.getQueryString().isEmpty()) { final TreeMap<String, Deque<String>> newParams = new TreeMap<>();
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { PathMatcher.PathMatch<HttpHandler> match = null; boolean hit = false; if(cache != null) { match = cache.get(exchange.getRelativePath()); hit = true; } if(match == null) { match = pathMatcher.match(exchange.getRelativePath()); } if (match.getValue() == null) { ResponseCodeHandler.HANDLE_404.handleRequest(exchange); return; } if(hit) { cache.add(exchange.getRelativePath(), match); } exchange.setRelativePath(match.getRemaining()); if(exchange.getResolvedPath().isEmpty()) { //first path handler, we can just use the matched part exchange.setResolvedPath(match.getMatched()); } else { //already something in the resolved path exchange.setResolvedPath(exchange.getResolvedPath() + match.getMatched()); } match.getValue().handleRequest(exchange); }
if(!exchange.getResolvedPath().isEmpty() && targetURI.startsWith(exchange.getResolvedPath())) { targetURI = targetURI.substring(exchange.getResolvedPath().length());
@Override public String readAttribute(final HttpServerExchange exchange) { return exchange.getResolvedPath(); }
@Override public String readAttribute(final HttpServerExchange exchange) { return exchange.getResolvedPath(); }
public String getResolvedPath() { return this.exchange.getResolvedPath(); }
@Override public void start(StartContext context) throws StartException { pathHandler.clearPaths(); SecureRandomSessionIdGenerator generator = new SecureRandomSessionIdGenerator(); pathHandler.addPrefixPath(AFFINITY_PATH, exchange -> { String resolved = exchange.getResolvedPath(); int index = resolved.lastIndexOf(AFFINITY_PATH); if(index > 0) { resolved = resolved.substring(0, index); } exchange.getResponseCookies().put("JSESSIONID", new CookieImpl("JSESSIONID", generator.createSessionId()).setPath(resolved)); }); }
@Override public void start(StartContext context) throws StartException { pathHandler.clearPaths(); SecureRandomSessionIdGenerator generator = new SecureRandomSessionIdGenerator(); pathHandler.addPrefixPath(AFFINITY_PATH, exchange -> { String resolved = exchange.getResolvedPath(); int index = resolved.lastIndexOf(AFFINITY_PATH); if(index > 0) { resolved = resolved.substring(0, index); } exchange.getResponseCookies().put("JSESSIONID", new CookieImpl("JSESSIONID", generator.createSessionId()).setPath(resolved)); }); }
if (pos == -1) { exchange.setRelativePath(newValue); String requestURI = exchange.getResolvedPath() + newValue; if(requestURI.contains("%")) { final String path = newValue.substring(0, pos); exchange.setRelativePath(path); String requestURI = exchange.getResolvedPath() + path; if(requestURI.contains("%")) { exchange.setRequestURI(requestURI.replaceAll("%", "%25"));
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { boolean handlingRequired = File.separatorChar != '/'; if (handlingRequired) { exchange.setRequestPath(canonicalize(exchange.getRequestPath().replace(File.separatorChar, '/'))); exchange.setRelativePath(canonicalize(exchange.getRelativePath().replace(File.separatorChar, '/'))); exchange.setResolvedPath(canonicalize(exchange.getResolvedPath().replace(File.separatorChar, '/'))); } next.handleRequest(exchange); }
if (pos == -1) { exchange.setRelativePath(newValue); String requestURI = exchange.getResolvedPath() + newValue; if(requestURI.contains("%")) { final String path = newValue.substring(0, pos); exchange.setRelativePath(path); String requestURI = exchange.getResolvedPath() + path; if(requestURI.contains("%")) { exchange.setRequestURI(requestURI.replaceAll("%", "%25"));
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { boolean handlingRequired = File.separatorChar != '/'; if (handlingRequired) { exchange.setRequestPath(canonicalize(exchange.getRequestPath().replace(File.separatorChar, '/'))); exchange.setRelativePath(canonicalize(exchange.getRelativePath().replace(File.separatorChar, '/'))); exchange.setResolvedPath(canonicalize(exchange.getResolvedPath().replace(File.separatorChar, '/'))); } next.handleRequest(exchange); }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { boolean decodeDone = exchange.getConnection().getUndertowOptions().get(UndertowOptions.DECODE_URL, true); if (!decodeDone) { final StringBuilder sb = new StringBuilder(); final boolean decodeSlash = exchange.getConnection().getUndertowOptions().get(UndertowOptions.ALLOW_ENCODED_SLASH, false); exchange.setRequestPath(URLUtils.decode(exchange.getRequestPath(), charset, decodeSlash, false, sb)); exchange.setRelativePath(URLUtils.decode(exchange.getRelativePath(), charset, decodeSlash, false, sb)); exchange.setResolvedPath(URLUtils.decode(exchange.getResolvedPath(), charset, decodeSlash, false, sb)); if (!exchange.getQueryString().isEmpty()) { final TreeMap<String, Deque<String>> newParams = new TreeMap<>(); for (Map.Entry<String, Deque<String>> param : exchange.getQueryParameters().entrySet()) { final Deque<String> newVales = new ArrayDeque<>(param.getValue().size()); for (String val : param.getValue()) { newVales.add(URLUtils.decode(val, charset, true, true, sb)); } newParams.put(URLUtils.decode(param.getKey(), charset, true, true, sb), newVales); } exchange.getQueryParameters().clear(); exchange.getQueryParameters().putAll(newParams); } } next.handleRequest(exchange); }
exchange.setRequestPath(URLUtils.decode(exchange.getRequestPath(), charset, decodeSlash, false, sb)); exchange.setRelativePath(URLUtils.decode(exchange.getRelativePath(), charset, decodeSlash, false, sb)); exchange.setResolvedPath(URLUtils.decode(exchange.getResolvedPath(), charset, decodeSlash, false, sb)); if (!exchange.getQueryString().isEmpty()) { final TreeMap<String, Deque<String>> newParams = new TreeMap<>();
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { PathMatcher.PathMatch<HttpHandler> match = null; boolean hit = false; if(cache != null) { match = cache.get(exchange.getRelativePath()); hit = true; } if(match == null) { match = pathMatcher.match(exchange.getRelativePath()); } if (match.getValue() == null) { ResponseCodeHandler.HANDLE_404.handleRequest(exchange); return; } if(hit) { cache.add(exchange.getRelativePath(), match); } exchange.setRelativePath(match.getRemaining()); if(exchange.getResolvedPath().isEmpty()) { //first path handler, we can just use the matched part exchange.setResolvedPath(match.getMatched()); } else { //already something in the resolved path exchange.setResolvedPath(exchange.getResolvedPath() + match.getMatched()); } match.getValue().handleRequest(exchange); }