@@ -0,0 +1,2540 @@
+package io.undertow.util;%0A%0Aimport io.undertow.server.HttpServerExchange;%0A%0Aimport java.io.UnsupportedEncodingException;%0Aimport java.net.URLEncoder;%0Aimport java.util.Deque;%0Aimport java.util.Map;%0A%0A/**%0A * Utility class for building redirects.%0A *%0A * @author Stuart Douglas%0A */%0Apublic class RedirectBuilder %7B%0A%0A    public static final String UTF_8 = %22UTF-8%22;%0A%0A    /**%0A     * Redirects to a new relative path. All other data from the exchange is preserved.%0A     *%0A     * @param exchange        The HTTP server exchange%0A     * @param newRelativePath The new relative path%0A     * @return%0A     */%0A    public static String redirect(final HttpServerExchange exchange, final String newRelativePath) %7B%0A        try %7B%0A            StringBuilder uri = new StringBuilder(exchange.getRequestScheme());%0A            uri.append(%22://%22);%0A            uri.append(exchange.getHostAndPort());%0A            uri.append(URLEncoder.encode(exchange.getResolvedPath(), UTF_8));%0A            if (exchange.getResolvedPath().endsWith(%22/%22)) %7B%0A                if (newRelativePath.startsWith(%22/%22)) %7B%0A                    uri.append(URLEncoder.encode(newRelativePath.substring(1), UTF_8));%0A                %7D else %7B%0A                    uri.append(URLEncoder.encode(newRelativePath, UTF_8));%0A                %7D%0A            %7D else %7B%0A                if (!newRelativePath.startsWith(%22/%22)) %7B%0A                    uri.append('/');%0A                %7D%0A                uri.append(URLEncoder.encode(newRelativePath, UTF_8));%0A            %7D%0A            if(!exchange.getPathParameters().isEmpty()) %7B%0A                boolean first = true;%0A                uri.append(';');%0A                for(Map.Entry%3CString, Deque%3CString%3E%3E param : exchange.getPathParameters().entrySet()) %7B%0A                    for(String value : param.getValue()) %7B%0A                        if(first) %7B%0A                            first = false;%0A                        %7D else %7B%0A                            uri.append('&');%0A                        %7D%0A                        uri.append(URLEncoder.encode(param.getKey(), UTF_8));%0A                        uri.append('=');%0A                        uri.append(URLEncoder.encode(value, UTF_8));%0A                    %7D%0A                %7D%0A            %7D%0A            if(!exchange.getQueryString().isEmpty()) %7B%0A                uri.append('?');%0A                uri.append(exchange.getQueryString());%0A            %7D%0A            return uri.toString();%0A        %7D catch (UnsupportedEncodingException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A    private RedirectBuilder() %7B%0A%0A    %7D%0A%7D%0A

Add RedirectBuilder utility class