@Override public void handle(HttpExchange t) throws IOException { LOGGER.debug("root req " + t.getRequestURI()); if (RemoteUtil.deny(t)) { throw new IOException("Access denied"); } if (t.getRequestURI().getPath().contains("favicon")) { RemoteUtil.sendLogo(t); return; } HashMap<String, Object> vars = new HashMap<>(); vars.put("logs", getLogs(true)); if (configuration.getUseCache()) { vars.put( "cache", "http://" + PMS.get().getServer().getHost() + ":" + PMS.get().getServer().getPort() + "/console/home"); } String response = parent.getResources().getTemplate("doc.html").execute(vars); RemoteUtil.respond(t, response, 200, "text/html"); }
@Override public void handle(HttpExchange t) throws IOException { LOGGER.debug("root req " + t.getRequestURI()); if (RemoteUtil.deny(t)) { throw new IOException("Access denied"); } if (t.getRequestURI().getPath().contains("favicon")) { RemoteUtil.sendLogo(t); return; } HashMap<String, Object> vars = new HashMap<>(); vars.put("serverName", configuration.getServerName()); vars.put("profileName", configuration.getProfileName()); String response = parent.getResources().getTemplate("start.html").execute(vars); RemoteUtil.respond(t, response, 200, "text/html"); }
@Override public void handle(HttpExchange t) throws IOException { if (RemoteUtil.deny(t)) { throw new IOException("Access denied"); } String id = RemoteUtil.getId("thumb/", t); LOGGER.trace("web thumb req " + id); if (id.contains("logo")) { RemoteUtil.sendLogo(t); return; } RootFolder root = parent.getRoot(RemoteUtil.userName(t), t); if (root == null) { LOGGER.debug("weird root in thumb req"); throw new IOException("Unknown root"); } final DLNAResource r = root.getDLNAResource(id, root.getDefaultRenderer()); if (r == null) { // another error LOGGER.debug("media unknown"); throw new IOException("Bad id"); } InputStream in; if (!configuration.isShowCodeThumbs() && !r.isCodeValid(r)) { // we shouldn't show the thumbs for coded objects // unless the code is entered in = r.getGenericThumbnailInputStream(null); } else { r.checkThumbnail(); in = r.getThumbnailInputStream(); } Headers hdr = t.getResponseHeaders(); hdr.add("Content-Type", r.getThumbnailContentType()); hdr.add("Accept-Ranges", "bytes"); hdr.add("Connection", "keep-alive"); t.sendResponseHeaders(200, in.available()); OutputStream os = t.getResponseBody(); LOGGER.trace("input is {} output is {}", in, os); RemoteUtil.dump(in, os); }