@Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { exchange.setResolvedPath(newValue); }
@Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { int pos = newValue.indexOf('?'); if (pos == -1) { exchange.setRelativePath(newValue); exchange.setRequestURI(newValue); exchange.setRequestPath(newValue); exchange.setResolvedPath(""); } else { final String path = newValue.substring(0, pos); exchange.setRelativePath(path); exchange.setRequestURI(path); exchange.setRequestPath(path); exchange.setResolvedPath(""); final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange))); } }
@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 writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { int pos = newValue.indexOf('?'); exchange.setResolvedPath(""); if (pos == -1) { exchange.setRelativePath(newValue); exchange.setRequestURI(newValue); exchange.setRequestPath(newValue); } else { final String path = newValue.substring(0, pos); exchange.setRequestPath(path); exchange.setRelativePath(path); exchange.setRequestURI(newValue); final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(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); }
@Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { exchange.setResolvedPath(newValue); }
@Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { exchange.setResolvedPath(newValue); }
private void fixURL( final HttpServerExchange exchange, final URI uri ) { val relativePath = uri.getPath() == null ? "/" : uri.getPath(); exchange.setRelativePath( relativePath ); exchange.setRequestPath( relativePath ); exchange.setResolvedPath( relativePath ); exchange.setRequestURI( uri.toString() ); } }
@Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { int pos = newValue.indexOf('?'); if (pos == -1) { exchange.setRelativePath(newValue); exchange.setRequestURI(newValue); exchange.setRequestPath(newValue); exchange.setResolvedPath(""); } else { final String path = newValue.substring(0, pos); exchange.setRelativePath(path); exchange.setRequestURI(path); exchange.setRequestPath(path); exchange.setResolvedPath(""); final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange))); } }
@Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { int pos = newValue.indexOf('?'); if (pos == -1) { exchange.setRelativePath(newValue); exchange.setRequestURI(newValue); exchange.setRequestPath(newValue); exchange.setResolvedPath(""); } else { final String path = newValue.substring(0, pos); exchange.setRelativePath(path); exchange.setRequestURI(path); exchange.setRequestPath(path); exchange.setResolvedPath(""); final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange))); } }
@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 writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { int pos = newValue.indexOf('?'); exchange.setResolvedPath(""); if (pos == -1) { exchange.setRelativePath(newValue); exchange.setRequestURI(newValue); exchange.setRequestPath(newValue); } else { final String path = newValue.substring(0, pos); exchange.setRequestPath(path); exchange.setRelativePath(path); exchange.setRequestURI(newValue); final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange))); } }
@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 writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { int pos = newValue.indexOf('?'); exchange.setResolvedPath(""); if (pos == -1) { exchange.setRelativePath(newValue); exchange.setRequestURI(newValue); exchange.setRequestPath(newValue); } else { final String path = newValue.substring(0, pos); exchange.setRequestPath(path); exchange.setRelativePath(path); exchange.setRequestURI(newValue); final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(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<>();
if(exchange.getResolvedPath().isEmpty()) { exchange.setResolvedPath(match.getMatched()); } else { sb.append(exchange.getResolvedPath()); sb.append(match.getMatched()); exchange.setResolvedPath(sb.toString());
@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); }
exchange.setRequestPath(errorPage); exchange.setRelativePath(errorPage); exchange.setResolvedPath(errorPage); next.handleRequest(exchange); return;