public Response serve(Request request) throws InterruptedException {

		authener.authen(request);

		if (request.uri.equals("/")) {
			Response welcome = serveFile(request.uri, request.header,
					getHomeDir(), true);
			welcome.markNoCache();
			return welcome;
		} else if (request.getCookie("d") != null
				&& request.uri.endsWith(request.getCookie("d"))) {
			Servlet servlet = getServlet("/homecam.Capturer.action");
			return servlet.serve(request);
		} else if (request.uri.endsWith(servletUriSuffix)) {
			Servlet servlet = getServlet(request.uri);
			return servlet.serve(request);
		} else {
			try {
				String ext = request.uri.substring(
						request.uri.lastIndexOf('.') + 1).toLowerCase();
				if (ext.equals(request.uri) || theMimeTypes.containsKey(ext)
						|| !authener.requireAuthen(request.uri, request.method)) {
					return serveFile(request.uri, request.header, getHomeDir(),
							true);
				}
			} catch (Exception e) {
				log.error(request.uri, e);
			}
		}
		return new Response(Server.HTTP_FORBIDDEN, Server.MIME_PLAINTEXT,
				"Sorry cannot serve " + request.uri);
	}