@@ -0,0 +1,2563 @@
+/*%0A * JBoss, Home of Professional Open Source.%0A * Copyright 2012 Red Hat, Inc., and individual contributors%0A * as indicated by the @author tags.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage io.undertow.server.handlers.file;%0A%0Aimport java.io.File;%0A%0Aimport io.undertow.UndertowLogger;%0Aimport io.undertow.UndertowMessages;%0Aimport io.undertow.server.HttpCompletionHandler;%0Aimport io.undertow.server.HttpHandler;%0Aimport io.undertow.server.HttpServerExchange;%0A%0A/**%0A *%0A * Serves files direct from the file system.%0A *%0A * @author Stuart Douglas%0A */%0Apublic class FileHandler implements HttpHandler %7B%0A%0A    private volatile File base;%0A    private volatile FileCache fileCache = DirectFileCache.INSTANCE;%0A%0A    public FileHandler(final File base) %7B%0A        if (base == null) %7B%0A            throw UndertowMessages.MESSAGES.argumentCannotBeNull();%0A        %7D%0A        this.base = base;%0A    %7D%0A%0A    @Override%0A    public void handleRequest(final HttpServerExchange exchange, final HttpCompletionHandler completionHandler) %7B%0A        final File file = new File(base.getAbsolutePath() + File.separatorChar + exchange.getRelativePath());%0A        //TODO: is there a better way to do this check%0A        if(!file.getAbsolutePath().startsWith(base.getAbsolutePath())) %7B%0A            UndertowLogger.REQUEST_LOGGER.fileHandlerWithoutCanonicalPathHandler();%0A            exchange.setResponseCode(500);%0A            completionHandler.handleComplete();%0A            return;%0A        %7D%0A        fileCache.serveFile(exchange, completionHandler, file);%0A    %7D%0A%0A    public File getBase() %7B%0A        return base;%0A    %7D%0A%0A    public void setBase(final File base) %7B%0A        if (base == null) %7B%0A            throw UndertowMessages.MESSAGES.argumentCannotBeNull();%0A        %7D%0A        this.base = base;%0A    %7D%0A%0A    public FileCache getFileCache() %7B%0A        return fileCache;%0A    %7D%0A%0A    public void setFileCache(final FileCache fileCache) %7B%0A        if (fileCache == null) %7B%0A            throw UndertowMessages.MESSAGES.argumentCannotBeNull();%0A        %7D%0A        this.fileCache = fileCache;%0A    %7D%0A%7D%0A

Add handler for serving static files